class BalihooLpcClient::Request::Metrics

Attributes

tactic_id[RW]

Public Class Methods

new(api:, params:, tactic_id:) click to toggle source
Calls superclass method BalihooLpcClient::Request::ApiBase::new
# File lib/balihoo_lpc_client/request/metrics.rb, line 6
def initialize(api:, params:, tactic_id:)
  super(api: api, params: params)
  self.tactic_id = tactic_id
end

Public Instance Methods

fetch() click to toggle source
# File lib/balihoo_lpc_client/request/metrics.rb, line 11
def fetch
  response = self.class.get("/tactic/#{tactic_id}/metrics", opts).parsed_response
  handle_errors_with(klass: ApiResponseError, response: response)
  handle_response(response: response, klass: klass_for(response: response), mappable: false)
end

Private Instance Methods

klass_for(response:) click to toggle source
# File lib/balihoo_lpc_client/request/metrics.rb, line 19
def klass_for(response:)
  case (multiple_locations? ? response.values.first['channel'] : response['channel'])
  when /Email/
    Response::EmailMetric
  when /Paid Search/
    Response::PaidSearchMetric
  when /Display/
    Response::DisplayMetric
  end
end