Class: Stash::Rewards::EnrolUserInCampaign
- Inherits:
-
ApiWrapper
- Object
- ApiWrapper
- Stash::Rewards::EnrolUserInCampaign
- Defined in:
- lib/stash/rewards/enrol_user_in_campaign.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:) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/stash/rewards/enrol_user_in_campaign.rb', line 8 def call(campaign_id:, user_identifier:) api_response = api_wrapper.post("campaigns/#{campaign_id}/users") do |req| req.body = user_payload(user_identifier) 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 |