tradenity 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +89 -77
  4. data/lib/tradenity/api_client.rb +408 -0
  5. data/lib/tradenity/api_error.rb +36 -0
  6. data/lib/tradenity/configuration.rb +205 -0
  7. data/lib/tradenity/exceptions.rb +5 -0
  8. data/lib/tradenity/rails/railtie.rb +20 -20
  9. data/lib/tradenity/resources/address.rb +729 -0
  10. data/lib/tradenity/resources/braintree_gateway.rb +804 -0
  11. data/lib/tradenity/resources/brand.rb +732 -0
  12. data/lib/tradenity/resources/cancel_operation.rb +675 -0
  13. data/lib/tradenity/resources/cart_settings.rb +219 -0
  14. data/lib/tradenity/resources/cash_on_delivery_payment.rb +746 -0
  15. data/lib/tradenity/resources/category.rb +763 -0
  16. data/lib/tradenity/resources/collection.rb +734 -0
  17. data/lib/tradenity/resources/contact_info.rb +306 -0
  18. data/lib/tradenity/resources/countries_geo_zone.rb +739 -0
  19. data/lib/tradenity/resources/country.rb +803 -0
  20. data/lib/tradenity/resources/coupon.rb +454 -0
  21. data/lib/tradenity/resources/credit_card_payment.rb +803 -0
  22. data/lib/tradenity/resources/currency.rb +762 -0
  23. data/lib/tradenity/resources/customer.rb +816 -0
  24. data/lib/tradenity/resources/customer_group.rb +723 -0
  25. data/lib/tradenity/resources/dimensions.rb +263 -0
  26. data/lib/tradenity/resources/discount_coupon.rb +811 -0
  27. data/lib/tradenity/resources/discount_promotion.rb +784 -0
  28. data/lib/tradenity/resources/fixed_rate_shipping.rb +837 -0
  29. data/lib/tradenity/resources/free_item_coupon.rb +793 -0
  30. data/lib/tradenity/resources/free_shipping.rb +806 -0
  31. data/lib/tradenity/resources/free_shipping_coupon.rb +788 -0
  32. data/lib/tradenity/resources/free_shipping_promotion.rb +744 -0
  33. data/lib/tradenity/resources/gateway.rb +435 -0
  34. data/lib/tradenity/resources/general_settings.rb +206 -0
  35. data/lib/tradenity/resources/geo_zone.rb +406 -0
  36. data/lib/tradenity/resources/instance_meta.rb +182 -0
  37. data/lib/tradenity/resources/inventory_settings.rb +197 -0
  38. data/lib/tradenity/resources/items_selector.rb +270 -0
  39. data/lib/tradenity/resources/line_item.rb +347 -0
  40. data/lib/tradenity/resources/mail_server_settings.rb +221 -0
  41. data/lib/tradenity/resources/measurement_settings.rb +253 -0
  42. data/lib/tradenity/resources/option.rb +787 -0
  43. data/lib/tradenity/resources/option_set.rb +734 -0
  44. data/lib/tradenity/resources/option_value.rb +680 -0
  45. data/lib/tradenity/resources/order.rb +929 -0
  46. data/lib/tradenity/resources/order_line_item.rb +777 -0
  47. data/lib/tradenity/resources/paging.rb +38 -0
  48. data/lib/tradenity/resources/payment.rb +429 -0
  49. data/lib/tradenity/resources/payment_card.rb +847 -0
  50. data/lib/tradenity/resources/payment_settings.rb +201 -0
  51. data/lib/tradenity/resources/payment_source.rb +392 -0
  52. data/lib/tradenity/resources/payment_token.rb +723 -0
  53. data/lib/tradenity/resources/payment_transaction.rb +740 -0
  54. data/lib/tradenity/resources/photo.rb +341 -0
  55. data/lib/tradenity/resources/product.rb +1156 -0
  56. data/lib/tradenity/resources/promotion.rb +427 -0
  57. data/lib/tradenity/resources/refund_operation.rb +358 -0
  58. data/lib/tradenity/resources/refund_transaction.rb +730 -0
  59. data/lib/tradenity/resources/return_line_item.rb +781 -0
  60. data/lib/tradenity/resources/return_operation.rb +686 -0
  61. data/lib/tradenity/resources/return_settings.rb +255 -0
  62. data/lib/tradenity/resources/shipping_method.rb +530 -0
  63. data/lib/tradenity/resources/shopping_cart.rb +647 -0
  64. data/lib/tradenity/resources/state.rb +675 -0
  65. data/lib/tradenity/resources/states_geo_zone.rb +748 -0
  66. data/lib/tradenity/resources/store_credit.rb +686 -0
  67. data/lib/tradenity/resources/store_credit_payment.rb +764 -0
  68. data/lib/tradenity/resources/store_credit_transaction.rb +730 -0
  69. data/lib/tradenity/resources/store_profile.rb +532 -0
  70. data/lib/tradenity/resources/stripe_gateway.rb +804 -0
  71. data/lib/tradenity/resources/table_rate_rule.rb +712 -0
  72. data/lib/tradenity/resources/table_rate_shipping.rb +834 -0
  73. data/lib/tradenity/resources/tax_class.rb +723 -0
  74. data/lib/tradenity/resources/tax_rate.rb +845 -0
  75. data/lib/tradenity/resources/tax_settings.rb +231 -0
  76. data/lib/tradenity/resources/test_gateway.rb +804 -0
  77. data/lib/tradenity/resources/transaction.rb +523 -0
  78. data/lib/tradenity/resources/utils.rb +7 -0
  79. data/lib/tradenity/resources/variant.rb +877 -0
  80. data/lib/tradenity/resources/web_hooks.rb +262 -0
  81. data/lib/tradenity/resources/weight.rb +235 -0
  82. data/lib/tradenity/resources/wish_list.rb +686 -0
  83. data/lib/tradenity/resources/zip_codes_geo_zone.rb +755 -0
  84. data/lib/tradenity/token_holder.rb +22 -0
  85. data/lib/tradenity/version.rb +13 -3
  86. data/lib/tradenity.rb +117 -7
  87. data/tradenity.gemspec +35 -30
  88. metadata +200 -34
  89. data/lib/tradenity/api.rb +0 -17
  90. data/lib/tradenity/error/exceptions.rb +0 -52
  91. data/lib/tradenity/error/message.rb +0 -38
  92. data/lib/tradenity/http/client.rb +0 -130
  93. data/lib/tradenity/model/base.rb +0 -100
  94. data/lib/tradenity/model/entities.rb +0 -390
  95. data/lib/tradenity/model/paging.rb +0 -23
@@ -0,0 +1,763 @@
1
+ =begin
2
+ #Tradenity API
3
+
4
+ #Tradenity eCommerce Rest API
5
+
6
+ Contact: support@tradenity.com
7
+ Generated by: https://github.com/tradenity
8
+
9
+ =end
10
+
11
+ require 'uri'
12
+
13
+ module Tradenity
14
+ class Category
15
+
16
+
17
+ def id=(id)
18
+ @id = id
19
+ end
20
+
21
+ def id
22
+ if instance_variable_defined?('@id') && @id != nil
23
+ @id
24
+ elsif __meta && __meta.href != nil
25
+ @id = __meta.href.split('/')[-1]
26
+ @id
27
+ else
28
+ nil
29
+ end
30
+ end
31
+
32
+ attr_accessor :__meta
33
+
34
+ attr_accessor :created_at
35
+
36
+ attr_accessor :updated_at
37
+
38
+ attr_accessor :name
39
+
40
+ attr_accessor :slug
41
+
42
+ attr_accessor :status
43
+
44
+ attr_accessor :description
45
+
46
+ attr_accessor :photo
47
+
48
+ attr_accessor :depth
49
+
50
+ attr_accessor :position
51
+
52
+ attr_accessor :parent_category
53
+
54
+ class EnumAttributeValidator
55
+ attr_reader :datatype
56
+ attr_reader :allowable_values
57
+
58
+ def initialize(datatype, allowable_values)
59
+ @allowable_values = allowable_values.map do |value|
60
+ case datatype.to_s
61
+ when /Integer/i
62
+ value.to_i
63
+ when /Float/i
64
+ value.to_f
65
+ else
66
+ value
67
+ end
68
+ end
69
+ end
70
+
71
+ def valid?(value)
72
+ !value || allowable_values.include?(value)
73
+ end
74
+ end
75
+
76
+ # Attribute mapping from ruby-style variable name to JSON key.
77
+ def self.attribute_map
78
+ {
79
+ :'id' => :'id',
80
+ :'__meta' => :'__meta',
81
+ :'created_at' => :'createdAt',
82
+ :'updated_at' => :'updatedAt',
83
+ :'name' => :'name',
84
+ :'slug' => :'slug',
85
+ :'status' => :'status',
86
+ :'description' => :'description',
87
+ :'photo' => :'photo',
88
+ :'depth' => :'depth',
89
+ :'position' => :'position',
90
+ :'parent_category' => :'parentCategory'
91
+ }
92
+ end
93
+
94
+ # Attribute type mapping.
95
+ def self.swagger_types
96
+ {
97
+ :'id' => :'String',
98
+ :'__meta' => :'InstanceMeta',
99
+ :'created_at' => :'DateTime',
100
+ :'updated_at' => :'DateTime',
101
+ :'name' => :'String',
102
+ :'slug' => :'String',
103
+ :'status' => :'String',
104
+ :'description' => :'String',
105
+ :'photo' => :'Photo',
106
+ :'depth' => :'Integer',
107
+ :'position' => :'Integer',
108
+ :'parent_category' => :'Category'
109
+ }
110
+ end
111
+
112
+ # Initializes the object
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ def initialize(attributes = {})
115
+ return unless attributes.is_a?(Hash)
116
+
117
+ # convert string to symbol for hash key
118
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
119
+ if attributes.has_key?(:'id')
120
+ self.id = attributes[:'id']
121
+ end
122
+
123
+ if attributes.has_key?(:'__meta')
124
+ self.__meta = attributes[:'__meta']
125
+ end
126
+
127
+ if attributes.has_key?(:'createdAt')
128
+ self.created_at = attributes[:'createdAt']
129
+ end
130
+
131
+ if attributes.has_key?(:'created_at')
132
+ self.created_at = attributes[:'created_at']
133
+ end
134
+
135
+ if attributes.has_key?(:'updatedAt')
136
+ self.updated_at = attributes[:'updatedAt']
137
+ end
138
+
139
+ if attributes.has_key?(:'updated_at')
140
+ self.updated_at = attributes[:'updated_at']
141
+ end
142
+
143
+ if attributes.has_key?(:'name')
144
+ self.name = attributes[:'name']
145
+ end
146
+
147
+ if attributes.has_key?(:'slug')
148
+ self.slug = attributes[:'slug']
149
+ end
150
+
151
+ if attributes.has_key?(:'status')
152
+ self.status = attributes[:'status']
153
+ end
154
+
155
+ if attributes.has_key?(:'description')
156
+ self.description = attributes[:'description']
157
+ end
158
+
159
+ if attributes.has_key?(:'photo')
160
+ self.photo = attributes[:'photo']
161
+ end
162
+
163
+ if attributes.has_key?(:'depth')
164
+ self.depth = attributes[:'depth']
165
+ end
166
+
167
+ if attributes.has_key?(:'position')
168
+ self.position = attributes[:'position']
169
+ end
170
+
171
+ if attributes.has_key?(:'parentCategory')
172
+ self.parent_category = attributes[:'parentCategory']
173
+ end
174
+
175
+ if attributes.has_key?(:'parent_category')
176
+ self.parent_category = attributes[:'parent_category']
177
+ end
178
+ end
179
+
180
+ # Show invalid properties with the reasons. Usually used together with valid?
181
+ # @return Array for valid properties with the reasons
182
+ def list_invalid_properties
183
+ invalid_properties = Array.new
184
+ if @name.nil?
185
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
186
+ end
187
+
188
+ if @slug.nil?
189
+ invalid_properties.push('invalid value for "slug", slug cannot be nil.')
190
+ end
191
+
192
+ if @status.nil?
193
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
194
+ end
195
+
196
+ invalid_properties
197
+ end
198
+
199
+ # Check to see if the all the properties in the model are valid
200
+ # @return true if the model is valid
201
+ def valid?
202
+ return false if @name.nil?
203
+ return false if @slug.nil?
204
+ return false if @status.nil?
205
+ status_validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
206
+ return false unless status_validator.valid?(@status)
207
+ true
208
+ end
209
+
210
+ # Custom attribute writer method checking allowed values (enum).
211
+ # @param [Object] status Object to be assigned
212
+ def status=(status)
213
+ validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
214
+ unless validator.valid?(status)
215
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
216
+ end
217
+ @status = status
218
+ end
219
+
220
+ # Checks equality by comparing each attribute.
221
+ # @param [Object] Object to be compared
222
+ def ==(o)
223
+ return true if self.equal?(o)
224
+ self.class == o.class &&
225
+ __meta == o.__meta &&
226
+ created_at == o.created_at &&
227
+ updated_at == o.updated_at &&
228
+ name == o.name &&
229
+ slug == o.slug &&
230
+ status == o.status &&
231
+ description == o.description &&
232
+ photo == o.photo &&
233
+ depth == o.depth &&
234
+ position == o.position &&
235
+ parent_category == o.parent_category
236
+ end
237
+
238
+ # @see the `==` method
239
+ # @param [Object] Object to be compared
240
+ def eql?(o)
241
+ self == o
242
+ end
243
+
244
+ # Calculates hash code according to all attributes.
245
+ # @return [Fixnum] Hash code
246
+ def hash
247
+ [__meta, created_at, updated_at, name, slug, status, description, photo, depth, position, parent_category].hash
248
+ end
249
+
250
+ # Builds the object from hash
251
+ # @param [Hash] attributes Model attributes in the form of hash
252
+ # @return [Object] Returns the model itself
253
+ def build_from_hash(attributes)
254
+ return nil unless attributes.is_a?(Hash)
255
+ self.class.swagger_types.each_pair do |key, type|
256
+ if type =~ /\AArray<(.*)>/i
257
+ # check to ensure the input is an array given that the the attribute
258
+ # is documented as an array but the input is not
259
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
260
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
261
+ end
262
+ elsif !attributes[self.class.attribute_map[key]].nil?
263
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
264
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
265
+ end
266
+
267
+ self
268
+ end
269
+
270
+ # Deserializes the data based on type
271
+ # @param string type Data type
272
+ # @param string value Value to be deserialized
273
+ # @return [Object] Deserialized data
274
+ def _deserialize(type, value)
275
+ case type.to_sym
276
+ when :DateTime
277
+ DateTime.parse(value)
278
+ when :Date
279
+ Date.parse(value)
280
+ when :String
281
+ value.to_s
282
+ when :Integer
283
+ value.to_i
284
+ when :Float
285
+ value.to_f
286
+ when :BOOLEAN
287
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
288
+ true
289
+ else
290
+ false
291
+ end
292
+ when :Object
293
+ # generic object (usually a Hash), return directly
294
+ value
295
+ when /\AArray<(?<inner_type>.+)>\z/
296
+ inner_type = Regexp.last_match[:inner_type]
297
+ value.map { |v| _deserialize(inner_type, v) }
298
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
299
+ k_type = Regexp.last_match[:k_type]
300
+ v_type = Regexp.last_match[:v_type]
301
+ {}.tap do |hash|
302
+ value.each do |k, v|
303
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
304
+ end
305
+ end
306
+ else # model
307
+ temp_model = Tradenity.const_get(type).new
308
+ temp_model.build_from_hash(value)
309
+ end
310
+ end
311
+
312
+ # Returns the string representation of the object
313
+ # @return [String] String presentation of the object
314
+ def to_s
315
+ to_hash.to_s
316
+ end
317
+
318
+ # to_body is an alias to to_hash (backward compatibility)
319
+ # @return [Hash] Returns the object in the form of hash
320
+ def to_body
321
+ to_hash
322
+ end
323
+
324
+ # Returns the object in the form of hash
325
+ # @return [Hash] Returns the object in the form of hash
326
+ def to_hash
327
+ hash = {}
328
+ self.class.attribute_map.each_pair do |attr, param|
329
+ value = self.send(attr)
330
+ next if value.nil?
331
+ hash[param] = _to_hash(value)
332
+ end
333
+ hash
334
+ end
335
+
336
+ # Outputs non-array value in the form of hash
337
+ # For object, use to_hash. Otherwise, just return the value
338
+ # @param [Object] value Any valid value
339
+ # @return [Hash] Returns the value in the form of hash
340
+ def _to_hash(value)
341
+ if value.is_a?(Array)
342
+ value.compact.map { |v| _to_hash(v) }
343
+ elsif value.is_a?(Hash)
344
+ {}.tap do |hash|
345
+ value.each { |k, v| hash[k] = _to_hash(v) }
346
+ end
347
+ elsif value.respond_to? :to_hash
348
+ value.to_hash
349
+ else
350
+ value
351
+ end
352
+ end
353
+
354
+
355
+ def self.api_client
356
+ ApiClient.default
357
+ end
358
+
359
+ # Create Category
360
+ # Create a new Category
361
+ def create
362
+ data = self.class.create_category(self)
363
+ self.id = data.id
364
+ data
365
+ end
366
+
367
+ # Update Category
368
+ # Update attributes of Category
369
+ # @return [Category]
370
+ def update
371
+ self.class.update_category_by_id(self.id, self)
372
+ end
373
+
374
+ # Delete Category
375
+ # Delete this instance of Category.
376
+ # @return [nil]
377
+ def delete
378
+ self.class.delete_category_by_id(self.id)
379
+ end
380
+
381
+ class << self
382
+
383
+ # List Categorys
384
+ # Return a list of Categorys
385
+ # @param [Hash] opts the optional parameters
386
+ # @return [Page<Category>]
387
+ def find_all
388
+ list_all_categories
389
+ end
390
+
391
+ # Find List of Category
392
+ # Return multiple instances of Category by its attributes.
393
+ # @param [Hash] opts the search parameters
394
+ # @return [Page<Collection>]
395
+ def find_all_by(opts = {})
396
+ list_all_categories(opts)
397
+ end
398
+
399
+ # Find Category by its parameters
400
+ # Return single instance of Collection by its attributes.
401
+ # @param [Hash] opts search parameters
402
+ # @return [Category]
403
+ def find_one_by(opts = {})
404
+ list_all_categories(opts)[0]
405
+ end
406
+
407
+ # Find Category
408
+ # Return single instance of Category by its ID.
409
+ # @param id ID of Category to return
410
+ # @return [Category]
411
+ def find_by_id(id)
412
+ get_category_by_id(id)
413
+ end
414
+
415
+ # Delete Category
416
+ # Delete an instance of Category by its ID.
417
+ # @param id ID of Category to delete.
418
+ # @return [nil]
419
+ def delete_by_id(id)
420
+ delete_category_by_id(id)
421
+ end
422
+
423
+ # Create Category
424
+ # Create a new Category
425
+ # @param category Attributes of category to create
426
+ # @param [Hash] opts the optional parameters
427
+ # @return [Category]
428
+ def create_category(category, opts = {})
429
+ data, _status_code, _headers = create_category_with_http_info(category, opts)
430
+ data
431
+ end
432
+
433
+ # Create Category
434
+ # Create a new Category
435
+ # @param category Attributes of category to create
436
+ # @param [Hash] opts the optional parameters
437
+ # @return [Array<(Category, Fixnum, Hash)>] Category data, response status code and response headers
438
+ def create_category_with_http_info(category, opts = {})
439
+ if api_client.config.debugging
440
+ api_client.config.logger.debug 'Calling API: Category.create_category ...'
441
+ end
442
+ # verify the required parameter 'category' is set
443
+ if api_client.config.client_side_validation && category.nil?
444
+ fail ArgumentError, "Missing the required parameter 'category' when calling Category.create_category"
445
+ end
446
+ # resource path
447
+ local_var_path = '/categories'
448
+
449
+ # query parameters
450
+ query_params = opts
451
+
452
+ # header parameters
453
+ header_params = {}
454
+ # HTTP header 'Accept' (if needed)
455
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
456
+ # HTTP header 'Content-Type'
457
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
458
+
459
+ # form parameters
460
+ form_params = {}
461
+
462
+ # http body (model)
463
+ post_body = api_client.object_to_http_body(category)
464
+ auth_names = []
465
+ data, status_code, headers = api_client.call_api(:POST, local_var_path,
466
+ :header_params => header_params,
467
+ :query_params => query_params,
468
+ :form_params => form_params,
469
+ :body => post_body,
470
+ :auth_names => auth_names,
471
+ :return_type => 'Category')
472
+ if api_client.config.debugging
473
+ api_client.config.logger.debug "API called: Category#create_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
474
+ end
475
+ return data, status_code, headers
476
+ end
477
+ # Delete Category
478
+ # Delete an instance of Category by its ID.
479
+ # @param category_id ID of category to delete.
480
+ # @param [Hash] opts the optional parameters
481
+ # @return [nil]
482
+ def delete_category_by_id(category_id, opts = {})
483
+ delete_category_by_id_with_http_info(category_id, opts)
484
+ nil
485
+ end
486
+
487
+ # Delete Category
488
+ # Delete an instance of Category by its ID.
489
+ # @param category_id ID of category to delete.
490
+ # @param [Hash] opts the optional parameters
491
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
492
+ def delete_category_by_id_with_http_info(category_id, opts = {})
493
+ if api_client.config.debugging
494
+ api_client.config.logger.debug 'Calling API: Category.delete_category_by_id ...'
495
+ end
496
+ # verify the required parameter 'category_id' is set
497
+ if api_client.config.client_side_validation && category_id.nil?
498
+ fail ArgumentError, "Missing the required parameter 'category_id' when calling Category.delete_category_by_id"
499
+ end
500
+ # resource path
501
+ local_var_path = '/categories/{categoryId}'.sub('{' + 'categoryId' + '}', category_id.to_s)
502
+
503
+ # query parameters
504
+ query_params = opts
505
+
506
+ # header parameters
507
+ header_params = {}
508
+ # HTTP header 'Accept' (if needed)
509
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
510
+ # HTTP header 'Content-Type'
511
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
512
+
513
+ # form parameters
514
+ form_params = {}
515
+
516
+ # http body (model)
517
+ post_body = nil
518
+ auth_names = []
519
+ data, status_code, headers = api_client.call_api(:DELETE, local_var_path,
520
+ :header_params => header_params,
521
+ :query_params => query_params,
522
+ :form_params => form_params,
523
+ :body => post_body,
524
+ :auth_names => auth_names)
525
+ if api_client.config.debugging
526
+ api_client.config.logger.debug "API called: Category#delete_category_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
527
+ end
528
+ return data, status_code, headers
529
+ end
530
+ # Find Category
531
+ # Return single instance of Category by its ID.
532
+ # @param category_id ID of category to return
533
+ # @param [Hash] opts the optional parameters
534
+ # @return [Category]
535
+ def get_category_by_id(category_id, opts = {})
536
+ data, _status_code, _headers = get_category_by_id_with_http_info(category_id, opts)
537
+ data
538
+ end
539
+
540
+ # Find Category
541
+ # Return single instance of Category by its ID.
542
+ # @param category_id ID of category to return
543
+ # @param [Hash] opts the optional parameters
544
+ # @return [Array<(Category, Fixnum, Hash)>] Category data, response status code and response headers
545
+ def get_category_by_id_with_http_info(category_id, opts = {})
546
+ if api_client.config.debugging
547
+ api_client.config.logger.debug 'Calling API: Category.get_category_by_id ...'
548
+ end
549
+ # verify the required parameter 'category_id' is set
550
+ if api_client.config.client_side_validation && category_id.nil?
551
+ fail ArgumentError, "Missing the required parameter 'category_id' when calling Category.get_category_by_id"
552
+ end
553
+ # resource path
554
+ local_var_path = '/categories/{categoryId}'.sub('{' + 'categoryId' + '}', category_id.to_s)
555
+
556
+ # query parameters
557
+ query_params = opts
558
+
559
+ # header parameters
560
+ header_params = {}
561
+ # HTTP header 'Accept' (if needed)
562
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
563
+ # HTTP header 'Content-Type'
564
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
565
+
566
+ # form parameters
567
+ form_params = {}
568
+
569
+ # http body (model)
570
+ post_body = nil
571
+ auth_names = []
572
+ data, status_code, headers = api_client.call_api(:GET, local_var_path,
573
+ :header_params => header_params,
574
+ :query_params => query_params,
575
+ :form_params => form_params,
576
+ :body => post_body,
577
+ :auth_names => auth_names,
578
+ :return_type => 'Category')
579
+ if api_client.config.debugging
580
+ api_client.config.logger.debug "API called: Category#get_category_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
581
+ end
582
+ return data, status_code, headers
583
+ end
584
+ # List Categories
585
+ # Return a list of Categories
586
+ # @param [Hash] opts the optional parameters
587
+ # @option opts [Integer] :page page number
588
+ # @option opts [Integer] :size page size
589
+ # @option opts [String] :sort page order
590
+ # @return [Page<Category>]
591
+ def list_all_categories(opts = {})
592
+ data, _status_code, _headers = list_all_categories_with_http_info(opts)
593
+ data
594
+ end
595
+
596
+ # List Categories
597
+ # Return a list of Categories
598
+ # @param [Hash] opts the optional parameters
599
+ # @option opts [Integer] :page page number
600
+ # @option opts [Integer] :size page size
601
+ # @option opts [String] :sort page order
602
+ # @return [Array<(Page<Category>, Fixnum, Hash)>] Page<Category> data, response status code and response headers
603
+ def list_all_categories_with_http_info(opts = {})
604
+ if api_client.config.debugging
605
+ api_client.config.logger.debug 'Calling API: Category.list_all_categories ...'
606
+ end
607
+ # resource path
608
+ local_var_path = '/categories'
609
+
610
+ # query parameters
611
+ query_params = opts
612
+ # query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
613
+ # query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
614
+ # query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
615
+
616
+ # header parameters
617
+ header_params = {}
618
+ # HTTP header 'Accept' (if needed)
619
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
620
+ # HTTP header 'Content-Type'
621
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
622
+
623
+ # form parameters
624
+ form_params = {}
625
+
626
+ # http body (model)
627
+ post_body = nil
628
+ auth_names = []
629
+ data, status_code, headers = api_client.call_api(:GET, local_var_path,
630
+ :header_params => header_params,
631
+ :query_params => query_params,
632
+ :form_params => form_params,
633
+ :body => post_body,
634
+ :auth_names => auth_names,
635
+ :return_type => 'Page<Category>')
636
+ if api_client.config.debugging
637
+ api_client.config.logger.debug "API called: Category#list_all_categories\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
638
+ end
639
+ return data, status_code, headers
640
+ end
641
+ # Replace Category
642
+ # Replace all attributes of Category
643
+ # @param category_id ID of category to replace
644
+ # @param category Attributes of category to replace
645
+ # @param [Hash] opts the optional parameters
646
+ # @return [Category]
647
+ def replace_category_by_id(category_id, category, opts = {})
648
+ data, _status_code, _headers = replace_category_by_id_with_http_info(category_id, category, opts)
649
+ data
650
+ end
651
+
652
+ # Replace Category
653
+ # Replace all attributes of Category
654
+ # @param category_id ID of category to replace
655
+ # @param category Attributes of category to replace
656
+ # @param [Hash] opts the optional parameters
657
+ # @return [Array<(Category, Fixnum, Hash)>] Category data, response status code and response headers
658
+ def replace_category_by_id_with_http_info(category_id, category, opts = {})
659
+ if api_client.config.debugging
660
+ api_client.config.logger.debug 'Calling API: Category.replace_category_by_id ...'
661
+ end
662
+ # verify the required parameter 'category_id' is set
663
+ if api_client.config.client_side_validation && category_id.nil?
664
+ fail ArgumentError, "Missing the required parameter 'category_id' when calling Category.replace_category_by_id"
665
+ end
666
+ # verify the required parameter 'category' is set
667
+ if api_client.config.client_side_validation && category.nil?
668
+ fail ArgumentError, "Missing the required parameter 'category' when calling Category.replace_category_by_id"
669
+ end
670
+ # resource path
671
+ local_var_path = '/categories/{categoryId}'.sub('{' + 'categoryId' + '}', category_id.to_s)
672
+
673
+ # query parameters
674
+ query_params = opts
675
+
676
+ # header parameters
677
+ header_params = {}
678
+ # HTTP header 'Accept' (if needed)
679
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
680
+ # HTTP header 'Content-Type'
681
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
682
+
683
+ # form parameters
684
+ form_params = {}
685
+
686
+ # http body (model)
687
+ post_body = api_client.object_to_http_body(category)
688
+ auth_names = []
689
+ data, status_code, headers = api_client.call_api(:PUT, local_var_path,
690
+ :header_params => header_params,
691
+ :query_params => query_params,
692
+ :form_params => form_params,
693
+ :body => post_body,
694
+ :auth_names => auth_names,
695
+ :return_type => 'Category')
696
+ if api_client.config.debugging
697
+ api_client.config.logger.debug "API called: Category#replace_category_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
698
+ end
699
+ return data, status_code, headers
700
+ end
701
+ # Update Category
702
+ # Update attributes of Category
703
+ # @param category_id ID of category to update.
704
+ # @param category Attributes of category to update.
705
+ # @param [Hash] opts the optional parameters
706
+ # @return [Category]
707
+ def update_category_by_id(category_id, category, opts = {})
708
+ data, _status_code, _headers = update_category_by_id_with_http_info(category_id, category, opts)
709
+ data
710
+ end
711
+
712
+ # Update Category
713
+ # Update attributes of Category
714
+ # @param category_id ID of category to update.
715
+ # @param category Attributes of category to update.
716
+ # @param [Hash] opts the optional parameters
717
+ # @return [Array<(Category, Fixnum, Hash)>] Category data, response status code and response headers
718
+ def update_category_by_id_with_http_info(category_id, category, opts = {})
719
+ if api_client.config.debugging
720
+ api_client.config.logger.debug 'Calling API: Category.update_category_by_id ...'
721
+ end
722
+ # verify the required parameter 'category_id' is set
723
+ if api_client.config.client_side_validation && category_id.nil?
724
+ fail ArgumentError, "Missing the required parameter 'category_id' when calling Category.update_category_by_id"
725
+ end
726
+ # verify the required parameter 'category' is set
727
+ if api_client.config.client_side_validation && category.nil?
728
+ fail ArgumentError, "Missing the required parameter 'category' when calling Category.update_category_by_id"
729
+ end
730
+ # resource path
731
+ local_var_path = '/categories/{categoryId}'.sub('{' + 'categoryId' + '}', category_id.to_s)
732
+
733
+ # query parameters
734
+ query_params = opts
735
+
736
+ # header parameters
737
+ header_params = {}
738
+ # HTTP header 'Accept' (if needed)
739
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
740
+ # HTTP header 'Content-Type'
741
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
742
+
743
+ # form parameters
744
+ form_params = {}
745
+
746
+ # http body (model)
747
+ post_body = api_client.object_to_http_body(category)
748
+ auth_names = []
749
+ data, status_code, headers = api_client.call_api(:PATCH, local_var_path,
750
+ :header_params => header_params,
751
+ :query_params => query_params,
752
+ :form_params => form_params,
753
+ :body => post_body,
754
+ :auth_names => auth_names,
755
+ :return_type => 'Category')
756
+ if api_client.config.debugging
757
+ api_client.config.logger.debug "API called: Category#update_category_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
758
+ end
759
+ return data, status_code, headers
760
+ end
761
+ end
762
+ end
763
+ end