class Xcflushd::Reporter
Attributes
threescale_client[R]
Public Class Methods
new(threescale_client)
click to toggle source
# File lib/xcflushd/reporter.rb, line 43 def initialize(threescale_client) @threescale_client = threescale_client end
Public Instance Methods
report(service_id, credentials, usage)
click to toggle source
# File lib/xcflushd/reporter.rb, line 47 def report(service_id, credentials, usage) transaction = credentials.creds.merge(usage: usage) begin resp = threescale_client.report(transactions: [transaction], service_id: service_id) # TODO: get rid of the coupling with ThreeScale::ServerError rescue ThreeScale::ServerError, SocketError # We'll get a SocketError if there's a timeout when contacting 3scale. raise ThreeScaleInternalError.new(service_id, transaction) rescue ArgumentError raise ThreeScaleBadParams.new(service_id, transaction) end raise ThreeScaleAuthError.new(service_id, transaction) unless resp.success? true end