Class: AdvancedBilling::OffersController
- Inherits:
-
BaseController
- Object
- BaseController
- AdvancedBilling::OffersController
- Defined in:
- lib/advanced_billing/controllers/offers_controller.rb
Overview
OffersController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#archive_offer(offer_id) ⇒ void
Archive an existing offer.
-
#create_offer(body: nil) ⇒ OfferResponse
Create an offer within your Advanced Billing site by sending a POST request.
-
#list_offers(options = {}) ⇒ ListOffersResponse
This endpoint will list offers for a site.
-
#read_offer(offer_id) ⇒ OfferResponse
This method allows you to list a specific offer’s attributes.
-
#unarchive_offer(offer_id) ⇒ void
Unarchive a previously archived offer.
Methods inherited from BaseController
#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from AdvancedBilling::BaseController
Instance Method Details
#archive_offer(offer_id) ⇒ void
This method returns an undefined value.
Archive an existing offer. Please provide an ‘offer_id` in order to archive the correct item. offer
109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 109 def archive_offer(offer_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/offers/{offer_id}/archive.json', Server::PRODUCTION) .template_param(new_parameter(offer_id, key: 'offer_id') .is_required(true) .should_encode(true)) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_response_void(true)) .execute end |
#create_offer(body: nil) ⇒ OfferResponse
Create an offer within your Advanced Billing site by sending a POST request. ## Documentation Offers allow you to package complicated combinations of products, components and coupons into a convenient package which can then be subscribed to just like products. Once an offer is defined it can be used as an alternative to the product when creating subscriptions. Full documentation on how to use offers in the Advanced Billing UI can be located [here](maxio.zendesk.com/hc/en-us/articles/24261295098637-Offers-O verview). ## Using a Product Price Point You can optionally pass in a ‘product_price_point_id` that corresponds with the `product_id` and the offer will use that price point. If a `product_price_point_id` is not passed in, the product’s default price point will be used.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 28 def create_offer(body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/offers.json', Server::PRODUCTION) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(OfferResponse.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorArrayMapResponseException)) .execute end |
#list_offers(options = {}) ⇒ ListOffersResponse
This endpoint will list offers for a site. pages. By default, the first page of results is displayed. The page parameter specifies a page number of results to fetch. You can start navigating through the pages to consume the results. You do this by passing in a page parameter. Retrieve the next page by adding ?page=2 to the query string. If there are no results to return, then an empty result set will be returned. Use in query ‘page=1`. many records to fetch in each request. Default value is 20. The maximum allowed values is 200; any per_page value over 200 will be changed to 200. Use in query `per_page=200`. Include archived products. Use in query: `include_archived=true`.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 63 def list_offers( = {}) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/offers.json', Server::PRODUCTION) .query_param(new_parameter(['page'], key: 'page')) .query_param(new_parameter(['per_page'], key: 'per_page')) .query_param(new_parameter(['include_archived'], key: 'include_archived')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListOffersResponse.method(:from_hash)) .local_error_template('422', 'HTTP Response Not OK. Status code: {$statusCode}.'\ ' Response: \'{$response.body}\'.', ErrorListResponseException)) .execute end |
#read_offer(offer_id) ⇒ OfferResponse
This method allows you to list a specific offer’s attributes. This is different than list all offers for a site, as it requires an ‘offer_id`. offer
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 88 def read_offer(offer_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/offers/{offer_id}.json', Server::PRODUCTION) .template_param(new_parameter(offer_id, key: 'offer_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(OfferResponse.method(:from_hash))) .execute end |
#unarchive_offer(offer_id) ⇒ void
This method returns an undefined value.
Unarchive a previously archived offer. Please provide an ‘offer_id` in order to un-archive the correct item. offer
128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 128 def unarchive_offer(offer_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/offers/{offer_id}/unarchive.json', Server::PRODUCTION) .template_param(new_parameter(offer_id, key: 'offer_id') .is_required(true) .should_encode(true)) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_response_void(true)) .execute end |