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