Class: Stash::Rewards::GetRewards

Inherits:
ApiWrapper show all
Defined in:
lib/stash/rewards/get_rewards.rb

Instance Method Summary collapse

Methods inherited from ApiWrapper

#initialize

Constructor Details

This class inherits a constructor from Stash::Rewards::ApiWrapper

Instance Method Details

#call(campaign_id:, page_no: 0, page_size: 500) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/stash/rewards/get_rewards.rb', line 8

def call(campaign_id:, page_no: 0, page_size: 500)
  api_response = api_wrapper.get("campaigns/#{campaign_id}/rewards") do |req|
    req.params = query_params(page_no, page_size)
  end
  response = Stash::Rewards::Response.new(api_response)
  raise Stash::Rewards::Error, response.error_message if response.error?

  response
rescue Faraday::Error => e
  raise Stash::Rewards::Error, e.message
end