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,877 @@
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 Variant
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 :sku
43
+
44
+ attr_accessor :description
45
+
46
+ attr_accessor :status
47
+
48
+ attr_accessor :price_change
49
+
50
+ attr_accessor :stock_level
51
+
52
+ attr_accessor :minimum_stock_level
53
+
54
+ attr_accessor :maximum_sell_count
55
+
56
+ attr_accessor :item_dimensions
57
+
58
+ attr_accessor :package_dimensions
59
+
60
+ attr_accessor :package_weight
61
+
62
+ attr_accessor :product
63
+
64
+ attr_accessor :option_set
65
+
66
+ attr_accessor :option_values
67
+
68
+ class EnumAttributeValidator
69
+ attr_reader :datatype
70
+ attr_reader :allowable_values
71
+
72
+ def initialize(datatype, allowable_values)
73
+ @allowable_values = allowable_values.map do |value|
74
+ case datatype.to_s
75
+ when /Integer/i
76
+ value.to_i
77
+ when /Float/i
78
+ value.to_f
79
+ else
80
+ value
81
+ end
82
+ end
83
+ end
84
+
85
+ def valid?(value)
86
+ !value || allowable_values.include?(value)
87
+ end
88
+ end
89
+
90
+ # Attribute mapping from ruby-style variable name to JSON key.
91
+ def self.attribute_map
92
+ {
93
+ :'id' => :'id',
94
+ :'__meta' => :'__meta',
95
+ :'created_at' => :'createdAt',
96
+ :'updated_at' => :'updatedAt',
97
+ :'name' => :'name',
98
+ :'slug' => :'slug',
99
+ :'sku' => :'sku',
100
+ :'description' => :'description',
101
+ :'status' => :'status',
102
+ :'price_change' => :'priceChange',
103
+ :'stock_level' => :'stockLevel',
104
+ :'minimum_stock_level' => :'minimumStockLevel',
105
+ :'maximum_sell_count' => :'maximumSellCount',
106
+ :'item_dimensions' => :'itemDimensions',
107
+ :'package_dimensions' => :'packageDimensions',
108
+ :'package_weight' => :'packageWeight',
109
+ :'product' => :'product',
110
+ :'option_set' => :'optionSet',
111
+ :'option_values' => :'optionValues'
112
+ }
113
+ end
114
+
115
+ # Attribute type mapping.
116
+ def self.swagger_types
117
+ {
118
+ :'id' => :'String',
119
+ :'__meta' => :'InstanceMeta',
120
+ :'created_at' => :'DateTime',
121
+ :'updated_at' => :'DateTime',
122
+ :'name' => :'String',
123
+ :'slug' => :'String',
124
+ :'sku' => :'String',
125
+ :'description' => :'String',
126
+ :'status' => :'String',
127
+ :'price_change' => :'Integer',
128
+ :'stock_level' => :'Integer',
129
+ :'minimum_stock_level' => :'Integer',
130
+ :'maximum_sell_count' => :'Integer',
131
+ :'item_dimensions' => :'Dimensions',
132
+ :'package_dimensions' => :'Dimensions',
133
+ :'package_weight' => :'Weight',
134
+ :'product' => :'Product',
135
+ :'option_set' => :'OptionSet',
136
+ :'option_values' => :'Array<OptionValue>'
137
+ }
138
+ end
139
+
140
+ # Initializes the object
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ def initialize(attributes = {})
143
+ return unless attributes.is_a?(Hash)
144
+
145
+ # convert string to symbol for hash key
146
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
147
+ if attributes.has_key?(:'id')
148
+ self.id = attributes[:'id']
149
+ end
150
+
151
+ if attributes.has_key?(:'__meta')
152
+ self.__meta = attributes[:'__meta']
153
+ end
154
+
155
+ if attributes.has_key?(:'createdAt')
156
+ self.created_at = attributes[:'createdAt']
157
+ end
158
+
159
+ if attributes.has_key?(:'created_at')
160
+ self.created_at = attributes[:'created_at']
161
+ end
162
+
163
+ if attributes.has_key?(:'updatedAt')
164
+ self.updated_at = attributes[:'updatedAt']
165
+ end
166
+
167
+ if attributes.has_key?(:'updated_at')
168
+ self.updated_at = attributes[:'updated_at']
169
+ end
170
+
171
+ if attributes.has_key?(:'name')
172
+ self.name = attributes[:'name']
173
+ end
174
+
175
+ if attributes.has_key?(:'slug')
176
+ self.slug = attributes[:'slug']
177
+ end
178
+
179
+ if attributes.has_key?(:'sku')
180
+ self.sku = attributes[:'sku']
181
+ end
182
+
183
+ if attributes.has_key?(:'description')
184
+ self.description = attributes[:'description']
185
+ end
186
+
187
+ if attributes.has_key?(:'status')
188
+ self.status = attributes[:'status']
189
+ end
190
+
191
+ if attributes.has_key?(:'priceChange')
192
+ self.price_change = attributes[:'priceChange']
193
+ end
194
+
195
+ if attributes.has_key?(:'price_change')
196
+ self.price_change = attributes[:'price_change']
197
+ end
198
+
199
+ if attributes.has_key?(:'stockLevel')
200
+ self.stock_level = attributes[:'stockLevel']
201
+ end
202
+
203
+ if attributes.has_key?(:'stock_level')
204
+ self.stock_level = attributes[:'stock_level']
205
+ end
206
+
207
+ if attributes.has_key?(:'minimumStockLevel')
208
+ self.minimum_stock_level = attributes[:'minimumStockLevel']
209
+ end
210
+
211
+ if attributes.has_key?(:'minimum_stock_level')
212
+ self.minimum_stock_level = attributes[:'minimum_stock_level']
213
+ end
214
+
215
+ if attributes.has_key?(:'maximumSellCount')
216
+ self.maximum_sell_count = attributes[:'maximumSellCount']
217
+ end
218
+
219
+ if attributes.has_key?(:'maximum_sell_count')
220
+ self.maximum_sell_count = attributes[:'maximum_sell_count']
221
+ end
222
+
223
+ if attributes.has_key?(:'itemDimensions')
224
+ self.item_dimensions = attributes[:'itemDimensions']
225
+ end
226
+
227
+ if attributes.has_key?(:'item_dimensions')
228
+ self.item_dimensions = attributes[:'item_dimensions']
229
+ end
230
+
231
+ if attributes.has_key?(:'packageDimensions')
232
+ self.package_dimensions = attributes[:'packageDimensions']
233
+ end
234
+
235
+ if attributes.has_key?(:'package_dimensions')
236
+ self.package_dimensions = attributes[:'package_dimensions']
237
+ end
238
+
239
+ if attributes.has_key?(:'packageWeight')
240
+ self.package_weight = attributes[:'packageWeight']
241
+ end
242
+
243
+ if attributes.has_key?(:'package_weight')
244
+ self.package_weight = attributes[:'package_weight']
245
+ end
246
+
247
+ if attributes.has_key?(:'product')
248
+ self.product = attributes[:'product']
249
+ end
250
+
251
+ if attributes.has_key?(:'optionSet')
252
+ self.option_set = attributes[:'optionSet']
253
+ end
254
+
255
+ if attributes.has_key?(:'option_set')
256
+ self.option_set = attributes[:'option_set']
257
+ end
258
+
259
+ if attributes.has_key?(:'optionValues')
260
+ if (value = attributes[:'optionValues']).is_a?(Array)
261
+ self.option_values = value
262
+ end
263
+ end
264
+
265
+ if attributes.has_key?(:'option_values')
266
+ if (value = attributes[:'option_values']).is_a?(Array)
267
+ self.option_values = value
268
+ end
269
+ end
270
+ end
271
+
272
+ # Show invalid properties with the reasons. Usually used together with valid?
273
+ # @return Array for valid properties with the reasons
274
+ def list_invalid_properties
275
+ invalid_properties = Array.new
276
+ if @name.nil?
277
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
278
+ end
279
+
280
+ if @slug.nil?
281
+ invalid_properties.push('invalid value for "slug", slug cannot be nil.')
282
+ end
283
+
284
+ if @sku.nil?
285
+ invalid_properties.push('invalid value for "sku", sku cannot be nil.')
286
+ end
287
+
288
+ if @status.nil?
289
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
290
+ end
291
+
292
+ if @product.nil?
293
+ invalid_properties.push('invalid value for "product", product cannot be nil.')
294
+ end
295
+
296
+ if @option_set.nil?
297
+ invalid_properties.push('invalid value for "option_set", option_set cannot be nil.')
298
+ end
299
+
300
+ invalid_properties
301
+ end
302
+
303
+ # Check to see if the all the properties in the model are valid
304
+ # @return true if the model is valid
305
+ def valid?
306
+ return false if @name.nil?
307
+ return false if @slug.nil?
308
+ return false if @sku.nil?
309
+ return false if @status.nil?
310
+ status_validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
311
+ return false unless status_validator.valid?(@status)
312
+ return false if @product.nil?
313
+ return false if @option_set.nil?
314
+ true
315
+ end
316
+
317
+ # Custom attribute writer method checking allowed values (enum).
318
+ # @param [Object] status Object to be assigned
319
+ def status=(status)
320
+ validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
321
+ unless validator.valid?(status)
322
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
323
+ end
324
+ @status = status
325
+ end
326
+
327
+ # Checks equality by comparing each attribute.
328
+ # @param [Object] Object to be compared
329
+ def ==(o)
330
+ return true if self.equal?(o)
331
+ self.class == o.class &&
332
+ __meta == o.__meta &&
333
+ created_at == o.created_at &&
334
+ updated_at == o.updated_at &&
335
+ name == o.name &&
336
+ slug == o.slug &&
337
+ sku == o.sku &&
338
+ description == o.description &&
339
+ status == o.status &&
340
+ price_change == o.price_change &&
341
+ stock_level == o.stock_level &&
342
+ minimum_stock_level == o.minimum_stock_level &&
343
+ maximum_sell_count == o.maximum_sell_count &&
344
+ item_dimensions == o.item_dimensions &&
345
+ package_dimensions == o.package_dimensions &&
346
+ package_weight == o.package_weight &&
347
+ product == o.product &&
348
+ option_set == o.option_set &&
349
+ option_values == o.option_values
350
+ end
351
+
352
+ # @see the `==` method
353
+ # @param [Object] Object to be compared
354
+ def eql?(o)
355
+ self == o
356
+ end
357
+
358
+ # Calculates hash code according to all attributes.
359
+ # @return [Fixnum] Hash code
360
+ def hash
361
+ [__meta, created_at, updated_at, name, slug, sku, description, status, price_change, stock_level, minimum_stock_level, maximum_sell_count, item_dimensions, package_dimensions, package_weight, product, option_set, option_values].hash
362
+ end
363
+
364
+ # Builds the object from hash
365
+ # @param [Hash] attributes Model attributes in the form of hash
366
+ # @return [Object] Returns the model itself
367
+ def build_from_hash(attributes)
368
+ return nil unless attributes.is_a?(Hash)
369
+ self.class.swagger_types.each_pair do |key, type|
370
+ if type =~ /\AArray<(.*)>/i
371
+ # check to ensure the input is an array given that the the attribute
372
+ # is documented as an array but the input is not
373
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
374
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
375
+ end
376
+ elsif !attributes[self.class.attribute_map[key]].nil?
377
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
378
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
379
+ end
380
+
381
+ self
382
+ end
383
+
384
+ # Deserializes the data based on type
385
+ # @param string type Data type
386
+ # @param string value Value to be deserialized
387
+ # @return [Object] Deserialized data
388
+ def _deserialize(type, value)
389
+ case type.to_sym
390
+ when :DateTime
391
+ DateTime.parse(value)
392
+ when :Date
393
+ Date.parse(value)
394
+ when :String
395
+ value.to_s
396
+ when :Integer
397
+ value.to_i
398
+ when :Float
399
+ value.to_f
400
+ when :BOOLEAN
401
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
402
+ true
403
+ else
404
+ false
405
+ end
406
+ when :Object
407
+ # generic object (usually a Hash), return directly
408
+ value
409
+ when /\AArray<(?<inner_type>.+)>\z/
410
+ inner_type = Regexp.last_match[:inner_type]
411
+ value.map { |v| _deserialize(inner_type, v) }
412
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
413
+ k_type = Regexp.last_match[:k_type]
414
+ v_type = Regexp.last_match[:v_type]
415
+ {}.tap do |hash|
416
+ value.each do |k, v|
417
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
418
+ end
419
+ end
420
+ else # model
421
+ temp_model = Tradenity.const_get(type).new
422
+ temp_model.build_from_hash(value)
423
+ end
424
+ end
425
+
426
+ # Returns the string representation of the object
427
+ # @return [String] String presentation of the object
428
+ def to_s
429
+ to_hash.to_s
430
+ end
431
+
432
+ # to_body is an alias to to_hash (backward compatibility)
433
+ # @return [Hash] Returns the object in the form of hash
434
+ def to_body
435
+ to_hash
436
+ end
437
+
438
+ # Returns the object in the form of hash
439
+ # @return [Hash] Returns the object in the form of hash
440
+ def to_hash
441
+ hash = {}
442
+ self.class.attribute_map.each_pair do |attr, param|
443
+ value = self.send(attr)
444
+ next if value.nil?
445
+ hash[param] = _to_hash(value)
446
+ end
447
+ hash
448
+ end
449
+
450
+ # Outputs non-array value in the form of hash
451
+ # For object, use to_hash. Otherwise, just return the value
452
+ # @param [Object] value Any valid value
453
+ # @return [Hash] Returns the value in the form of hash
454
+ def _to_hash(value)
455
+ if value.is_a?(Array)
456
+ value.compact.map { |v| _to_hash(v) }
457
+ elsif value.is_a?(Hash)
458
+ {}.tap do |hash|
459
+ value.each { |k, v| hash[k] = _to_hash(v) }
460
+ end
461
+ elsif value.respond_to? :to_hash
462
+ value.to_hash
463
+ else
464
+ value
465
+ end
466
+ end
467
+
468
+
469
+ def self.api_client
470
+ ApiClient.default
471
+ end
472
+
473
+ # Create Variant
474
+ # Create a new Variant
475
+ def create
476
+ data = self.class.create_variant(self)
477
+ self.id = data.id
478
+ data
479
+ end
480
+
481
+ # Update Variant
482
+ # Update attributes of Variant
483
+ # @return [Variant]
484
+ def update
485
+ self.class.update_variant_by_id(self.id, self)
486
+ end
487
+
488
+ # Delete Variant
489
+ # Delete this instance of Variant.
490
+ # @return [nil]
491
+ def delete
492
+ self.class.delete_variant_by_id(self.id)
493
+ end
494
+
495
+ class << self
496
+
497
+ # List Variants
498
+ # Return a list of Variants
499
+ # @param [Hash] opts the optional parameters
500
+ # @return [Page<Variant>]
501
+ def find_all
502
+ list_all_variants
503
+ end
504
+
505
+ # Find List of Variant
506
+ # Return multiple instances of Variant by its attributes.
507
+ # @param [Hash] opts the search parameters
508
+ # @return [Page<Collection>]
509
+ def find_all_by(opts = {})
510
+ list_all_variants(opts)
511
+ end
512
+
513
+ # Find Variant by its parameters
514
+ # Return single instance of Collection by its attributes.
515
+ # @param [Hash] opts search parameters
516
+ # @return [Variant]
517
+ def find_one_by(opts = {})
518
+ list_all_variants(opts)[0]
519
+ end
520
+
521
+ # Find Variant
522
+ # Return single instance of Variant by its ID.
523
+ # @param id ID of Variant to return
524
+ # @return [Variant]
525
+ def find_by_id(id)
526
+ get_variant_by_id(id)
527
+ end
528
+
529
+ # Delete Variant
530
+ # Delete an instance of Variant by its ID.
531
+ # @param id ID of Variant to delete.
532
+ # @return [nil]
533
+ def delete_by_id(id)
534
+ delete_variant_by_id(id)
535
+ end
536
+
537
+ # Create Variant
538
+ # Create a new Variant
539
+ # @param variant Attributes of variant to create
540
+ # @param [Hash] opts the optional parameters
541
+ # @return [Variant]
542
+ def create_variant(variant, opts = {})
543
+ data, _status_code, _headers = create_variant_with_http_info(variant, opts)
544
+ data
545
+ end
546
+
547
+ # Create Variant
548
+ # Create a new Variant
549
+ # @param variant Attributes of variant to create
550
+ # @param [Hash] opts the optional parameters
551
+ # @return [Array<(Variant, Fixnum, Hash)>] Variant data, response status code and response headers
552
+ def create_variant_with_http_info(variant, opts = {})
553
+ if api_client.config.debugging
554
+ api_client.config.logger.debug 'Calling API: Variant.create_variant ...'
555
+ end
556
+ # verify the required parameter 'variant' is set
557
+ if api_client.config.client_side_validation && variant.nil?
558
+ fail ArgumentError, "Missing the required parameter 'variant' when calling Variant.create_variant"
559
+ end
560
+ # resource path
561
+ local_var_path = '/variants'
562
+
563
+ # query parameters
564
+ query_params = opts
565
+
566
+ # header parameters
567
+ header_params = {}
568
+ # HTTP header 'Accept' (if needed)
569
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
570
+ # HTTP header 'Content-Type'
571
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
572
+
573
+ # form parameters
574
+ form_params = {}
575
+
576
+ # http body (model)
577
+ post_body = api_client.object_to_http_body(variant)
578
+ auth_names = []
579
+ data, status_code, headers = api_client.call_api(:POST, local_var_path,
580
+ :header_params => header_params,
581
+ :query_params => query_params,
582
+ :form_params => form_params,
583
+ :body => post_body,
584
+ :auth_names => auth_names,
585
+ :return_type => 'Variant')
586
+ if api_client.config.debugging
587
+ api_client.config.logger.debug "API called: Variant#create_variant\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
588
+ end
589
+ return data, status_code, headers
590
+ end
591
+ # Delete Variant
592
+ # Delete an instance of Variant by its ID.
593
+ # @param variant_id ID of variant to delete.
594
+ # @param [Hash] opts the optional parameters
595
+ # @return [nil]
596
+ def delete_variant_by_id(variant_id, opts = {})
597
+ delete_variant_by_id_with_http_info(variant_id, opts)
598
+ nil
599
+ end
600
+
601
+ # Delete Variant
602
+ # Delete an instance of Variant by its ID.
603
+ # @param variant_id ID of variant to delete.
604
+ # @param [Hash] opts the optional parameters
605
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
606
+ def delete_variant_by_id_with_http_info(variant_id, opts = {})
607
+ if api_client.config.debugging
608
+ api_client.config.logger.debug 'Calling API: Variant.delete_variant_by_id ...'
609
+ end
610
+ # verify the required parameter 'variant_id' is set
611
+ if api_client.config.client_side_validation && variant_id.nil?
612
+ fail ArgumentError, "Missing the required parameter 'variant_id' when calling Variant.delete_variant_by_id"
613
+ end
614
+ # resource path
615
+ local_var_path = '/variants/{variantId}'.sub('{' + 'variantId' + '}', variant_id.to_s)
616
+
617
+ # query parameters
618
+ query_params = opts
619
+
620
+ # header parameters
621
+ header_params = {}
622
+ # HTTP header 'Accept' (if needed)
623
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
624
+ # HTTP header 'Content-Type'
625
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
626
+
627
+ # form parameters
628
+ form_params = {}
629
+
630
+ # http body (model)
631
+ post_body = nil
632
+ auth_names = []
633
+ data, status_code, headers = api_client.call_api(:DELETE, local_var_path,
634
+ :header_params => header_params,
635
+ :query_params => query_params,
636
+ :form_params => form_params,
637
+ :body => post_body,
638
+ :auth_names => auth_names)
639
+ if api_client.config.debugging
640
+ api_client.config.logger.debug "API called: Variant#delete_variant_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
641
+ end
642
+ return data, status_code, headers
643
+ end
644
+ # Find Variant
645
+ # Return single instance of Variant by its ID.
646
+ # @param variant_id ID of variant to return
647
+ # @param [Hash] opts the optional parameters
648
+ # @return [Variant]
649
+ def get_variant_by_id(variant_id, opts = {})
650
+ data, _status_code, _headers = get_variant_by_id_with_http_info(variant_id, opts)
651
+ data
652
+ end
653
+
654
+ # Find Variant
655
+ # Return single instance of Variant by its ID.
656
+ # @param variant_id ID of variant to return
657
+ # @param [Hash] opts the optional parameters
658
+ # @return [Array<(Variant, Fixnum, Hash)>] Variant data, response status code and response headers
659
+ def get_variant_by_id_with_http_info(variant_id, opts = {})
660
+ if api_client.config.debugging
661
+ api_client.config.logger.debug 'Calling API: Variant.get_variant_by_id ...'
662
+ end
663
+ # verify the required parameter 'variant_id' is set
664
+ if api_client.config.client_side_validation && variant_id.nil?
665
+ fail ArgumentError, "Missing the required parameter 'variant_id' when calling Variant.get_variant_by_id"
666
+ end
667
+ # resource path
668
+ local_var_path = '/variants/{variantId}'.sub('{' + 'variantId' + '}', variant_id.to_s)
669
+
670
+ # query parameters
671
+ query_params = opts
672
+
673
+ # header parameters
674
+ header_params = {}
675
+ # HTTP header 'Accept' (if needed)
676
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
677
+ # HTTP header 'Content-Type'
678
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
679
+
680
+ # form parameters
681
+ form_params = {}
682
+
683
+ # http body (model)
684
+ post_body = nil
685
+ auth_names = []
686
+ data, status_code, headers = api_client.call_api(:GET, local_var_path,
687
+ :header_params => header_params,
688
+ :query_params => query_params,
689
+ :form_params => form_params,
690
+ :body => post_body,
691
+ :auth_names => auth_names,
692
+ :return_type => 'Variant')
693
+ if api_client.config.debugging
694
+ api_client.config.logger.debug "API called: Variant#get_variant_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
695
+ end
696
+ return data, status_code, headers
697
+ end
698
+ # List Variants
699
+ # Return a list of Variants
700
+ # @param [Hash] opts the optional parameters
701
+ # @option opts [Integer] :page page number
702
+ # @option opts [Integer] :size page size
703
+ # @option opts [String] :sort page order
704
+ # @return [Page<Variant>]
705
+ def list_all_variants(opts = {})
706
+ data, _status_code, _headers = list_all_variants_with_http_info(opts)
707
+ data
708
+ end
709
+
710
+ # List Variants
711
+ # Return a list of Variants
712
+ # @param [Hash] opts the optional parameters
713
+ # @option opts [Integer] :page page number
714
+ # @option opts [Integer] :size page size
715
+ # @option opts [String] :sort page order
716
+ # @return [Array<(Page<Variant>, Fixnum, Hash)>] Page<Variant> data, response status code and response headers
717
+ def list_all_variants_with_http_info(opts = {})
718
+ if api_client.config.debugging
719
+ api_client.config.logger.debug 'Calling API: Variant.list_all_variants ...'
720
+ end
721
+ # resource path
722
+ local_var_path = '/variants'
723
+
724
+ # query parameters
725
+ query_params = opts
726
+ # query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
727
+ # query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
728
+ # query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
729
+
730
+ # header parameters
731
+ header_params = {}
732
+ # HTTP header 'Accept' (if needed)
733
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
734
+ # HTTP header 'Content-Type'
735
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
736
+
737
+ # form parameters
738
+ form_params = {}
739
+
740
+ # http body (model)
741
+ post_body = nil
742
+ auth_names = []
743
+ data, status_code, headers = api_client.call_api(:GET, local_var_path,
744
+ :header_params => header_params,
745
+ :query_params => query_params,
746
+ :form_params => form_params,
747
+ :body => post_body,
748
+ :auth_names => auth_names,
749
+ :return_type => 'Page<Variant>')
750
+ if api_client.config.debugging
751
+ api_client.config.logger.debug "API called: Variant#list_all_variants\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
752
+ end
753
+ return data, status_code, headers
754
+ end
755
+ # Replace Variant
756
+ # Replace all attributes of Variant
757
+ # @param variant_id ID of variant to replace
758
+ # @param variant Attributes of variant to replace
759
+ # @param [Hash] opts the optional parameters
760
+ # @return [Variant]
761
+ def replace_variant_by_id(variant_id, variant, opts = {})
762
+ data, _status_code, _headers = replace_variant_by_id_with_http_info(variant_id, variant, opts)
763
+ data
764
+ end
765
+
766
+ # Replace Variant
767
+ # Replace all attributes of Variant
768
+ # @param variant_id ID of variant to replace
769
+ # @param variant Attributes of variant to replace
770
+ # @param [Hash] opts the optional parameters
771
+ # @return [Array<(Variant, Fixnum, Hash)>] Variant data, response status code and response headers
772
+ def replace_variant_by_id_with_http_info(variant_id, variant, opts = {})
773
+ if api_client.config.debugging
774
+ api_client.config.logger.debug 'Calling API: Variant.replace_variant_by_id ...'
775
+ end
776
+ # verify the required parameter 'variant_id' is set
777
+ if api_client.config.client_side_validation && variant_id.nil?
778
+ fail ArgumentError, "Missing the required parameter 'variant_id' when calling Variant.replace_variant_by_id"
779
+ end
780
+ # verify the required parameter 'variant' is set
781
+ if api_client.config.client_side_validation && variant.nil?
782
+ fail ArgumentError, "Missing the required parameter 'variant' when calling Variant.replace_variant_by_id"
783
+ end
784
+ # resource path
785
+ local_var_path = '/variants/{variantId}'.sub('{' + 'variantId' + '}', variant_id.to_s)
786
+
787
+ # query parameters
788
+ query_params = opts
789
+
790
+ # header parameters
791
+ header_params = {}
792
+ # HTTP header 'Accept' (if needed)
793
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
794
+ # HTTP header 'Content-Type'
795
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
796
+
797
+ # form parameters
798
+ form_params = {}
799
+
800
+ # http body (model)
801
+ post_body = api_client.object_to_http_body(variant)
802
+ auth_names = []
803
+ data, status_code, headers = api_client.call_api(:PUT, local_var_path,
804
+ :header_params => header_params,
805
+ :query_params => query_params,
806
+ :form_params => form_params,
807
+ :body => post_body,
808
+ :auth_names => auth_names,
809
+ :return_type => 'Variant')
810
+ if api_client.config.debugging
811
+ api_client.config.logger.debug "API called: Variant#replace_variant_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
812
+ end
813
+ return data, status_code, headers
814
+ end
815
+ # Update Variant
816
+ # Update attributes of Variant
817
+ # @param variant_id ID of variant to update.
818
+ # @param variant Attributes of variant to update.
819
+ # @param [Hash] opts the optional parameters
820
+ # @return [Variant]
821
+ def update_variant_by_id(variant_id, variant, opts = {})
822
+ data, _status_code, _headers = update_variant_by_id_with_http_info(variant_id, variant, opts)
823
+ data
824
+ end
825
+
826
+ # Update Variant
827
+ # Update attributes of Variant
828
+ # @param variant_id ID of variant to update.
829
+ # @param variant Attributes of variant to update.
830
+ # @param [Hash] opts the optional parameters
831
+ # @return [Array<(Variant, Fixnum, Hash)>] Variant data, response status code and response headers
832
+ def update_variant_by_id_with_http_info(variant_id, variant, opts = {})
833
+ if api_client.config.debugging
834
+ api_client.config.logger.debug 'Calling API: Variant.update_variant_by_id ...'
835
+ end
836
+ # verify the required parameter 'variant_id' is set
837
+ if api_client.config.client_side_validation && variant_id.nil?
838
+ fail ArgumentError, "Missing the required parameter 'variant_id' when calling Variant.update_variant_by_id"
839
+ end
840
+ # verify the required parameter 'variant' is set
841
+ if api_client.config.client_side_validation && variant.nil?
842
+ fail ArgumentError, "Missing the required parameter 'variant' when calling Variant.update_variant_by_id"
843
+ end
844
+ # resource path
845
+ local_var_path = '/variants/{variantId}'.sub('{' + 'variantId' + '}', variant_id.to_s)
846
+
847
+ # query parameters
848
+ query_params = opts
849
+
850
+ # header parameters
851
+ header_params = {}
852
+ # HTTP header 'Accept' (if needed)
853
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
854
+ # HTTP header 'Content-Type'
855
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
856
+
857
+ # form parameters
858
+ form_params = {}
859
+
860
+ # http body (model)
861
+ post_body = api_client.object_to_http_body(variant)
862
+ auth_names = []
863
+ data, status_code, headers = api_client.call_api(:PATCH, local_var_path,
864
+ :header_params => header_params,
865
+ :query_params => query_params,
866
+ :form_params => form_params,
867
+ :body => post_body,
868
+ :auth_names => auth_names,
869
+ :return_type => 'Variant')
870
+ if api_client.config.debugging
871
+ api_client.config.logger.debug "API called: Variant#update_variant_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
872
+ end
873
+ return data, status_code, headers
874
+ end
875
+ end
876
+ end
877
+ end