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,784 @@
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 DiscountPromotion
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 :description
41
+
42
+ attr_accessor :status
43
+
44
+ attr_accessor :begins_at
45
+
46
+ attr_accessor :ends_at
47
+
48
+ attr_accessor :include
49
+
50
+ attr_accessor :type
51
+
52
+ attr_accessor :amount
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
+ :'description' => :'description',
85
+ :'status' => :'status',
86
+ :'begins_at' => :'beginsAt',
87
+ :'ends_at' => :'endsAt',
88
+ :'include' => :'include',
89
+ :'type' => :'type',
90
+ :'amount' => :'amount'
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
+ :'description' => :'String',
103
+ :'status' => :'String',
104
+ :'begins_at' => :'DateTime',
105
+ :'ends_at' => :'DateTime',
106
+ :'include' => :'ItemsSelector',
107
+ :'type' => :'String',
108
+ :'amount' => :'Integer'
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?(:'description')
148
+ self.description = attributes[:'description']
149
+ end
150
+
151
+ if attributes.has_key?(:'status')
152
+ self.status = attributes[:'status']
153
+ end
154
+
155
+ if attributes.has_key?(:'beginsAt')
156
+ self.begins_at = attributes[:'beginsAt']
157
+ end
158
+
159
+ if attributes.has_key?(:'begins_at')
160
+ self.begins_at = attributes[:'begins_at']
161
+ end
162
+
163
+ if attributes.has_key?(:'endsAt')
164
+ self.ends_at = attributes[:'endsAt']
165
+ end
166
+
167
+ if attributes.has_key?(:'ends_at')
168
+ self.ends_at = attributes[:'ends_at']
169
+ end
170
+
171
+ if attributes.has_key?(:'include')
172
+ self.include = attributes[:'include']
173
+ end
174
+
175
+ if attributes.has_key?(:'type')
176
+ self.type = attributes[:'type']
177
+ end
178
+
179
+ if attributes.has_key?(:'amount')
180
+ self.amount = attributes[:'amount']
181
+ end
182
+ end
183
+
184
+ # Show invalid properties with the reasons. Usually used together with valid?
185
+ # @return Array for valid properties with the reasons
186
+ def list_invalid_properties
187
+ invalid_properties = Array.new
188
+ if @name.nil?
189
+ invalid_properties.push('invalid value for "name", name 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
+ if @type.nil?
197
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
198
+ end
199
+
200
+ if @amount.nil?
201
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
202
+ end
203
+
204
+ invalid_properties
205
+ end
206
+
207
+ # Check to see if the all the properties in the model are valid
208
+ # @return true if the model is valid
209
+ def valid?
210
+ return false if @name.nil?
211
+ return false if @status.nil?
212
+ status_validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
213
+ return false unless status_validator.valid?(@status)
214
+ return false if @type.nil?
215
+ type_validator = EnumAttributeValidator.new('String', ['percentage', 'fixedRate'])
216
+ return false unless type_validator.valid?(@type)
217
+ return false if @amount.nil?
218
+ true
219
+ end
220
+
221
+ # Custom attribute writer method checking allowed values (enum).
222
+ # @param [Object] status Object to be assigned
223
+ def status=(status)
224
+ validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
225
+ unless validator.valid?(status)
226
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
227
+ end
228
+ @status = status
229
+ end
230
+
231
+ # Custom attribute writer method checking allowed values (enum).
232
+ # @param [Object] type Object to be assigned
233
+ def type=(type)
234
+ validator = EnumAttributeValidator.new('String', ['percentage', 'fixedRate'])
235
+ unless validator.valid?(type)
236
+ fail ArgumentError, 'invalid value for "type", must be one of #{validator.allowable_values}.'
237
+ end
238
+ @type = type
239
+ end
240
+
241
+ # Checks equality by comparing each attribute.
242
+ # @param [Object] Object to be compared
243
+ def ==(o)
244
+ return true if self.equal?(o)
245
+ self.class == o.class &&
246
+ __meta == o.__meta &&
247
+ created_at == o.created_at &&
248
+ updated_at == o.updated_at &&
249
+ name == o.name &&
250
+ description == o.description &&
251
+ status == o.status &&
252
+ begins_at == o.begins_at &&
253
+ ends_at == o.ends_at &&
254
+ include == o.include &&
255
+ type == o.type &&
256
+ amount == o.amount
257
+ end
258
+
259
+ # @see the `==` method
260
+ # @param [Object] Object to be compared
261
+ def eql?(o)
262
+ self == o
263
+ end
264
+
265
+ # Calculates hash code according to all attributes.
266
+ # @return [Fixnum] Hash code
267
+ def hash
268
+ [__meta, created_at, updated_at, name, description, status, begins_at, ends_at, include, type, amount].hash
269
+ end
270
+
271
+ # Builds the object from hash
272
+ # @param [Hash] attributes Model attributes in the form of hash
273
+ # @return [Object] Returns the model itself
274
+ def build_from_hash(attributes)
275
+ return nil unless attributes.is_a?(Hash)
276
+ self.class.swagger_types.each_pair do |key, type|
277
+ if type =~ /\AArray<(.*)>/i
278
+ # check to ensure the input is an array given that the the attribute
279
+ # is documented as an array but the input is not
280
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
281
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
282
+ end
283
+ elsif !attributes[self.class.attribute_map[key]].nil?
284
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
285
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
286
+ end
287
+
288
+ self
289
+ end
290
+
291
+ # Deserializes the data based on type
292
+ # @param string type Data type
293
+ # @param string value Value to be deserialized
294
+ # @return [Object] Deserialized data
295
+ def _deserialize(type, value)
296
+ case type.to_sym
297
+ when :DateTime
298
+ DateTime.parse(value)
299
+ when :Date
300
+ Date.parse(value)
301
+ when :String
302
+ value.to_s
303
+ when :Integer
304
+ value.to_i
305
+ when :Float
306
+ value.to_f
307
+ when :BOOLEAN
308
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
309
+ true
310
+ else
311
+ false
312
+ end
313
+ when :Object
314
+ # generic object (usually a Hash), return directly
315
+ value
316
+ when /\AArray<(?<inner_type>.+)>\z/
317
+ inner_type = Regexp.last_match[:inner_type]
318
+ value.map { |v| _deserialize(inner_type, v) }
319
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
320
+ k_type = Regexp.last_match[:k_type]
321
+ v_type = Regexp.last_match[:v_type]
322
+ {}.tap do |hash|
323
+ value.each do |k, v|
324
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
325
+ end
326
+ end
327
+ else # model
328
+ temp_model = Tradenity.const_get(type).new
329
+ temp_model.build_from_hash(value)
330
+ end
331
+ end
332
+
333
+ # Returns the string representation of the object
334
+ # @return [String] String presentation of the object
335
+ def to_s
336
+ to_hash.to_s
337
+ end
338
+
339
+ # to_body is an alias to to_hash (backward compatibility)
340
+ # @return [Hash] Returns the object in the form of hash
341
+ def to_body
342
+ to_hash
343
+ end
344
+
345
+ # Returns the object in the form of hash
346
+ # @return [Hash] Returns the object in the form of hash
347
+ def to_hash
348
+ hash = {}
349
+ self.class.attribute_map.each_pair do |attr, param|
350
+ value = self.send(attr)
351
+ next if value.nil?
352
+ hash[param] = _to_hash(value)
353
+ end
354
+ hash
355
+ end
356
+
357
+ # Outputs non-array value in the form of hash
358
+ # For object, use to_hash. Otherwise, just return the value
359
+ # @param [Object] value Any valid value
360
+ # @return [Hash] Returns the value in the form of hash
361
+ def _to_hash(value)
362
+ if value.is_a?(Array)
363
+ value.compact.map { |v| _to_hash(v) }
364
+ elsif value.is_a?(Hash)
365
+ {}.tap do |hash|
366
+ value.each { |k, v| hash[k] = _to_hash(v) }
367
+ end
368
+ elsif value.respond_to? :to_hash
369
+ value.to_hash
370
+ else
371
+ value
372
+ end
373
+ end
374
+
375
+
376
+ def self.api_client
377
+ ApiClient.default
378
+ end
379
+
380
+ # Create DiscountPromotion
381
+ # Create a new DiscountPromotion
382
+ def create
383
+ data = self.class.create_discount_promotion(self)
384
+ self.id = data.id
385
+ data
386
+ end
387
+
388
+ # Update DiscountPromotion
389
+ # Update attributes of DiscountPromotion
390
+ # @return [DiscountPromotion]
391
+ def update
392
+ self.class.update_discount_promotion_by_id(self.id, self)
393
+ end
394
+
395
+ # Delete DiscountPromotion
396
+ # Delete this instance of DiscountPromotion.
397
+ # @return [nil]
398
+ def delete
399
+ self.class.delete_discount_promotion_by_id(self.id)
400
+ end
401
+
402
+ class << self
403
+
404
+ # List DiscountPromotions
405
+ # Return a list of DiscountPromotions
406
+ # @param [Hash] opts the optional parameters
407
+ # @return [Page<DiscountPromotion>]
408
+ def find_all
409
+ list_all_discount_promotions
410
+ end
411
+
412
+ # Find List of DiscountPromotion
413
+ # Return multiple instances of DiscountPromotion by its attributes.
414
+ # @param [Hash] opts the search parameters
415
+ # @return [Page<Collection>]
416
+ def find_all_by(opts = {})
417
+ list_all_discount_promotions(opts)
418
+ end
419
+
420
+ # Find DiscountPromotion by its parameters
421
+ # Return single instance of Collection by its attributes.
422
+ # @param [Hash] opts search parameters
423
+ # @return [DiscountPromotion]
424
+ def find_one_by(opts = {})
425
+ list_all_discount_promotions(opts)[0]
426
+ end
427
+
428
+ # Find DiscountPromotion
429
+ # Return single instance of DiscountPromotion by its ID.
430
+ # @param id ID of DiscountPromotion to return
431
+ # @return [DiscountPromotion]
432
+ def find_by_id(id)
433
+ get_discount_promotion_by_id(id)
434
+ end
435
+
436
+ # Delete DiscountPromotion
437
+ # Delete an instance of DiscountPromotion by its ID.
438
+ # @param id ID of DiscountPromotion to delete.
439
+ # @return [nil]
440
+ def delete_by_id(id)
441
+ delete_discount_promotion_by_id(id)
442
+ end
443
+
444
+ # Create DiscountPromotion
445
+ # Create a new DiscountPromotion
446
+ # @param discount_promotion Attributes of discountPromotion to create
447
+ # @param [Hash] opts the optional parameters
448
+ # @return [DiscountPromotion]
449
+ def create_discount_promotion(discount_promotion, opts = {})
450
+ data, _status_code, _headers = create_discount_promotion_with_http_info(discount_promotion, opts)
451
+ data
452
+ end
453
+
454
+ # Create DiscountPromotion
455
+ # Create a new DiscountPromotion
456
+ # @param discount_promotion Attributes of discountPromotion to create
457
+ # @param [Hash] opts the optional parameters
458
+ # @return [Array<(DiscountPromotion, Fixnum, Hash)>] DiscountPromotion data, response status code and response headers
459
+ def create_discount_promotion_with_http_info(discount_promotion, opts = {})
460
+ if api_client.config.debugging
461
+ api_client.config.logger.debug 'Calling API: DiscountPromotion.create_discount_promotion ...'
462
+ end
463
+ # verify the required parameter 'discount_promotion' is set
464
+ if api_client.config.client_side_validation && discount_promotion.nil?
465
+ fail ArgumentError, "Missing the required parameter 'discount_promotion' when calling DiscountPromotion.create_discount_promotion"
466
+ end
467
+ # resource path
468
+ local_var_path = '/discountPromotions'
469
+
470
+ # query parameters
471
+ query_params = opts
472
+
473
+ # header parameters
474
+ header_params = {}
475
+ # HTTP header 'Accept' (if needed)
476
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
477
+ # HTTP header 'Content-Type'
478
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
479
+
480
+ # form parameters
481
+ form_params = {}
482
+
483
+ # http body (model)
484
+ post_body = api_client.object_to_http_body(discount_promotion)
485
+ auth_names = []
486
+ data, status_code, headers = api_client.call_api(:POST, local_var_path,
487
+ :header_params => header_params,
488
+ :query_params => query_params,
489
+ :form_params => form_params,
490
+ :body => post_body,
491
+ :auth_names => auth_names,
492
+ :return_type => 'DiscountPromotion')
493
+ if api_client.config.debugging
494
+ api_client.config.logger.debug "API called: DiscountPromotion#create_discount_promotion\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
495
+ end
496
+ return data, status_code, headers
497
+ end
498
+ # Delete DiscountPromotion
499
+ # Delete an instance of DiscountPromotion by its ID.
500
+ # @param discount_promotion_id ID of discountPromotion to delete.
501
+ # @param [Hash] opts the optional parameters
502
+ # @return [nil]
503
+ def delete_discount_promotion_by_id(discount_promotion_id, opts = {})
504
+ delete_discount_promotion_by_id_with_http_info(discount_promotion_id, opts)
505
+ nil
506
+ end
507
+
508
+ # Delete DiscountPromotion
509
+ # Delete an instance of DiscountPromotion by its ID.
510
+ # @param discount_promotion_id ID of discountPromotion to delete.
511
+ # @param [Hash] opts the optional parameters
512
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
513
+ def delete_discount_promotion_by_id_with_http_info(discount_promotion_id, opts = {})
514
+ if api_client.config.debugging
515
+ api_client.config.logger.debug 'Calling API: DiscountPromotion.delete_discount_promotion_by_id ...'
516
+ end
517
+ # verify the required parameter 'discount_promotion_id' is set
518
+ if api_client.config.client_side_validation && discount_promotion_id.nil?
519
+ fail ArgumentError, "Missing the required parameter 'discount_promotion_id' when calling DiscountPromotion.delete_discount_promotion_by_id"
520
+ end
521
+ # resource path
522
+ local_var_path = '/discountPromotions/{discountPromotionId}'.sub('{' + 'discountPromotionId' + '}', discount_promotion_id.to_s)
523
+
524
+ # query parameters
525
+ query_params = opts
526
+
527
+ # header parameters
528
+ header_params = {}
529
+ # HTTP header 'Accept' (if needed)
530
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
531
+ # HTTP header 'Content-Type'
532
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
533
+
534
+ # form parameters
535
+ form_params = {}
536
+
537
+ # http body (model)
538
+ post_body = nil
539
+ auth_names = []
540
+ data, status_code, headers = api_client.call_api(:DELETE, local_var_path,
541
+ :header_params => header_params,
542
+ :query_params => query_params,
543
+ :form_params => form_params,
544
+ :body => post_body,
545
+ :auth_names => auth_names)
546
+ if api_client.config.debugging
547
+ api_client.config.logger.debug "API called: DiscountPromotion#delete_discount_promotion_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
548
+ end
549
+ return data, status_code, headers
550
+ end
551
+ # Find DiscountPromotion
552
+ # Return single instance of DiscountPromotion by its ID.
553
+ # @param discount_promotion_id ID of discountPromotion to return
554
+ # @param [Hash] opts the optional parameters
555
+ # @return [DiscountPromotion]
556
+ def get_discount_promotion_by_id(discount_promotion_id, opts = {})
557
+ data, _status_code, _headers = get_discount_promotion_by_id_with_http_info(discount_promotion_id, opts)
558
+ data
559
+ end
560
+
561
+ # Find DiscountPromotion
562
+ # Return single instance of DiscountPromotion by its ID.
563
+ # @param discount_promotion_id ID of discountPromotion to return
564
+ # @param [Hash] opts the optional parameters
565
+ # @return [Array<(DiscountPromotion, Fixnum, Hash)>] DiscountPromotion data, response status code and response headers
566
+ def get_discount_promotion_by_id_with_http_info(discount_promotion_id, opts = {})
567
+ if api_client.config.debugging
568
+ api_client.config.logger.debug 'Calling API: DiscountPromotion.get_discount_promotion_by_id ...'
569
+ end
570
+ # verify the required parameter 'discount_promotion_id' is set
571
+ if api_client.config.client_side_validation && discount_promotion_id.nil?
572
+ fail ArgumentError, "Missing the required parameter 'discount_promotion_id' when calling DiscountPromotion.get_discount_promotion_by_id"
573
+ end
574
+ # resource path
575
+ local_var_path = '/discountPromotions/{discountPromotionId}'.sub('{' + 'discountPromotionId' + '}', discount_promotion_id.to_s)
576
+
577
+ # query parameters
578
+ query_params = opts
579
+
580
+ # header parameters
581
+ header_params = {}
582
+ # HTTP header 'Accept' (if needed)
583
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
584
+ # HTTP header 'Content-Type'
585
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
586
+
587
+ # form parameters
588
+ form_params = {}
589
+
590
+ # http body (model)
591
+ post_body = nil
592
+ auth_names = []
593
+ data, status_code, headers = api_client.call_api(:GET, local_var_path,
594
+ :header_params => header_params,
595
+ :query_params => query_params,
596
+ :form_params => form_params,
597
+ :body => post_body,
598
+ :auth_names => auth_names,
599
+ :return_type => 'DiscountPromotion')
600
+ if api_client.config.debugging
601
+ api_client.config.logger.debug "API called: DiscountPromotion#get_discount_promotion_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
602
+ end
603
+ return data, status_code, headers
604
+ end
605
+ # List DiscountPromotions
606
+ # Return a list of DiscountPromotions
607
+ # @param [Hash] opts the optional parameters
608
+ # @option opts [Integer] :page page number
609
+ # @option opts [Integer] :size page size
610
+ # @option opts [String] :sort page order
611
+ # @return [Page<DiscountPromotion>]
612
+ def list_all_discount_promotions(opts = {})
613
+ data, _status_code, _headers = list_all_discount_promotions_with_http_info(opts)
614
+ data
615
+ end
616
+
617
+ # List DiscountPromotions
618
+ # Return a list of DiscountPromotions
619
+ # @param [Hash] opts the optional parameters
620
+ # @option opts [Integer] :page page number
621
+ # @option opts [Integer] :size page size
622
+ # @option opts [String] :sort page order
623
+ # @return [Array<(Page<DiscountPromotion>, Fixnum, Hash)>] Page<DiscountPromotion> data, response status code and response headers
624
+ def list_all_discount_promotions_with_http_info(opts = {})
625
+ if api_client.config.debugging
626
+ api_client.config.logger.debug 'Calling API: DiscountPromotion.list_all_discount_promotions ...'
627
+ end
628
+ # resource path
629
+ local_var_path = '/discountPromotions'
630
+
631
+ # query parameters
632
+ query_params = opts
633
+ # query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
634
+ # query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
635
+ # query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
636
+
637
+ # header parameters
638
+ header_params = {}
639
+ # HTTP header 'Accept' (if needed)
640
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
641
+ # HTTP header 'Content-Type'
642
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
643
+
644
+ # form parameters
645
+ form_params = {}
646
+
647
+ # http body (model)
648
+ post_body = nil
649
+ auth_names = []
650
+ data, status_code, headers = api_client.call_api(:GET, local_var_path,
651
+ :header_params => header_params,
652
+ :query_params => query_params,
653
+ :form_params => form_params,
654
+ :body => post_body,
655
+ :auth_names => auth_names,
656
+ :return_type => 'Page<DiscountPromotion>')
657
+ if api_client.config.debugging
658
+ api_client.config.logger.debug "API called: DiscountPromotion#list_all_discount_promotions\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
659
+ end
660
+ return data, status_code, headers
661
+ end
662
+ # Replace DiscountPromotion
663
+ # Replace all attributes of DiscountPromotion
664
+ # @param discount_promotion_id ID of discountPromotion to replace
665
+ # @param discount_promotion Attributes of discountPromotion to replace
666
+ # @param [Hash] opts the optional parameters
667
+ # @return [DiscountPromotion]
668
+ def replace_discount_promotion_by_id(discount_promotion_id, discount_promotion, opts = {})
669
+ data, _status_code, _headers = replace_discount_promotion_by_id_with_http_info(discount_promotion_id, discount_promotion, opts)
670
+ data
671
+ end
672
+
673
+ # Replace DiscountPromotion
674
+ # Replace all attributes of DiscountPromotion
675
+ # @param discount_promotion_id ID of discountPromotion to replace
676
+ # @param discount_promotion Attributes of discountPromotion to replace
677
+ # @param [Hash] opts the optional parameters
678
+ # @return [Array<(DiscountPromotion, Fixnum, Hash)>] DiscountPromotion data, response status code and response headers
679
+ def replace_discount_promotion_by_id_with_http_info(discount_promotion_id, discount_promotion, opts = {})
680
+ if api_client.config.debugging
681
+ api_client.config.logger.debug 'Calling API: DiscountPromotion.replace_discount_promotion_by_id ...'
682
+ end
683
+ # verify the required parameter 'discount_promotion_id' is set
684
+ if api_client.config.client_side_validation && discount_promotion_id.nil?
685
+ fail ArgumentError, "Missing the required parameter 'discount_promotion_id' when calling DiscountPromotion.replace_discount_promotion_by_id"
686
+ end
687
+ # verify the required parameter 'discount_promotion' is set
688
+ if api_client.config.client_side_validation && discount_promotion.nil?
689
+ fail ArgumentError, "Missing the required parameter 'discount_promotion' when calling DiscountPromotion.replace_discount_promotion_by_id"
690
+ end
691
+ # resource path
692
+ local_var_path = '/discountPromotions/{discountPromotionId}'.sub('{' + 'discountPromotionId' + '}', discount_promotion_id.to_s)
693
+
694
+ # query parameters
695
+ query_params = opts
696
+
697
+ # header parameters
698
+ header_params = {}
699
+ # HTTP header 'Accept' (if needed)
700
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
701
+ # HTTP header 'Content-Type'
702
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
703
+
704
+ # form parameters
705
+ form_params = {}
706
+
707
+ # http body (model)
708
+ post_body = api_client.object_to_http_body(discount_promotion)
709
+ auth_names = []
710
+ data, status_code, headers = api_client.call_api(:PUT, local_var_path,
711
+ :header_params => header_params,
712
+ :query_params => query_params,
713
+ :form_params => form_params,
714
+ :body => post_body,
715
+ :auth_names => auth_names,
716
+ :return_type => 'DiscountPromotion')
717
+ if api_client.config.debugging
718
+ api_client.config.logger.debug "API called: DiscountPromotion#replace_discount_promotion_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
719
+ end
720
+ return data, status_code, headers
721
+ end
722
+ # Update DiscountPromotion
723
+ # Update attributes of DiscountPromotion
724
+ # @param discount_promotion_id ID of discountPromotion to update.
725
+ # @param discount_promotion Attributes of discountPromotion to update.
726
+ # @param [Hash] opts the optional parameters
727
+ # @return [DiscountPromotion]
728
+ def update_discount_promotion_by_id(discount_promotion_id, discount_promotion, opts = {})
729
+ data, _status_code, _headers = update_discount_promotion_by_id_with_http_info(discount_promotion_id, discount_promotion, opts)
730
+ data
731
+ end
732
+
733
+ # Update DiscountPromotion
734
+ # Update attributes of DiscountPromotion
735
+ # @param discount_promotion_id ID of discountPromotion to update.
736
+ # @param discount_promotion Attributes of discountPromotion to update.
737
+ # @param [Hash] opts the optional parameters
738
+ # @return [Array<(DiscountPromotion, Fixnum, Hash)>] DiscountPromotion data, response status code and response headers
739
+ def update_discount_promotion_by_id_with_http_info(discount_promotion_id, discount_promotion, opts = {})
740
+ if api_client.config.debugging
741
+ api_client.config.logger.debug 'Calling API: DiscountPromotion.update_discount_promotion_by_id ...'
742
+ end
743
+ # verify the required parameter 'discount_promotion_id' is set
744
+ if api_client.config.client_side_validation && discount_promotion_id.nil?
745
+ fail ArgumentError, "Missing the required parameter 'discount_promotion_id' when calling DiscountPromotion.update_discount_promotion_by_id"
746
+ end
747
+ # verify the required parameter 'discount_promotion' is set
748
+ if api_client.config.client_side_validation && discount_promotion.nil?
749
+ fail ArgumentError, "Missing the required parameter 'discount_promotion' when calling DiscountPromotion.update_discount_promotion_by_id"
750
+ end
751
+ # resource path
752
+ local_var_path = '/discountPromotions/{discountPromotionId}'.sub('{' + 'discountPromotionId' + '}', discount_promotion_id.to_s)
753
+
754
+ # query parameters
755
+ query_params = opts
756
+
757
+ # header parameters
758
+ header_params = {}
759
+ # HTTP header 'Accept' (if needed)
760
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
761
+ # HTTP header 'Content-Type'
762
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
763
+
764
+ # form parameters
765
+ form_params = {}
766
+
767
+ # http body (model)
768
+ post_body = api_client.object_to_http_body(discount_promotion)
769
+ auth_names = []
770
+ data, status_code, headers = api_client.call_api(:PATCH, local_var_path,
771
+ :header_params => header_params,
772
+ :query_params => query_params,
773
+ :form_params => form_params,
774
+ :body => post_body,
775
+ :auth_names => auth_names,
776
+ :return_type => 'DiscountPromotion')
777
+ if api_client.config.debugging
778
+ api_client.config.logger.debug "API called: DiscountPromotion#update_discount_promotion_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
779
+ end
780
+ return data, status_code, headers
781
+ end
782
+ end
783
+ end
784
+ end