Class: Warbler::RewardsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Warbler::RewardsController
- Defined in:
- lib/warbler/controllers/rewards_controller.rb
Instance Method Summary collapse
-
#bid(amount, id) ⇒ Object
Bid on a reward auction.
-
#list(category_id: nil, limit: 25, offset: 0) ⇒ Object
List all the available rewards.
-
#redeem(id) ⇒ Object
Redeem a reward.
-
#show(id) ⇒ Object
Show a reward’s details.
Methods inherited from ApplicationController
Constructor Details
This class inherits a constructor from Warbler::ApplicationController
Instance Method Details
#bid(amount, id) ⇒ Object
Bid on a reward auction.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/warbler/controllers/rewards_controller.rb', line 32 def bid amount, id # the base uri for api requests query_builder = base_uri # prepare query string for API call query_builder << "/v3/rewards/#{ id }/bids" # process optional query parameters query_builder = APIHelper.append_url_with_template_parameters query_builder, { "id" => id, "amount" => amount } perform_query('post', query_builder) end |
#list(category_id: nil, limit: 25, offset: 0) ⇒ Object
List all the available rewards.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/warbler/controllers/rewards_controller.rb', line 11 def list category_id: nil, limit: 25, offset: 0 # the base uri for api requests query_builder = base_uri # prepare query string for API call query_builder << "/v3/rewards" # process optional query parameters query_builder = APIHelper.append_url_with_query_parameters query_builder, { "category_id" => category_id, "limit" => if limit.nil? then 25 else limit end, "offset" => if offset.nil? then 0 else offset end, } perform_query('get', query_builder) end |
#redeem(id) ⇒ Object
Redeem a reward.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/warbler/controllers/rewards_controller.rb', line 69 def redeem id # the base uri for api requests query_builder = base_uri # prepare query string for API call query_builder << "/v3/rewards/#{ id }/redemptions" # process optional query parameters query_builder = APIHelper.append_url_with_template_parameters query_builder, { "id" => id, } perform_query('post', query_builder) end |
#show(id) ⇒ Object
Show a reward’s details.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/warbler/controllers/rewards_controller.rb', line 51 def show id # the base uri for api requests query_builder = base_uri # prepare query string for API call query_builder << "/v3/rewards/#{ id }" # process optional query parameters query_builder = APIHelper.append_url_with_template_parameters query_builder, { "id" => id, } perform_query('get', query_builder) end |