Class: Stash::Rewards::IssueVoucher
- Inherits:
-
ApiWrapper
- Object
- ApiWrapper
- Stash::Rewards::IssueVoucher
- Defined in:
- lib/stash/rewards/issue_voucher.rb
Instance Method Summary collapse
Methods inherited from ApiWrapper
Constructor Details
This class inherits a constructor from Stash::Rewards::ApiWrapper
Instance Method Details
#call(campaign_id:, user_identifier:, reward_id:, quantity: 1) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/stash/rewards/issue_voucher.rb', line 8 def call(campaign_id:, user_identifier:, reward_id:, quantity: 1) price = reward_price(reward_id, campaign_id) api_response = api_wrapper.post("campaigns/#{campaign_id}/users/refId_#{user_identifier}/rewards/order") do |req| req.body = order_payload(reward_id, quantity, price) end response = Stash::Rewards::Response.new(api_response) raise Stash::Rewards::Error, response. if response.error? response rescue Faraday::Error => e raise Stash::Rewards::Error, e. end |