Class: StickyIoRestfulApiV2025731::VariantsController
- Inherits:
-
BaseController
- Object
- BaseController
- StickyIoRestfulApiV2025731::VariantsController
- Defined in:
- lib/sticky_io_restful_api_v2025731/controllers/variants_controller.rb
Overview
VariantsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#add_product_variant(body, domain, v2_ext, product_id) ⇒ ApiResponse
Add a new product variant.
-
#delete_product_variant(domain, v2_ext, product_id, variant_id) ⇒ ApiResponse
Delete a product variant.
-
#get_product_variants(domain, v2_ext, product_id) ⇒ ApiResponse
Fetch a list of product variants associated with a single product.
-
#update_product_variant(body, domain, v2_ext, product_id, variant_id) ⇒ ApiResponse
Update an existing product variant.
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
#add_product_variant(body, domain, v2_ext, product_id) ⇒ ApiResponse
Add a new product variant. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | | ———————————— | ———– | ——- | ——— | ————————————- | | variants | Required | - | Array | An array of variant objects. | | variants.*.price | Optional | - | Numeric | The new variant price. | | variants.*.quantity | Optional | - | Integer | The new variant max quantity. | | variants.*.weight | Optional | - | Numeric | The new variant weight. | | variants.*.sku_num | Required | - | String | The updated product variant sku. | | variants.*.attributes | Required | - | Array | An array of attribute objects. | | variants.*.attributes | Required | - | Array | An array of product attribute objects. | | variants.*.attributes.*.id | Required | - | Integer | The attribute ID. | | variants.*.attributes.*.options | Required | - | Object | An option object. | | variants.*.attributes.*.options.id | Required | - | Integer | The option ID. | **Response Data**\ Response parameters contained within the ‘data` field object: | Field | Data Type | Description
|
| ———————————– | ——— | ———————————————————— | | id | Integer | The variant ID.
|
| price | Numeric | The variant price. Will be ‘null` if it inherits the product price. | | quantity | Integer | The max quantity of the product variant. Will be `null` if it inherits the product max quantity. | | weight | Numeric | The weight of the product variant. | | sku_num | String | The variant SKU identifier. | | attributes | Array | An array of product variant attribute objects. | | attributes.*.id | Integer | The attribute ID. | | attributes.*.attribute | Object | The product variant attribute object. | | attributes.*.attribute.id | Integer | The attribute-option ID. | | attributes.*.attribute.name | String | The attribute name. | | attributes.*.attribute.option | Object | The attribute option object. | | attributes.*.attribute.option.id | Integer | The attribute option ID. | | attributes.*.attribute.option.name | String | The attribute option name. | description here here
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/variants_controller.rb', line 224 def add_product_variant(body, domain, v2_ext, product_id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}products/{product_id}/variants', 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(product_id, key: 'product_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(AddProductVariant.method(:from_hash)) .is_api_response(true)) .execute end |
#delete_product_variant(domain, v2_ext, product_id, variant_id) ⇒ ApiResponse
Delete a product variant. **Response Data**\ Response parameters contained within the ‘data` field object: | Field | Data Type | Description
|
| ———————————– | ——— | ———————————————————— | | id | Integer | The variant ID.
|
| price | Numeric | The variant price. Will be ‘null` if it inherits the product price. | | quantity | Integer | The max quantity of the product variant. Will be `null` if it inherits the product max quantity. | | weight | Numeric | The weight of the product variant. | | sku_num | String | The variant SKU identifier. | | attributes | Array | An array of product variant attribute objects. | | attributes.*.id | Integer | The attribute ID. | | attributes.*.attribute | Object | The product variant attribute object. | | attributes.*.attribute.id | Integer | The attribute-option ID. | | attributes.*.attribute.name | String | The attribute name. | | attributes.*.attribute.option | Object | The attribute option object. | | attributes.*.attribute.option.id | Integer | The attribute option ID. | | attributes.*.attribute.option.name | String | The attribute option name. | here here
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/variants_controller.rb', line 293 def delete_product_variant(domain, v2_ext, product_id, variant_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}products/{product_id}/variants/{variant_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(product_id, key: 'product_id') .is_required(true) .should_encode(true)) .template_param(new_parameter(variant_id, key: 'variant_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(DeleteProductVariant.method(:from_hash)) .is_api_response(true)) .execute end |
#get_product_variants(domain, v2_ext, product_id) ⇒ ApiResponse
Fetch a list of product variants associated with a single product. **Response Data**\ Response parameters contained within the ‘data` field array: | Field | Data Type | Description
|
| ———————————– | ——— | ———————————————————— | | id | Integer | The variant ID.
|
| price | Numeric | The variant price. Will be ‘null` if it inherits the product price. | | quantity | Integer | The max quantity of the product variant. Will be `null` if it inherits the product max quantity. | | weight | Numeric | The weight of the product variant. | | sku_num | String | The variant SKU identifier. | | attributes | Array | An array of product variant attribute objects. | | attributes.*.id | Integer | The attribute ID. | | attributes.*.attribute | Object | The product variant attribute object. | | attributes.*.attribute.id | Integer | The attribute-option ID. | | attributes.*.attribute.name | String | The attribute name. | | attributes.*.attribute.option | Object | The attribute option object. | | attributes.*.attribute.option.id | Integer | The attribute option ID. | | attributes.*.attribute.option.name | String | The attribute option name. | here
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/variants_controller.rb', line 46 def get_product_variants(domain, v2_ext, product_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}products/{product_id}/variants', Server::SERVER_1) .header_param(new_parameter('application/x-www-form-urlencoded', 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(product_id, key: 'product_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(GetProductVariants.method(:from_hash)) .is_api_response(true)) .execute end |
#update_product_variant(body, domain, v2_ext, product_id, variant_id) ⇒ ApiResponse
Update an existing product variant. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description
|
| ——– | ———– | ——- | ——— | ————————————- | | price | Optional | - | Numeric | The new variant price. | | quantity | Optional | - | Integer | The new variant max quantity. | | weight | Optional | - | Numeric | The new variant weight. | | sku_num | Required | - | String | The updated product variant sku. | **Response Data**\ Response parameters contained within the ‘data` field object: | Field | Data Type | Description
|
| ———————————– | ——— | ———————————————————— | | id | Integer | The variant ID.
|
| price | Numeric | The variant price. Will be ‘null` if it inherits the product price. | | quantity | Integer | The max quantity of the product variant. Will be `null` if it inherits the product max quantity. | | weight | Numeric | The weight of the product variant. | | sku_num | String | The variant SKU identifier. | | attributes | Array | An array of product variant attribute objects. | | attributes.*.id | Integer | The attribute ID. | | attributes.*.attribute | Object | The product variant attribute object. | | attributes.*.attribute.id | Integer | The attribute-option ID. | | attributes.*.attribute.name | String | The attribute name. | | attributes.*.attribute.option | Object | The attribute option object. | | attributes.*.attribute.option.id | Integer | The attribute option ID. | | attributes.*.attribute.option.name | String | The attribute option name. | description here here here
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/variants_controller.rb', line 125 def update_product_variant(body, domain, v2_ext, product_id, variant_id) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/.{domain}{v2_ext}products/{product_id}/variants/{variant_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(product_id, key: 'product_id') .is_required(true) .should_encode(true)) .template_param(new_parameter(variant_id, key: 'variant_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(UpdateProductVariant.method(:from_hash)) .is_api_response(true)) .execute end |