Class: StickyIoRestfulApiV2025731::CategoriesController
- Inherits:
-
BaseController
- Object
- BaseController
- StickyIoRestfulApiV2025731::CategoriesController
- Defined in:
- lib/sticky_io_restful_api_v2025731/controllers/categories_controller.rb
Overview
CategoriesController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#add_category(body, domain, v2_ext) ⇒ ApiResponse
Add a product category.
-
#delete_category(domain, v2_ext, category_id) ⇒ ApiResponse
Delete a product category.
-
#get_categories(domain, v2_ext) ⇒ ApiResponse
Fetch a list of product categories.
-
#get_category(domain, v2_ext, category_id) ⇒ ApiResponse
Fetch a list of product categories.
-
#update_category(body, domain, v2_ext, category_id) ⇒ ApiResponse
Update an existing product category.
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_category(body, domain, v2_ext) ⇒ ApiResponse
Add a product category. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description
|
| ———– | ———– | ——- | ——— | ————————————– | | name | Required | - | String | The category name. | | description | Optional | - | String | The category description (maximum 1000 characters). | **Response Data**\ Response parameters contained within the ‘data` field object: | Field | Data Type | Description
|
| ————- | ——— | ————————————————– | | id | Integer | The category ID.
|
| name | String | The category name.
|
| description | String | The category description.
|
| product_count | Integer | The number of products associated to the category. | | created_by | String | User name that created the category.
|
| updated_by | String | User name that last updated the category.
|
description here
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/categories_controller.rb', line 42 def add_category(body, domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/.{domain}{v2_ext}categories', 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(AddCategory.method(:from_hash)) .is_api_response(true)) .execute end |
#delete_category(domain, v2_ext, category_id) ⇒ ApiResponse
Delete a product category. Note A category can not be deleted if products are attached. **Response Data**\ No data is returned. Look for a standard standard ‘SUCCESS` indicator in the `status` field. here
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/categories_controller.rb', line 192 def delete_category(domain, v2_ext, category_id) @api_call .request(new_request_builder(HttpMethodEnum::DELETE, '/.{domain}{v2_ext}categories/{category_id}', Server::SERVER_1) .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(category_id, key: 'category_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(DeleteCategory.method(:from_hash)) .is_api_response(true)) .execute end |
#get_categories(domain, v2_ext) ⇒ ApiResponse
Fetch a list of product categories. **Response Data**\ Response parameters contained within the ‘data` field array: | Field | Data Type | Description
|
| ————- | ——— | ————————————————– | | id | Integer | The category ID.
|
| name | String | The category name.
|
| description | String | The category description.
|
| product_count | Integer | The number of products associated to the category. | | created_by | String | User name that created the category.
|
| updated_by | String | User name that last updated the category.
|
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/categories_controller.rb', line 239 def get_categories(domain, v2_ext) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}categories', Server::SERVER_1) .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')) .auth(Single.new('basic'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(GetCategories.method(:from_hash)) .is_api_response(true)) .execute end |
#get_category(domain, v2_ext, category_id) ⇒ ApiResponse
Fetch a list of product categories. **Response Data**\ Response parameters contained within the ‘data` field array: | Field | Data Type | Description
|
| ————- | ——— | ————————————————– | | id | Integer | The category ID.
|
| name | String | The category name.
|
| description | String | The category description.
|
| product_count | Integer | The number of products associated to the category. | | created_by | String | User name that created the category.
|
| updated_by | String | User name that last updated the category.
|
here
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/categories_controller.rb', line 157 def get_category(domain, v2_ext, category_id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/.{domain}{v2_ext}categories/{category_id}', Server::SERVER_1) .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(category_id, key: 'category_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(GetCategory.method(:from_hash)) .is_api_response(true)) .execute end |
#update_category(body, domain, v2_ext, category_id) ⇒ ApiResponse
Update an existing product category. **Request Data**\ Request parameters expected during this API call: | Field | Requirement | Default | Data Type | Description
|
| ———– | ———– | ——- | ——— | ————————————– | | name | Required | - | String | The category name. | | description | Optional | - | String | The category description (maximum 1000 characters). | **Response Data**\ Response parameters contained within the ‘data` field object: | Field | Data Type | Description
|
| ————- | ——— | ————————————————– | | id | Integer | The category ID.
|
| name | String | The category name.
|
| description | String | The category description.
|
| product_count | Integer | The number of products associated to the category. | | created_by | String | User name that created the category.
|
| updated_by | String | User name that last updated the category.
|
description here here
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 128 129 130 131 |
# File 'lib/sticky_io_restful_api_v2025731/controllers/categories_controller.rb', line 103 def update_category(body, domain, v2_ext, category_id) @api_call .request(new_request_builder(HttpMethodEnum::PUT, '/.{domain}{v2_ext}categories/{category_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(category_id, key: 'category_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(UpdateCategory.method(:from_hash)) .is_api_response(true)) .execute end |