Class: StickyIoRestfulApiV2025731::AttributesController
- Inherits:
-
BaseController
- Object
- BaseController
- StickyIoRestfulApiV2025731::AttributesController
- Defined in:
- lib/sticky_io_restful_api_v2025731/controllers/attributes_controller.rb
Overview
AttributesController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#add_product_attributes(body, domain, v2_ext, product_id) ⇒ ApiResponse
Add one or more variant attributes to a product.
-
#delete_product_attributes(body, domain, v2_ext, product_id) ⇒ ApiResponse
Delete one or more variant attributes from a product.
-
#get_product_attributes(domain, v2_ext, product_id) ⇒ ApiResponse
Fetch a list of variant attributes from a product.
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_attributes(body, domain, v2_ext, product_id) ⇒ ApiResponse
Add one or more variant attributes to a product. NOTE: This method will update the attributes of the product to the set passed in the request. If you would like to keep your existent configuration of attributtes, these should be passed along in the request. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description | | ——————— | ———– | ——- | ———— | ————————————– | | attributes | Required | - | Array | An array of product attribute objects. | | attributes.*.name | Required | - | String | The attribute name. | | attributes.*.options | Required | - | Array | An array of attribute option names. | | auto_create_variants | Optional | - | Integer Flag | Flag that tells the system to automatically create variants from the list of options. | **Response Data**\ Response parameters contained within the ‘data` field array: | Field | Data Type | Description
|
| ————— | ——— | ——————————————— | | id | Integer | The created attribute ID.
|
| name | String | The variant attribute name.
|
| options | Array | An array of product attribute option objects. | | options.*.id | Integer | The option ID.
|
| options.*.name | String | The option name.
|
description here here
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/attributes_controller.rb', line 99 def add_product_attributes(body, domain, v2_ext, product_id) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}products/{product_id}/attributes', 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(AddProductAttributes.method(:from_hash)) .is_api_response(true)) .execute end |
#delete_product_attributes(body, domain, v2_ext, product_id) ⇒ ApiResponse
Delete one or more variant attributes from a product. NOTE: If ‘ALL` is passed as a value all options and the attribute itself are going to get deleted. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description
|
| ——————— | ———– | ——- | ——— | ————————————– | | attributes | Required | - | Array | An array of product attribute objects. | | attributes.*.options | Required | - | Array | An array of attribute option names. Can pass ‘ALL` as an array value to delete all options under this attribute. | **Response Data**\ No data is returned. Look for a standard standard `SUCCESS` indicator in the `status` field. here
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/attributes_controller.rb', line 152 def delete_product_attributes(body, domain, v2_ext, product_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}products/{product_id}/attributes', 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')) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(DeleteProductAttributes.method(:from_hash)) .is_api_response(true)) .execute end |
#get_product_attributes(domain, v2_ext, product_id) ⇒ ApiResponse
Fetch a list of variant attributes from a product. **Response Data**\ Response parameters contained within the ‘data` field array: | Field | Data Type | Description
|
| ————— | ——— | ——————————————— | | id | Integer | The created attribute ID.
|
| name | String | The variant attribute name.
|
| options | Array | An array of product attribute option objects. | | options.*.id | Integer | The option ID.
|
| options.*.name | String | The option name.
|
here
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/attributes_controller.rb', line 31 def get_product_attributes(domain, v2_ext, product_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}products/{product_id}/attributes', 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(GetProductAttributes.method(:from_hash)) .is_api_response(true)) .execute end |