Class: Devdraft::ProductsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/devdraft/api/products_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ ProductsApi

Returns a new instance of ProductsApi.



19
20
21
# File 'lib/devdraft/api/products_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/devdraft/api/products_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#product_controller_create(name, description, price, opts = {}) ⇒ nil

Create a new product Creates a new product with optional image uploads. This endpoint allows you to create products with detailed information and multiple images. ## Use Cases - Add new products to your catalog - Create products with multiple images - Set up product pricing and descriptions ## Supported Image Formats - JPEG/JPG - PNG - WebP - Maximum 10 images per product - Maximum file size: 5MB per image ## Example Request (multipart/form-data) “‘ name: "Premium Widget" description: "High-quality widget for all your needs" price: "99.99" images: [file1.jpg, file2.jpg] // Optional, up to 10 images “` ## Required Fields - `name`: Product name - `price`: Product price (decimal number) ## Optional Fields - `description`: Detailed product description - `images`: Product images (up to 10 files)

Parameters:

  • name (String)

    Product name as it will appear to customers. Should be clear and descriptive.

  • description (String)

    Detailed description of the product. Supports markdown formatting for rich text display.

  • price (Float)

    Product price in the specified currency. Must be greater than 0.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :currency (String)

    Currency code for the price. Defaults to USD if not specified. (default to ‘USD’)

  • :type (String)

    Product type

  • :weight (Float)

    Weight of the product

  • :unit (String)

    Unit of measurement

  • :quantity (Float)

    Quantity available

  • :stock_count (Float)

    Stock count

  • :status (String)

    Product status

  • :product_type (String)

    Product type

  • :images (Array<String>)

    Array of image URLs

Returns:

  • (nil)


38
39
40
41
# File 'lib/devdraft/api/products_api.rb', line 38

def product_controller_create(name, description, price, opts = {})
  product_controller_create_with_http_info(name, description, price, opts)
  nil
end

#product_controller_create_with_http_info(name, description, price, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Create a new product Creates a new product with optional image uploads. This endpoint allows you to create products with detailed information and multiple images. ## Use Cases - Add new products to your catalog - Create products with multiple images - Set up product pricing and descriptions ## Supported Image Formats - JPEG/JPG - PNG - WebP - Maximum 10 images per product - Maximum file size: 5MB per image ## Example Request (multipart/form-data) &#x60;&#x60;&#x60; name: &quot;Premium Widget&quot; description: &quot;High-quality widget for all your needs&quot; price: &quot;99.99&quot; images: [file1.jpg, file2.jpg] // Optional, up to 10 images &#x60;&#x60;&#x60; ## Required Fields - &#x60;name&#x60;: Product name - &#x60;price&#x60;: Product price (decimal number) ## Optional Fields - &#x60;description&#x60;: Detailed product description - &#x60;images&#x60;: Product images (up to 10 files)

Parameters:

  • name (String)

    Product name as it will appear to customers. Should be clear and descriptive.

  • description (String)

    Detailed description of the product. Supports markdown formatting for rich text display.

  • price (Float)

    Product price in the specified currency. Must be greater than 0.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :currency (String)

    Currency code for the price. Defaults to USD if not specified. (default to ‘USD’)

  • :type (String)

    Product type

  • :weight (Float)

    Weight of the product

  • :unit (String)

    Unit of measurement

  • :quantity (Float)

    Quantity available

  • :stock_count (Float)

    Stock count

  • :status (String)

    Product status

  • :product_type (String)

    Product type

  • :images (Array<String>)

    Array of image URLs

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/devdraft/api/products_api.rb', line 59

def product_controller_create_with_http_info(name, description, price, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ProductsApi.product_controller_create ...'
  end
  # verify the required parameter 'name' is set
  if @api_client.config.client_side_validation && name.nil?
    fail ArgumentError, "Missing the required parameter 'name' when calling ProductsApi.product_controller_create"
  end
  if @api_client.config.client_side_validation && name.to_s.length > 200
    fail ArgumentError, 'invalid value for "name" when calling ProductsApi.product_controller_create, the character length must be smaller than or equal to 200.'
  end

  if @api_client.config.client_side_validation && name.to_s.length < 1
    fail ArgumentError, 'invalid value for "name" when calling ProductsApi.product_controller_create, the character length must be greater than or equal to 1.'
  end

  # verify the required parameter 'description' is set
  if @api_client.config.client_side_validation && description.nil?
    fail ArgumentError, "Missing the required parameter 'description' when calling ProductsApi.product_controller_create"
  end
  if @api_client.config.client_side_validation && description.to_s.length > 2000
    fail ArgumentError, 'invalid value for "description" when calling ProductsApi.product_controller_create, the character length must be smaller than or equal to 2000.'
  end

  # verify the required parameter 'price' is set
  if @api_client.config.client_side_validation && price.nil?
    fail ArgumentError, "Missing the required parameter 'price' when calling ProductsApi.product_controller_create"
  end
  if @api_client.config.client_side_validation && price < 0.01
    fail ArgumentError, 'invalid value for "price" when calling ProductsApi.product_controller_create, must be greater than or equal to 0.01.'
  end

  allowable_values = ["USD", "EUR", "GBP", "CAD", "AUD", "JPY"]
  if @api_client.config.client_side_validation && opts[:'currency'] && !allowable_values.include?(opts[:'currency'])
    fail ArgumentError, "invalid value for \"currency\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/v0/products'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['name'] = name
  form_params['description'] = description
  form_params['price'] = price
  form_params['currency'] = opts[:'currency'] if !opts[:'currency'].nil?
  form_params['type'] = opts[:'type'] if !opts[:'type'].nil?
  form_params['weight'] = opts[:'weight'] if !opts[:'weight'].nil?
  form_params['unit'] = opts[:'unit'] if !opts[:'unit'].nil?
  form_params['quantity'] = opts[:'quantity'] if !opts[:'quantity'].nil?
  form_params['stockCount'] = opts[:'stock_count'] if !opts[:'stock_count'].nil?
  form_params['status'] = opts[:'status'] if !opts[:'status'].nil?
  form_params['productType'] = opts[:'product_type'] if !opts[:'product_type'].nil?
  form_params['images'] = @api_client.build_collection_param(opts[:'images'], :csv) if !opts[:'images'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['x-client-secret', 'x-client-key']

  new_options = opts.merge(
    :operation => :"ProductsApi.product_controller_create",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ProductsApi#product_controller_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#product_controller_find_all(opts = {}) ⇒ nil

Get all products Retrieves a list of products with pagination. This endpoint allows you to fetch products with optional pagination. ## Use Cases - List all products - Browse product catalog - Implement product search ## Query Parameters - ‘skip`: Number of records to skip (default: 0) - `take`: Number of records to take (default: 10) ## Example Response “`json { "data": [ { "id": "prod_123456", "name": "Premium Widget", "description": "High-quality widget for all your needs", "price": "99.99", "images": [ "", "" ], "createdAt": "2024-03-20T10:00:00Z" } ], "total": 100, "skip": 0, "take": 10 } “`

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :skip (Float)

    Number of records to skip

  • :take (Float)

    Number of records to take

Returns:

  • (nil)


156
157
158
159
# File 'lib/devdraft/api/products_api.rb', line 156

def product_controller_find_all(opts = {})
  product_controller_find_all_with_http_info(opts)
  nil
end

#product_controller_find_all_with_http_info(opts = {}) ⇒ Array<(nil, Integer, Hash)>

Get all products Retrieves a list of products with pagination. This endpoint allows you to fetch products with optional pagination. ## Use Cases - List all products - Browse product catalog - Implement product search ## Query Parameters - &#x60;skip&#x60;: Number of records to skip (default: 0) - &#x60;take&#x60;: Number of records to take (default: 10) ## Example Response &#x60;&#x60;&#x60;json { &quot;data&quot;: [ { &quot;id&quot;: &quot;prod_123456&quot;, &quot;name&quot;: &quot;Premium Widget&quot;, &quot;description&quot;: &quot;High-quality widget for all your needs&quot;, &quot;price&quot;: &quot;99.99&quot;, &quot;images&quot;: [ &quot;&quot;, &quot;&quot; ], &quot;createdAt&quot;: &quot;2024-03-20T10:00:00Z&quot; } ], &quot;total&quot;: 100, &quot;skip&quot;: 0, &quot;take&quot;: 10 } &#x60;&#x60;&#x60;

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :skip (Float)

    Number of records to skip

  • :take (Float)

    Number of records to take

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/devdraft/api/products_api.rb', line 167

def product_controller_find_all_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ProductsApi.product_controller_find_all ...'
  end
  # resource path
  local_var_path = '/api/v0/products'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'skip'] = opts[:'skip'] if !opts[:'skip'].nil?
  query_params[:'take'] = opts[:'take'] if !opts[:'take'].nil?

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['x-client-secret', 'x-client-key']

  new_options = opts.merge(
    :operation => :"ProductsApi.product_controller_find_all",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ProductsApi#product_controller_find_all\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#product_controller_find_one(id, opts = {}) ⇒ nil

Get a product by ID Retrieves detailed information about a specific product. This endpoint allows you to fetch complete product details including all images. ## Use Cases - View product details - Display product information - Check product availability ## Example Response “‘json { "id": "prod_123456", "name": "Premium Widget", "description": "High-quality widget for all your needs", "price": "99.99", "images": [ "", "" ], "createdAt": "2024-03-20T10:00:00Z", "updatedAt": "2024-03-20T10:00:00Z" } “`

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


216
217
218
219
# File 'lib/devdraft/api/products_api.rb', line 216

def product_controller_find_one(id, opts = {})
  product_controller_find_one_with_http_info(id, opts)
  nil
end

#product_controller_find_one_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Get a product by ID Retrieves detailed information about a specific product. This endpoint allows you to fetch complete product details including all images. ## Use Cases - View product details - Display product information - Check product availability ## Example Response &#x60;&#x60;&#x60;json { &quot;id&quot;: &quot;prod_123456&quot;, &quot;name&quot;: &quot;Premium Widget&quot;, &quot;description&quot;: &quot;High-quality widget for all your needs&quot;, &quot;price&quot;: &quot;99.99&quot;, &quot;images&quot;: [ &quot;&quot;, &quot;&quot; ], &quot;createdAt&quot;: &quot;2024-03-20T10:00:00Z&quot;, &quot;updatedAt&quot;: &quot;2024-03-20T10:00:00Z&quot; } &#x60;&#x60;&#x60;

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/devdraft/api/products_api.rb', line 226

def product_controller_find_one_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ProductsApi.product_controller_find_one ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.product_controller_find_one"
  end
  # resource path
  local_var_path = '/api/v0/products/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['x-client-secret', 'x-client-key']

  new_options = opts.merge(
    :operation => :"ProductsApi.product_controller_find_one",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ProductsApi#product_controller_find_one\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#product_controller_remove(id, opts = {}) ⇒ nil

Delete a product Deletes a product and its associated images. This endpoint allows you to remove a product and all its associated data. ## Use Cases - Remove discontinued products - Clean up product catalog - Delete test products ## Notes - This action cannot be undone - All product images will be deleted - Associated data will be removed

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


277
278
279
280
# File 'lib/devdraft/api/products_api.rb', line 277

def product_controller_remove(id, opts = {})
  product_controller_remove_with_http_info(id, opts)
  nil
end

#product_controller_remove_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete a product Deletes a product and its associated images. This endpoint allows you to remove a product and all its associated data. ## Use Cases - Remove discontinued products - Clean up product catalog - Delete test products ## Notes - This action cannot be undone - All product images will be deleted - Associated data will be removed

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



287
288
289
290
291
292
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
322
323
324
325
326
327
328
329
330
331
# File 'lib/devdraft/api/products_api.rb', line 287

def product_controller_remove_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ProductsApi.product_controller_remove ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.product_controller_remove"
  end
  # resource path
  local_var_path = '/api/v0/products/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['x-client-secret', 'x-client-key']

  new_options = opts.merge(
    :operation => :"ProductsApi.product_controller_remove",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ProductsApi#product_controller_remove\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#product_controller_update(id, opts = {}) ⇒ nil

Update a product Updates an existing product’s information and optionally adds new images. This endpoint allows you to modify product details and manage product images. ## Use Cases - Update product information - Change product pricing - Modify product images - Update product description ## Example Request (multipart/form-data) “‘ name: "Updated Premium Widget" description: "Updated description" price: "129.99" images: [file1.jpg, file2.jpg] // Optional, up to 10 images “` ## Notes - Only include fields that need to be updated - New images will replace existing images - Maximum 10 images per product - Images are automatically optimized

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :name (String)

    Product name as it will appear to customers. Should be clear and descriptive.

  • :description (String)

    Detailed description of the product. Supports markdown formatting for rich text display.

  • :price (Float)

    Product price in the specified currency. Must be greater than 0.

  • :currency (String)

    Currency code for the price. Defaults to USD if not specified. (default to ‘USD’)

  • :type (String)

    Product type

  • :weight (Float)

    Weight of the product

  • :unit (String)

    Unit of measurement

  • :quantity (Float)

    Quantity available

  • :stock_count (Float)

    Stock count

  • :status (String)

    Product status

  • :product_type (String)

    Product type

  • :images (Array<String>)

    Array of image URLs

Returns:

  • (nil)


350
351
352
353
# File 'lib/devdraft/api/products_api.rb', line 350

def product_controller_update(id, opts = {})
  product_controller_update_with_http_info(id, opts)
  nil
end

#product_controller_update_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Update a product Updates an existing product&#39;s information and optionally adds new images. This endpoint allows you to modify product details and manage product images. ## Use Cases - Update product information - Change product pricing - Modify product images - Update product description ## Example Request (multipart/form-data) &#x60;&#x60;&#x60; name: &quot;Updated Premium Widget&quot; description: &quot;Updated description&quot; price: &quot;129.99&quot; images: [file1.jpg, file2.jpg] // Optional, up to 10 images &#x60;&#x60;&#x60; ## Notes - Only include fields that need to be updated - New images will replace existing images - Maximum 10 images per product - Images are automatically optimized

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :name (String)

    Product name as it will appear to customers. Should be clear and descriptive.

  • :description (String)

    Detailed description of the product. Supports markdown formatting for rich text display.

  • :price (Float)

    Product price in the specified currency. Must be greater than 0.

  • :currency (String)

    Currency code for the price. Defaults to USD if not specified. (default to ‘USD’)

  • :type (String)

    Product type

  • :weight (Float)

    Weight of the product

  • :unit (String)

    Unit of measurement

  • :quantity (Float)

    Quantity available

  • :stock_count (Float)

    Stock count

  • :status (String)

    Product status

  • :product_type (String)

    Product type

  • :images (Array<String>)

    Array of image URLs

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/devdraft/api/products_api.rb', line 372

def product_controller_update_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ProductsApi.product_controller_update ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.product_controller_update"
  end
  if @api_client.config.client_side_validation && !opts[:'name'].nil? && opts[:'name'].to_s.length > 200
    fail ArgumentError, 'invalid value for "opts[:"name"]" when calling ProductsApi.product_controller_update, the character length must be smaller than or equal to 200.'
  end

  if @api_client.config.client_side_validation && !opts[:'name'].nil? && opts[:'name'].to_s.length < 1
    fail ArgumentError, 'invalid value for "opts[:"name"]" when calling ProductsApi.product_controller_update, the character length must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'description'].nil? && opts[:'description'].to_s.length > 2000
    fail ArgumentError, 'invalid value for "opts[:"description"]" when calling ProductsApi.product_controller_update, the character length must be smaller than or equal to 2000.'
  end

  if @api_client.config.client_side_validation && !opts[:'price'].nil? && opts[:'price'] < 0.01
    fail ArgumentError, 'invalid value for "opts[:"price"]" when calling ProductsApi.product_controller_update, must be greater than or equal to 0.01.'
  end

  allowable_values = ["USD", "EUR", "GBP", "CAD", "AUD", "JPY"]
  if @api_client.config.client_side_validation && opts[:'currency'] && !allowable_values.include?(opts[:'currency'])
    fail ArgumentError, "invalid value for \"currency\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/v0/products/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['multipart/form-data'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['description'] = opts[:'description'] if !opts[:'description'].nil?
  form_params['price'] = opts[:'price'] if !opts[:'price'].nil?
  form_params['currency'] = opts[:'currency'] if !opts[:'currency'].nil?
  form_params['type'] = opts[:'type'] if !opts[:'type'].nil?
  form_params['weight'] = opts[:'weight'] if !opts[:'weight'].nil?
  form_params['unit'] = opts[:'unit'] if !opts[:'unit'].nil?
  form_params['quantity'] = opts[:'quantity'] if !opts[:'quantity'].nil?
  form_params['stockCount'] = opts[:'stock_count'] if !opts[:'stock_count'].nil?
  form_params['status'] = opts[:'status'] if !opts[:'status'].nil?
  form_params['productType'] = opts[:'product_type'] if !opts[:'product_type'].nil?
  form_params['images'] = @api_client.build_collection_param(opts[:'images'], :csv) if !opts[:'images'].nil?

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['x-client-secret', 'x-client-key']

  new_options = opts.merge(
    :operation => :"ProductsApi.product_controller_update",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ProductsApi#product_controller_update\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#product_controller_upload_image(id, opts = {}) ⇒ nil

Upload images for a product Adds new images to an existing product. This endpoint allows you to upload additional images for a product that already exists. ## Use Cases - Add more product images - Update product gallery - Enhance product presentation ## Supported Image Formats - JPEG/JPG - PNG - WebP - Maximum 10 images per upload - Maximum file size: 5MB per image ## Example Request (multipart/form-data) “‘ images: [file1.jpg, file2.jpg] // Up to 10 images “` ## Notes - Images are appended to existing product images - Total images per product cannot exceed 10 - Images are automatically optimized and resized

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (nil)


460
461
462
463
# File 'lib/devdraft/api/products_api.rb', line 460

def product_controller_upload_image(id, opts = {})
  product_controller_upload_image_with_http_info(id, opts)
  nil
end

#product_controller_upload_image_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Upload images for a product Adds new images to an existing product. This endpoint allows you to upload additional images for a product that already exists. ## Use Cases - Add more product images - Update product gallery - Enhance product presentation ## Supported Image Formats - JPEG/JPG - PNG - WebP - Maximum 10 images per upload - Maximum file size: 5MB per image ## Example Request (multipart/form-data) &#x60;&#x60;&#x60; images: [file1.jpg, file2.jpg] // Up to 10 images &#x60;&#x60;&#x60; ## Notes - Images are appended to existing product images - Total images per product cannot exceed 10 - Images are automatically optimized and resized

Parameters:

  • id (String)

    Product ID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(nil, Integer, Hash)>)

    nil, response status code and response headers



470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# File 'lib/devdraft/api/products_api.rb', line 470

def product_controller_upload_image_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ProductsApi.product_controller_upload_image ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling ProductsApi.product_controller_upload_image"
  end
  # resource path
  local_var_path = '/api/v0/products/{id}/images'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['x-client-secret', 'x-client-key']

  new_options = opts.merge(
    :operation => :"ProductsApi.product_controller_upload_image",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ProductsApi#product_controller_upload_image\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end