Class: Unit::Resource::RewardResource

Inherits:
BaseResource show all
Defined in:
lib/unit/api_resources/reward_resource.rb

Class Method Summary collapse

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

Parameters:

  • request (CreateRewardRequest)

Returns:



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

Parameters:

  • request (GetRequest)

Returns:



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

Parameters:

  • params (ListRewardParams) (defaults to: nil)

Returns:



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