Class: StickyIoRestfulApiV2025731::OffersController
- Inherits:
-
BaseController
- Object
- BaseController
- StickyIoRestfulApiV2025731::OffersController
- Defined in:
- lib/sticky_io_restful_api_v2025731/controllers/offers_controller.rb
Overview
OffersController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_offer(body, domain, v2_ext) ⇒ ApiResponse
Create a new offer **Request Data** Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | | — | — | — | — | — | | name | Required | - | String | The offer name | | billing_models | Required | - | Array | Billing models associated with the offer | | products | Optional | - | Array | Products associated with the offer | | recurring | Optional | - | Object | Determines if it’s a recurring offer and the cycles | | is_trial | Optional | 0 | Integer Flag | Determines if it is a trial | | trial | Optional | - | Object | Describes the trial parameters for the offer | | type_id | Conditionally Required | - | Integer | This is a new parameter for all new offer types to use.
-
#delete_offer(domain, v2_ext, offer_id) ⇒ ApiResponse
Delete an existing offer.
-
#get_all_offers(domain, v2_ext) ⇒ ApiResponse
This method is used to get all available offers.
-
#get_offer(domain, v2_ext, offer_id) ⇒ ApiResponse
Fetch a specific offer object by ID.
-
#update_offer(body, domain, v2_ext, offer_id) ⇒ ApiResponse
TODO: type endpoint description here description here.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters
Constructor Details
This class inherits a constructor from StickyIoRestfulApiV2025731::BaseController
Instance Method Details
#create_offer(body, domain, v2_ext) ⇒ ApiResponse
Create a new offer **Request Data** Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | | — | — | — | — | — | | name | Required | - | String | The offer name | | billing_models | Required | - | Array | Billing models associated with the offer | | products | Optional | - | Array | Products associated with the offer | | recurring | Optional | - | Object | Determines if it’s a recurring offer and the cycles | | is_trial | Optional | 0 | Integer Flag | Determines if it is a trial | | trial | Optional | - | Object | Describes the trial parameters for the offer | | type_id | Conditionally Required | - | Integer | This is a new parameter for all new offer types to use. Required if you didn’t pass any other offers definitions. To get the full list of type IDs use ‘Get Offer Types` endpoint | description here
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/offers_controller.rb', line 251 def create_offer(body, domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}offers', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(CreateStandardOffer.method(:from_hash)) .is_api_response(true)) .execute end |
#delete_offer(domain, v2_ext, offer_id) ⇒ ApiResponse
Delete an existing offer.
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/offers_controller.rb', line 282 def delete_offer(domain, v2_ext, offer_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}offers/{offer_id}', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .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('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DeleteOffer.method(:from_hash)) .is_api_response(true)) .execute end |
#get_all_offers(domain, v2_ext) ⇒ ApiResponse
This method is used to get all available offers. **Max Requests Per Minute**: 120 ## Response Parameters |Parameter|Type|Description| |:-|-|-| |id|int|This is the ID for the related offer.| |name|string|This is the name of the related offer.| |recurring_type|string|This parameter returns the type of recurring process that occurs. Can be Self Recurring or Custom Next Recurring.| |trial_flag|int/bool|This parameter will only be present if there is a trial present on the order. Possible return values: 1 of 0.| |cycle_count|int|This is the number of cycles related to the particular offer.| |expiration|int/bool|If return value is 0 there is no expiration, if the return value is 1 the offer has an expiration.| |terminating_cycle_type|int|This parameter will contain the ID of the related cycle type attached to the offer.| |terminating_product_id|int|This is the ID of the last product on the billing cycle.| |recurring_product_id|int|This is the ID of the recurring product tied to the related offer.| |recurring_product_name|string|This is the name of the recurring product tied to the offer.| |trial|json|Payload of the related trial info.| |price|json|Nested within the trial parameter. Describes the trial price.| |duration|json|Nested within the trial parameter. Describes the duration of the trial| |products|json|Payload of products attached to the current offer. The key is the product_id and the value is the Product name| |billing_models|json|Payload of the billing models attached to the offer. The key is the billing_model_id and the value is the Billing Model name| |billing_models_detail|json|Array of payloads of the billing models attached to the offer.|
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/offers_controller.rb', line 171 def get_all_offers(domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}offers', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .auth(Single.new('basic'))) .response(new_response_handler .is_response_void(true) .is_api_response(true)) .execute end |
#get_offer(domain, v2_ext, offer_id) ⇒ ApiResponse
Fetch a specific offer object by ID. **Response Data**\ Response parameters expected in each response object contained within the ‘data` field object: | Field | Data Type | Description | | - | - | - | | id | Integer | The offer ID. | name | String | The offer name. | cycle_type_id | Integer | The cycle type ID. | terminating_product_id | Integer | The terminating product ID. | expire_cycles | Integer| Number of cycles for this offer. | is_seasonal | Integer Flag | Specifies wether it is a seasonal offer. | is_immutable | Integer Flag | Specifies wether ? | is_store | Integer Flag | - | | is_available_on_syncable | Integer flag | Specifies wether ? | type_id | Integer | The type ID. | created_at.date | Date time | date time when the offer was created. | created_at.timezone_type | Integer | timezone type where the offer was created. | created_at.timezone | String | Name of the timezone where the offer was created. | updated_at.date | Date time | date time when the offer was updated. | updated_at.timezone_type | Integer | timezone type where the offer was updated. | created_at.timezone | String | Name of the timezone where the offer was updated. | is_archived | Integer Flag | Specifies wether the offer is archived. | products | Array | List the product object associated with this offer. | billing_models | Array | Billing models associated with this offer. | billing_models.*.id | Integer | The billing model ID. | billing_models.*.name | String | The billing model name. | billing_models.*.created_at | Object | Creation date time and timezone. | billing_models.*.updated_at | Object | Last update date time and timezone. | billing_models.*.is_archived | Integer Flag | Specifies wether the billing model is archived. | billing_models.*.is_preserve_quantity | Integer Flag | Specifies wether the quantity is to be preserved. | billing_models.*.is_default | Integer Flag | Specifies if this is the default billing model. | billing_models.*.description | String | Billing model description. | billing_models.*.type | Object | Billing model type. | billing_models.*.type.id | Integer | Billing model type ID. | billing_models.*.type.name | String | Billing model type name. | billing_models.*.frequency | Integer | Billing model frequency. | billing_models.*.frequency_type_id | Integer | Billing model frequency type ID. | billing_models.*.discount | Integer | Billing model discount. | is_prepaid | Integer Flag | Specifies if it is a prepaid offer. | is_series | Integer Flag | Specifies wether the offer is ??? | type.id | Integer | The type ID. | type.name | String | The type name. | type.active | Integer Flag | Specifies if type is active. | type.smc_active | Integer Flag | Specifies if the System Module Control is active. | cycle_type.id | Integer | The cycle type ID. | cycle_type.name | String | The cycle type string. | terminating_cycle_type.id | Integer | The terminating cycle type ID. | terminating_cycle_type.name | String | The terminating cycle type name. | terminating_cycle_type.description | String | The terminating cycle type description. | prepaid_profile | - | - ??? | trial | Array | Trials associated with the offer. | trial_workflows | Array | Trial workflows associated with the offer. | cycle_products | Array | List of the associated seasonal products. | seasonal_products | Array | List of the associated seasonal products. | is_trial | Integer Flag | Specifies wether offer is a trial. | terminating_product_name | String | Terminating product name. | offer_billing_models | Array | List of all the offer billing models associated with offer. | offer_billing_models.*.id | Integer | The offer billing model ID. | offer_billing_models.*.name | String | The offer billing model name. | offer_billing_models.*.created_at | Object | Offer billing model creation date time and timezone. | offer_billing_models.*.updated_at | Object | offer billing model last update date time and timezone. | offer_billing_models.*.is_archived | Integer Flag | Specifies wether the offer billing model is archived. | offer_billing_models.*.is_preserve_quantity | Integer Flag | Specifies wether the offer billing model preserves quantity. | offer_billing_models.*.is_default | Integer Flag | Specifies if this is the default offer billing model. | offer_billing_models.*.description | String | The offer billing model description. | offer_billing_models.*.type | Object | The offer billing model type | offer_billing_models.*.frequency | Integer | Offer billing model frequency. | offer_billing_models.*.frequency_type_id | Integer | Offer billing model frequency type ID. | offer_billing_models.*.discount | Integer | Offer billing model discount. | terminating_cycle_product | Object | The terminating cycle product for the offer
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/offers_controller.rb', line 106 def get_offer(domain, v2_ext, offer_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}offers/{offer_id}', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .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('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetOffer.method(:from_hash)) .is_api_response(true) .local_error('404', 'Not Found', GetOfferNotFoundException)) .execute end |
#update_offer(body, domain, v2_ext, offer_id) ⇒ ApiResponse
TODO: type endpoint description here description here
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/offers_controller.rb', line 198 def update_offer(body, domain, v2_ext, offer_id) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/.{domain}{v2_ext}offers/{offer_id}', Server::SERVER_1) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(body) .is_required(true)) .template_param(new_parameter(domain, key: 'domain') .is_required(true) .should_encode(true)) .template_param(new_parameter(v2_ext, key: 'v2_ext') .is_required(true) .should_encode(true)) .template_param(new_parameter(offer_id, key: 'offer_id') .is_required(true) .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(UpdateOffer.method(:from_hash)) .is_api_response(true)) .execute end |