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 Chargify site by sending a POST request.
-
#list_offers ⇒ ListOffersResponse
This endpoint will list offers for a site.
-
#read_offers(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
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 114 def archive_offer(offer_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/offers/{offer_id}/archive.json', Server::DEFAULT) .template_param(new_parameter(offer_id, key: 'offer_id') .is_required(true) .should_encode(true)) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .is_response_void(true) .local_error('401', 'Unauthorized', APIException)) .execute end |
#create_offer(body: nil) ⇒ OfferResponse
Create an offer within your Chargify 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 Chargify UI can be located [here](chargify.zendesk.com/hc/en-us/articles/4407753852059). ## 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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 25 def create_offer(body: nil) new_api_call_builder .request(new_request_builder(HttpMethodEnum::POST, '/offers.json', Server::DEFAULT) .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 .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(OfferResponse.method(:from_hash)) .local_error('422', 'Unprocessable Entity (WebDAV)', ErrorMapResponseException)) .execute end |
#list_offers ⇒ ListOffersResponse
This endpoint will list offers for a site.
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 47 def list_offers new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/offers.json', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(ListOffersResponse.method(:from_hash))) .execute end |
#read_offers(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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 66 def read_offers(offer_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::GET, '/offers/{offer_id}.json', Server::DEFAULT) .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 .is_nullify404(true) .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(OfferResponse.method(:from_hash)) .local_error('401', 'Unauthorized', APIException)) .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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/advanced_billing/controllers/offers_controller.rb', line 91 def unarchive_offer(offer_id) new_api_call_builder .request(new_request_builder(HttpMethodEnum::PUT, '/offers/{offer_id}/unarchive.json', Server::DEFAULT) .template_param(new_parameter(offer_id, key: 'offer_id') .is_required(true) .should_encode(true)) .auth(Single.new('BasicAuth'))) .response(new_response_handler .is_nullify404(true) .is_response_void(true) .local_error('401', 'Unauthorized', APIException)) .execute end |