Class: StickyIoRestfulApiV2025731::CouponsController
- Inherits:
-
BaseController
- Object
- BaseController
- StickyIoRestfulApiV2025731::CouponsController
- Defined in:
- lib/sticky_io_restful_api_v2025731/controllers/coupons_controller.rb
Overview
CouponsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_coupon_profile(body, domain, v2_ext) ⇒ ApiResponse
Create a new coupon profile.
-
#delete_coupon_profile(domain, v2_ext, coupon_id) ⇒ ApiResponse
Delete an existing coupon profile here.
-
#delete_order_coupon(domain, v2_ext) ⇒ ApiResponse
Remove the coupon from the next recurring order.
-
#get_coupon_profile(domain, v2_ext, coupon_id) ⇒ ApiResponse
Fetch a single coupon profile **Response Data**\ Response parameters expected in coupon profile object contained within the ‘data` field object: | Field | Data Type | Description | ————————————— | ———— | ————————————– | | id | Integer | The coupon profile ID.
-
#get_coupon_profiles(domain, v2_ext) ⇒ ApiResponse
Fetch a list of all coupon profiles **Response Data** Response parameters expected in coupon profile object contained within the ‘data` field array: | Field | Data Type | Description | | — | — | — | | id | Integer | The coupon profile ID.
-
#update_coupon_profile(domain, v2_ext, coupon_id) ⇒ ApiResponse
Update an existing coupon profile.
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_coupon_profile(body, domain, v2_ext) ⇒ ApiResponse
Create a new coupon profile. For the ‘promo_codes` array, you make either pass an id of an existing promo code or you can pass the `code` and a new promo code will be generated. For meta data like `type_id` and the like, see the Coupon / Meta folder **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | - | - | - | - | - | | name | Required | - | String | The coupon profile name between 1-30. | description | Required | - | String | The coupon profile description between 1-255. | type_id | Required | - | Integer | The coupon type ID. | discount | Required | - | Object | The coupon discount object associated with coupon profile. | discount.type_id | Required | - | Integer | The coupon discount type ID. | discount.amount | Required Sometimes | - | Float | The coupon discount amount. Required if `discount.type_id` is a `Dollar` | discount.percent | Required Sometimes | - | Integer | The coupon discount percent between 1-100. Required if `discount.type_id` is a `Percent`. | discount.behavior_type_id | Required Sometimes | - | Integer | The coupon discount behavior type ID. | minimum_purchase | Required | - | Float | Coupon profile minimum purchase amount. | product_id | Optional | null | Integer | Coupon profile product ID. | variant_id | Optional | null | Integer | Coupon profile variant ID. | products | Required Sometimes | - | Array | Array of products objects associated with the coupon profile. Required if `type_id` is a `Product` and if `product_id` and `variant_id` are not provided. | products.*.product_id | Required | - | Integer | The product ID. | products.*.variant_id | Required | - | Integer | The variant ID. | minimum_quantity | Required Sometimes | 0 | Integer | Minimum purchase quantity required to activate coupon profile minimum 1. Required if `type_id` is a `Product` and if the `bogo` object is not provided | maximum_quantity | Required Sometimes | 0 | Integer | Maximum purchase quantity to apply product coupon to minimum 1. Required if `type_id` is a `Product` and if the `bogo` object is not provided | is_lifetime | Optional | 0 | Integer Flag | Specifies whether or not a coupon profile will be used throughout the life of a subscription. | is_free_shipping | Optional | 0 | Integer Flag | Specifies whether or not a coupon profile will make the shipping to be free. | expiration | Optional | - | Object | Object that contains data pertaining to the coupon profile’s expiration. | expiration.date | Required | - | date | The coupon profile expiration date YYYY-MM-DD format. | expiration.timezone | Required | - | String | The coupon profile expiration valid timezone name. | limits | Optional | - | Object | An object containing the coupon profile limits. | limits.total | Required | - | Integer | The maximum number of times a coupon profile may be used globally by any customer. | limits.per_customer | Required | - | Integer | The maximum number of times a coupon profile may be used by a single customer. | limits.per_code | Required | - | Integer | The maximum number of times a promo code may be used globally by any customer. | limits.per_code_per_customer | Required | - | Integer | The maximum number of times a promo code may be used by a single customer. | promo_codes | Required Sometimes | - | Array | Array of products objects associated with the coupon profile. | promo_codes.*.code | Required Sometimes | - | String | The promo code between 1-30 symbols. Required if ‘promo_codes.*.id` is not provided, will be created a new one. | promo_codes.*.id | Required Sometimes | - | Integer | The promo code ID. Required if `promo_codes.*.code` is not provided | bogo | Required Sometimes | - | Object | The coupon discount object associated with coupon profile. Required if `type_id` is a `Product` and `minimum_quantity` is not provided. | bogo.buy | Required | - | Integer | Count of products to buy to use the BOGO. Will overwrite `minimum_quantity` | bogo.get | Required | - | Integer | Count of discounted products when the BOGO requirement is met. Will overwrite `maximum_quantity` description here
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/coupons_controller.rb', line 214 def create_coupon_profile(body, domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}coupons', 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(CreateProductCouponProfile.method(:from_hash)) .is_api_response(true)) .execute end |
#delete_coupon_profile(domain, v2_ext, coupon_id) ⇒ ApiResponse
Delete an existing coupon profile here
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/coupons_controller.rb', line 482 def delete_coupon_profile(domain, v2_ext, coupon_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}coupons/{coupon_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(coupon_id, key: 'coupon_id') .is_required(true) .should_encode(true)) .auth(Single.new('basic'))) .response(new_response_handler .is_response_void(true) .is_api_response(true)) .execute end |
#delete_order_coupon(domain, v2_ext) ⇒ ApiResponse
Remove the coupon from the next recurring order. #### **Conditions for Coupon Removal** To be eligible for coupon removal from the next recurring order, an order must meet the following conditions:
-
**Order Status**: The order must not be pending, deleted, or on hold.
-
**Recurring Status**: The order must be recurring-enabled, with a
non-empty recurring date.
-
**Coupon Status**: A coupon must be currently applied to the order.
If the provided order meets these criteria, the coupon can be removed for the next recurring order in the subscription.
-
Parameters:
- `{{order_id}}`: Replace this placeholder with the specific order ID
or use an applicable child order ID that has a coupon applied and is pending recurrence.
The coupon will be removed for the next recurring order in the subscription chain.
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/coupons_controller.rb', line 530 def delete_order_coupon(domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}orders/13539/coupon', 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_coupon_profile(domain, v2_ext, coupon_id) ⇒ ApiResponse
Fetch a single coupon profile **Response Data**\ Response parameters expected in coupon profile object contained within the ‘data` field object: | Field | Data Type | Description | ————————————— | ———— | ————————————– | | id | Integer | The coupon profile ID. | type_id | Integer | The coupon type ID. | name | String | The coupon profile name. | description | String | The coupon profile description. | use_count | Integer | The coupon profile usage count. | discount_amount discount_amt | Float | Coupon profile discount amount. | discount_percent discount_pct | Float | Coupon profile discount percentage. | minimum_purchase | Float | Coupon profile minimum purchase amount. | is_lifetime | Integer Flag | Specifies whether or not a coupon profile will be used throughout the life of a subscription. | product_id | Integer | The product ID. | variant_id | Integer | The variant ID. | minimum_quantity min_qty | Integer | Minimum purchase quantity required to activate coupon profile. If BOGO this is going to be the `buy` quantity. | maximum_quantity max_qty | Integer | Maximum purchase quantity to apply product coupon to. If BOGO this is going to be the `get` quantity. | is_bogo | Integer Flag | The coupon profile’s buy one get one status. | is_active | Integer Flag | The coupon profile active status. | created_at | Object | Object that contains data pertaining to the coupon profile’s creation. | created_at.date | String | The coupon profile creation timestamp. | created_at.timezone_type | String | The coupon profile timezone type ID. | created_at.timezone | String | The coupon profile creation timestamp timezone. | updated_at | Object | Object that contains data pertaining to the coupon profile’s last update timestamp. | updated_at.date | String | The coupon profile last updated timestamp. | updated_at.timezone_type | String | The coupon profile timezone type ID. | updated_at.timezone | String | The coupon profile last update timestamp timezone. | expires_at | Object | Object that contains data pertaining to the coupon profile’s expiration. | expires_at.date | String | The coupon profile expiration timestamp. | expires_at.timezone_type | String | The coupon profile timezone type ID. | expires_at.timezone | String | The coupon profile expiration timestamp timezone. | is_free_shipping | Integer Flag | Specifies whether or not a coupon profile will make the shipping to be free. | promo_code_count | Integer | The coupon profile promo codes count. | limits | Object | An object containing the coupon profile limits. | limits.total | Integer | The maximum number of times a coupon profile may be used globally by any customer. | limits.per_customer | Integer | The maximum number of times a coupon profile may be used by a single customer. | limits.per_code | Integer | The maximum number of times a promo code may be used globally by any customer. | limits.per_code_per_customer | Integer | The maximum number of times a promo code may be used by a single customer. | creator | Object | Object that contains data pertaining to the admin user that created the coupon profile. | creator.department_id | Integer | Department ID associated with the admin user. | creator.timezone | String | The admin user timezone. | creator.id | Integer | The admin user ID. | creator.is_active | Integer Flag | The admin user active status. | creator.name | String | The admin user name. | creator.email | String | The admin user email. | creator.call_center_provider_id | Integer | The call center provider ID associated with the admin user. | updator | Object | Object that contains data pertaining to the admin user that last updated the coupon profile. | updator.department_id | Integer | Department ID associated with the admin user. | updator.timezone | String | The admin user timezone. | updator.id | Integer | The admin user ID. | updator.is_active | Integer Flag | The admin user active status. | updator.name | String | The admin user name. | updator.email | String | The admin user email. | updator.call_center_provider_id | Integer | The call center provider ID associated with the admin user | products | Array | Array of products objects associated with the coupon profile. | products.*.id | Integer | The product’s list ID. | products.*.coupon_id | Integer | The coupon ID. | products.*.product_id | Integer | The product ID. | products.*.variant_id | Integer | The variant ID. | promo_codes | Array | Array of products objects associated with the coupon profile. | promo_codes.*.id | Integer | The promo code ID. | promo_codes.*.use_count | Integer | The promo code usage count. | promo_codes.*.code | String | The promo code. | promo_codes.*.is_active | Integer Flag | The promo code active status. | promo_codes.*.is_deleted | Integer Flag | The promo code deleted status. | promo_codes.*.created_at | Object | Object that contains data pertaining to the promo code’s creation. | promo_codes.*.created_at.date | String | The promo code creation timestamp. | promo_codes.*.created_at.timezone_type | String | The promo code timezone type ID. | promo_codes.*.created_at.timezone | String | The promo code creation timestamp timezone. | promo_codes.*.created_by | Integer | The user ID that created the promo code. here
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/coupons_controller.rb', line 348 def get_coupon_profile(domain, v2_ext, coupon_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}coupons/{coupon_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(coupon_id, key: 'coupon_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(GetCouponProfile.method(:from_hash)) .is_api_response(true)) .execute end |
#get_coupon_profiles(domain, v2_ext) ⇒ ApiResponse
Fetch a list of all coupon profiles **Response Data** Response parameters expected in coupon profile object contained within the ‘data` field array: | Field | Data Type | Description | | — | — | — | | id | Integer | The coupon profile ID. | | type_id | Integer | The coupon type ID. | | name | String | The coupon profile name. | | description | String | The coupon profile description. | | use_count | Integer | The coupon profile usage count. | | discount_amount discount_amt | Float | Coupon profile discount amount. | | discount_percent discount_pct | Float | Coupon profile discount percentage. | | minimum_purchase | Float | Coupon profile minimum purchase amount. | | is_lifetime | Integer Flag | Specifies whether or not a coupon profile will be used throughout the life of a subscription. | | product_id | Integer | The product ID. | | variant_id | Integer | The variant ID. | | minimum_quantity min_qty | Integer | Minimum purchase quantity required to activate coupon profile. If BOGO this is going to be the `buy` quantity. | | maximum_quantity max_qty | Integer | Maximum purchase quantity to apply product coupon to. If BOGO this is going to be the `get` quantity. | | is_bogo | Integer Flag | The coupon profile’s buy one get one status. | | is_active | Integer Flag | The coupon profile active status. | | created_at | Object | Object that contains data pertaining to the coupon profile’s creation. | | created_at.date | String | The coupon profile creation timestamp. | | created_at.timezone_type | String | The coupon profile timezone type ID. | | created_at.timezone | String | The coupon profile creation timestamp timezone. | | updated_at | Object | Object that contains data pertaining to the coupon profile’s last update timestamp. | | updated_at.date | String | The coupon profile last updated timestamp. | | updated_at.timezone_type | String | The coupon profile timezone type ID. | | updated_at.timezone | String | The coupon profile last update timestamp timezone. | | expires_at | Object | Object that contains data pertaining to the coupon profile’s expiration. | | expires_at.date | String | The coupon profile expiration timestamp. | | expires_at.timezone_type | String | The coupon profile timezone type ID. | | expires_at.timezone | String | The coupon profile expiration timestamp timezone. | | is_free_shipping | Integer Flag | Specifies whether or not a coupon profile will make the shipping to be free. | | promo_code_count | Integer | The coupon profile promo codes count. | | limits | Object | An object containing the coupon profile limits. | | limits.total | Integer | The maximum number of times a coupon profile may be used globally by any customer. | | limits.per_customer | Integer | The maximum number of times a coupon profile may be used by a single customer. | | limits.per_code | Integer | The maximum number of times a promo code may be used globally by any customer. | | limits.per_code_per_customer | Integer | The maximum number of times a promo code may be used by a single customer. | | creator | Object | Object that contains data pertaining to the admin user that created the coupon profile. | | creator.department_id | Integer | Department ID associated with the admin user. | | creator.timezone | String | The admin user timezone. | | creator.id | Integer | The admin user ID. | | creator.is_active | Integer Flag | The admin user active status. | | creator.name | String | The admin user name. | | creator.email | String | The admin user email. | | creator.call_center_provider_id | Integer | The call center provider ID associated with the admin user. | | updator | Object | Object that contains data pertaining to the admin user that last updated the coupon profile. | | updator.department_id | Integer | Department ID associated with the admin user. | | updator.timezone | String | The admin user timezone. | | updator.id | Integer | The admin user ID. | | updator.is_active | Integer Flag | The admin user active status. | | updator.name | String | The admin user name. | | updator.email | String | The admin user email. | | updator.call_center_provider_id | Integer | The call center provider ID associated with the admin user | | products | Array | Array of products objects associated with the coupon profile. | | products.*.id | Integer | The product’s list ID. | | products.*.coupon_id | Integer | The coupon ID. | | products.*.product_id | Integer | The product ID. | | products.*.variant_id | Integer | The variant ID. | | promo_codes | Array | Array of promo_codes objects associated with the coupon profile. | | promo_codes.*.id | Integer | The promo code ID. | | promo_codes.*.use_count | Integer | The promo code usage count. | | promo_codes.*.code | String | The promo code. | | promo_codes.*.is_active | Integer Flag | The promo code active status. | | promo_codes.*.is_deleted | Integer Flag | The promo code deleted status. | | promo_codes.*.created_at | Object | Object that contains data pertaining to the promo code’s creation. | | promo_codes.*.created_at.date | String | The promo code creation timestamp. | | promo_codes.*.created_at.timezone_type | String | The promo code timezone type ID. | | promo_codes.*.created_at.timezone | String | The promo code creation timestamp timezone. | | promo_codes.*.created_by | Integer | The user ID that created the promo code. |
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/coupons_controller.rb', line 118 def get_coupon_profiles(domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}coupons', 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 |
#update_coupon_profile(domain, v2_ext, coupon_id) ⇒ ApiResponse
Update an existing coupon profile. For the ‘promo_codes` array, you make either pass an id of an existing promo code or you can pass the `code` and a new promo code will be generated. For meta data like `type_id` and the like, see the Coupon Meta folder. For payload examples, see the Create Coupon Profile method **Request Data** Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | | — | — | — | — | — | | name | Optional | - | String | The coupon profile name between 1-30 symbols. | | description | Optional | - | String | The coupon profile description 1-255 symbols. | | type_id | Optional | - | Integer | The coupon type ID. | | discount | Optional | - | Object | The coupon discount object associated with coupon profile. | | discount.type_id | Optional | - | Integer | The coupon discount type ID. | | discount.amount | Optional | - | Float | The coupon discount amount. | | discount.percent | Optional | - | Integer | The coupon discount percent between 1-100. | | discount.behavior_type_id | Optional | - | Integer | The coupon discount behavior type ID. | | minimum_purchase | Optional | - | Float | Coupon profile minimum purchase amount. | | product_id | Optional | null | Integer | Coupon profile product ID. | | variant_id | Optional | null | Integer | Coupon profile variant ID. | | products | Optional | - | Array | Array of products objects associated with the coupon profile. | | products.*.product_id | Required | - | Integer | The product ID. | | products.*.variant_id | Required | - | Integer | The variant ID. | | minimum_quantity | Optional | 0 | Integer | Minimum purchase quantity required to activate coupon profile minimum 1. | | maximum_quantity | Optional | 0 | Integer | Maximum purchase quantity to apply product coupon to minimum 1. | | is_lifetime | Optional | 0 | Integer Flag | Specifies whether or not a coupon profile will be used throughout the life of a subscription. | | is_free_shipping | Optional | 0 | Integer Flag | Specifies whether or not a coupon profile will make the shipping to be free. | | expiration | Optional | - | Object | Object that contains data pertaining to the coupon profile’s expiration. | | expiration.date | Required | - | date | The coupon profile expiration date YYYY-MM-DD format. | | expiration.timezone | Required | - | String | The coupon profile expiration valid timezone name. | | limits | Optional | - | Object | An object containing the coupon profile limits. | | limits.total | Required | - | Integer | The maximum number of times a coupon profile may be used globally by any customer. | | limits.per_customer | Required | - | Integer | The maximum number of times a coupon profile may be used by a single customer. | | limits.per_code | Required | - | Integer | The maximum number of times a promo code may be used globally by any customer. | | limits.per_code_per_customer | Required | - | Integer | The maximum number of times a promo code may be used by a single customer. | | add_promocodes | optional | | boolean (0,1) | 0 means we will remove old promocodes and 1 means we will not remove old promo codes and add the new ones. If we will not passing this parameter then it will simply go with default behaviour and replace old promocodes with new ones. And this will only work if we have promocodes array ofcourse. | | promo_codes | Optional | - | Array | Array of products objects associated with the coupon profile. | | promo_codes.*.code | Required Sometimes | - | String | The promo code between 1-30 symbols. Required if ‘promo_codes.\*.id` is not provided, will be created a new one. | | promo_codes.*.id | Required Sometimes | - | Integer | The promo code ID. Required if `promo_codes.\*.code` is not provided | | bogo | Optional | - | Object | The coupon discount object associated with coupon profile. | | bogo.buy | Required | - | Integer | Count of products to buy to use the BOGO. Will overwrite `minimum_quantity` | | bogo.get | Required | - | Integer | Count of discounted products when the BOGO requirement is met. Will overwrite `maximum_quantity` | here
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/coupons_controller.rb', line 452 def update_coupon_profile(domain, v2_ext, coupon_id) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/.{domain}{v2_ext}coupons/{coupon_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(coupon_id, key: 'coupon_id') .is_required(true) .should_encode(true)) .auth(Single.new('basic'))) .response(new_response_handler .is_response_void(true) .is_api_response(true)) .execute end |