Class: Unit::Resource::RewardResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Unit::Resource::RewardResource
- Defined in:
- lib/unit/api_resources/reward_resource.rb
Class Method Summary collapse
-
.create_reward(request) ⇒ UnitResponse, UnitError
Create a new reward by calling Unit’s API.
-
.get_reward(request) ⇒ UnitResponse, UnitError
Get a reward by calling Unit’s API.
-
.list_rewards(params = nil) ⇒ UnitResponse, UnitError
List rewards by calling Unit’s API.
Methods inherited from BaseResource
file_response_handler, response_handler
Class Method Details
.create_reward(request) ⇒ UnitResponse, UnitError
Create a new reward by calling Unit’s API
16 17 18 19 20 |
# File 'lib/unit/api_resources/reward_resource.rb', line 16 def create_reward(request) payload = request.to_json_api response = HttpHelper.post("#{api_url}/rewards", body: payload, headers: headers) response_handler(response) end |
.get_reward(request) ⇒ UnitResponse, UnitError
Get a reward by calling Unit’s API
25 26 27 28 29 |
# File 'lib/unit/api_resources/reward_resource.rb', line 25 def get_reward(request) payload = request.to_hash response = HttpHelper.get("#{api_url}/rewards/#{request.reward_id}", params: payload, headers: headers) response_handler(response) end |
.list_rewards(params = nil) ⇒ UnitResponse, UnitError
List rewards by calling Unit’s API
34 35 36 37 |
# File 'lib/unit/api_resources/reward_resource.rb', line 34 def list_rewards(params = nil) response = HttpHelper.get("#{api_url}/rewards", params: params&.to_hash, headers: headers) response_handler(response) end |