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