tradenity 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +7 -0
- data/README.md +89 -77
- data/lib/tradenity/api_client.rb +408 -0
- data/lib/tradenity/api_error.rb +36 -0
- data/lib/tradenity/configuration.rb +205 -0
- data/lib/tradenity/exceptions.rb +5 -0
- data/lib/tradenity/rails/railtie.rb +20 -20
- data/lib/tradenity/resources/address.rb +729 -0
- data/lib/tradenity/resources/braintree_gateway.rb +804 -0
- data/lib/tradenity/resources/brand.rb +732 -0
- data/lib/tradenity/resources/cancel_operation.rb +675 -0
- data/lib/tradenity/resources/cart_settings.rb +219 -0
- data/lib/tradenity/resources/cash_on_delivery_payment.rb +746 -0
- data/lib/tradenity/resources/category.rb +763 -0
- data/lib/tradenity/resources/collection.rb +734 -0
- data/lib/tradenity/resources/contact_info.rb +306 -0
- data/lib/tradenity/resources/countries_geo_zone.rb +739 -0
- data/lib/tradenity/resources/country.rb +803 -0
- data/lib/tradenity/resources/coupon.rb +454 -0
- data/lib/tradenity/resources/credit_card_payment.rb +803 -0
- data/lib/tradenity/resources/currency.rb +762 -0
- data/lib/tradenity/resources/customer.rb +816 -0
- data/lib/tradenity/resources/customer_group.rb +723 -0
- data/lib/tradenity/resources/dimensions.rb +263 -0
- data/lib/tradenity/resources/discount_coupon.rb +811 -0
- data/lib/tradenity/resources/discount_promotion.rb +784 -0
- data/lib/tradenity/resources/fixed_rate_shipping.rb +837 -0
- data/lib/tradenity/resources/free_item_coupon.rb +793 -0
- data/lib/tradenity/resources/free_shipping.rb +806 -0
- data/lib/tradenity/resources/free_shipping_coupon.rb +788 -0
- data/lib/tradenity/resources/free_shipping_promotion.rb +744 -0
- data/lib/tradenity/resources/gateway.rb +435 -0
- data/lib/tradenity/resources/general_settings.rb +206 -0
- data/lib/tradenity/resources/geo_zone.rb +406 -0
- data/lib/tradenity/resources/instance_meta.rb +182 -0
- data/lib/tradenity/resources/inventory_settings.rb +197 -0
- data/lib/tradenity/resources/items_selector.rb +270 -0
- data/lib/tradenity/resources/line_item.rb +347 -0
- data/lib/tradenity/resources/mail_server_settings.rb +221 -0
- data/lib/tradenity/resources/measurement_settings.rb +253 -0
- data/lib/tradenity/resources/option.rb +787 -0
- data/lib/tradenity/resources/option_set.rb +734 -0
- data/lib/tradenity/resources/option_value.rb +680 -0
- data/lib/tradenity/resources/order.rb +929 -0
- data/lib/tradenity/resources/order_line_item.rb +777 -0
- data/lib/tradenity/resources/paging.rb +38 -0
- data/lib/tradenity/resources/payment.rb +429 -0
- data/lib/tradenity/resources/payment_card.rb +847 -0
- data/lib/tradenity/resources/payment_settings.rb +201 -0
- data/lib/tradenity/resources/payment_source.rb +392 -0
- data/lib/tradenity/resources/payment_token.rb +723 -0
- data/lib/tradenity/resources/payment_transaction.rb +740 -0
- data/lib/tradenity/resources/photo.rb +341 -0
- data/lib/tradenity/resources/product.rb +1156 -0
- data/lib/tradenity/resources/promotion.rb +427 -0
- data/lib/tradenity/resources/refund_operation.rb +358 -0
- data/lib/tradenity/resources/refund_transaction.rb +730 -0
- data/lib/tradenity/resources/return_line_item.rb +781 -0
- data/lib/tradenity/resources/return_operation.rb +686 -0
- data/lib/tradenity/resources/return_settings.rb +255 -0
- data/lib/tradenity/resources/shipping_method.rb +530 -0
- data/lib/tradenity/resources/shopping_cart.rb +647 -0
- data/lib/tradenity/resources/state.rb +675 -0
- data/lib/tradenity/resources/states_geo_zone.rb +748 -0
- data/lib/tradenity/resources/store_credit.rb +686 -0
- data/lib/tradenity/resources/store_credit_payment.rb +764 -0
- data/lib/tradenity/resources/store_credit_transaction.rb +730 -0
- data/lib/tradenity/resources/store_profile.rb +532 -0
- data/lib/tradenity/resources/stripe_gateway.rb +804 -0
- data/lib/tradenity/resources/table_rate_rule.rb +712 -0
- data/lib/tradenity/resources/table_rate_shipping.rb +834 -0
- data/lib/tradenity/resources/tax_class.rb +723 -0
- data/lib/tradenity/resources/tax_rate.rb +845 -0
- data/lib/tradenity/resources/tax_settings.rb +231 -0
- data/lib/tradenity/resources/test_gateway.rb +804 -0
- data/lib/tradenity/resources/transaction.rb +523 -0
- data/lib/tradenity/resources/utils.rb +7 -0
- data/lib/tradenity/resources/variant.rb +877 -0
- data/lib/tradenity/resources/web_hooks.rb +262 -0
- data/lib/tradenity/resources/weight.rb +235 -0
- data/lib/tradenity/resources/wish_list.rb +686 -0
- data/lib/tradenity/resources/zip_codes_geo_zone.rb +755 -0
- data/lib/tradenity/token_holder.rb +22 -0
- data/lib/tradenity/version.rb +13 -3
- data/lib/tradenity.rb +117 -7
- data/tradenity.gemspec +35 -30
- metadata +200 -34
- data/lib/tradenity/api.rb +0 -17
- data/lib/tradenity/error/exceptions.rb +0 -52
- data/lib/tradenity/error/message.rb +0 -38
- data/lib/tradenity/http/client.rb +0 -130
- data/lib/tradenity/model/base.rb +0 -100
- data/lib/tradenity/model/entities.rb +0 -390
- data/lib/tradenity/model/paging.rb +0 -23
@@ -0,0 +1,1156 @@
|
|
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 Product
|
15
|
+
|
16
|
+
|
17
|
+
def id=(id)
|
18
|
+
@id = id
|
19
|
+
end
|
20
|
+
|
21
|
+
def id
|
22
|
+
if instance_variable_defined?('@id') && @id != nil
|
23
|
+
@id
|
24
|
+
elsif __meta && __meta.href != nil
|
25
|
+
@id = __meta.href.split('/')[-1]
|
26
|
+
@id
|
27
|
+
else
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
attr_accessor :__meta
|
33
|
+
|
34
|
+
attr_accessor :created_at
|
35
|
+
|
36
|
+
attr_accessor :updated_at
|
37
|
+
|
38
|
+
attr_accessor :name
|
39
|
+
|
40
|
+
attr_accessor :slug
|
41
|
+
|
42
|
+
attr_accessor :model
|
43
|
+
|
44
|
+
attr_accessor :status
|
45
|
+
|
46
|
+
attr_accessor :type
|
47
|
+
|
48
|
+
attr_accessor :short_description
|
49
|
+
|
50
|
+
attr_accessor :full_description
|
51
|
+
|
52
|
+
attr_accessor :free_shipping
|
53
|
+
|
54
|
+
attr_accessor :sku
|
55
|
+
|
56
|
+
attr_accessor :price
|
57
|
+
|
58
|
+
attr_accessor :cost_price
|
59
|
+
|
60
|
+
attr_accessor :retail_price
|
61
|
+
|
62
|
+
attr_accessor :sale_price
|
63
|
+
|
64
|
+
attr_accessor :manage_inventory
|
65
|
+
|
66
|
+
attr_accessor :stock_level
|
67
|
+
|
68
|
+
attr_accessor :minimum_stock_level
|
69
|
+
|
70
|
+
attr_accessor :maximum_sell_count
|
71
|
+
|
72
|
+
attr_accessor :item_dimensions
|
73
|
+
|
74
|
+
attr_accessor :package_dimensions
|
75
|
+
|
76
|
+
attr_accessor :package_weight
|
77
|
+
|
78
|
+
attr_accessor :require_shipping
|
79
|
+
|
80
|
+
attr_accessor :availability
|
81
|
+
|
82
|
+
attr_accessor :availability_date
|
83
|
+
|
84
|
+
attr_accessor :allow_pre_order
|
85
|
+
|
86
|
+
attr_accessor :brand
|
87
|
+
|
88
|
+
attr_accessor :main_photo
|
89
|
+
|
90
|
+
attr_accessor :photos
|
91
|
+
|
92
|
+
attr_accessor :files
|
93
|
+
|
94
|
+
attr_accessor :promotions
|
95
|
+
|
96
|
+
attr_accessor :related_products
|
97
|
+
|
98
|
+
attr_accessor :stock_status
|
99
|
+
|
100
|
+
attr_accessor :categories
|
101
|
+
|
102
|
+
attr_accessor :tax_class
|
103
|
+
|
104
|
+
attr_accessor :option_set
|
105
|
+
|
106
|
+
attr_accessor :variants
|
107
|
+
|
108
|
+
class EnumAttributeValidator
|
109
|
+
attr_reader :datatype
|
110
|
+
attr_reader :allowable_values
|
111
|
+
|
112
|
+
def initialize(datatype, allowable_values)
|
113
|
+
@allowable_values = allowable_values.map do |value|
|
114
|
+
case datatype.to_s
|
115
|
+
when /Integer/i
|
116
|
+
value.to_i
|
117
|
+
when /Float/i
|
118
|
+
value.to_f
|
119
|
+
else
|
120
|
+
value
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def valid?(value)
|
126
|
+
!value || allowable_values.include?(value)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
131
|
+
def self.attribute_map
|
132
|
+
{
|
133
|
+
:'id' => :'id',
|
134
|
+
:'__meta' => :'__meta',
|
135
|
+
:'created_at' => :'createdAt',
|
136
|
+
:'updated_at' => :'updatedAt',
|
137
|
+
:'name' => :'name',
|
138
|
+
:'slug' => :'slug',
|
139
|
+
:'model' => :'model',
|
140
|
+
:'status' => :'status',
|
141
|
+
:'type' => :'type',
|
142
|
+
:'short_description' => :'shortDescription',
|
143
|
+
:'full_description' => :'fullDescription',
|
144
|
+
:'free_shipping' => :'freeShipping',
|
145
|
+
:'sku' => :'sku',
|
146
|
+
:'price' => :'price',
|
147
|
+
:'cost_price' => :'costPrice',
|
148
|
+
:'retail_price' => :'retailPrice',
|
149
|
+
:'sale_price' => :'salePrice',
|
150
|
+
:'manage_inventory' => :'manageInventory',
|
151
|
+
:'stock_level' => :'stockLevel',
|
152
|
+
:'minimum_stock_level' => :'minimumStockLevel',
|
153
|
+
:'maximum_sell_count' => :'maximumSellCount',
|
154
|
+
:'item_dimensions' => :'itemDimensions',
|
155
|
+
:'package_dimensions' => :'packageDimensions',
|
156
|
+
:'package_weight' => :'packageWeight',
|
157
|
+
:'require_shipping' => :'requireShipping',
|
158
|
+
:'availability' => :'availability',
|
159
|
+
:'availability_date' => :'availabilityDate',
|
160
|
+
:'allow_pre_order' => :'allowPreOrder',
|
161
|
+
:'brand' => :'brand',
|
162
|
+
:'main_photo' => :'mainPhoto',
|
163
|
+
:'photos' => :'photos',
|
164
|
+
:'files' => :'files',
|
165
|
+
:'promotions' => :'promotions',
|
166
|
+
:'related_products' => :'relatedProducts',
|
167
|
+
:'stock_status' => :'stockStatus',
|
168
|
+
:'categories' => :'categories',
|
169
|
+
:'tax_class' => :'taxClass',
|
170
|
+
:'option_set' => :'optionSet',
|
171
|
+
:'variants' => :'variants'
|
172
|
+
}
|
173
|
+
end
|
174
|
+
|
175
|
+
# Attribute type mapping.
|
176
|
+
def self.swagger_types
|
177
|
+
{
|
178
|
+
:'id' => :'String',
|
179
|
+
:'__meta' => :'InstanceMeta',
|
180
|
+
:'created_at' => :'DateTime',
|
181
|
+
:'updated_at' => :'DateTime',
|
182
|
+
:'name' => :'String',
|
183
|
+
:'slug' => :'String',
|
184
|
+
:'model' => :'String',
|
185
|
+
:'status' => :'String',
|
186
|
+
:'type' => :'String',
|
187
|
+
:'short_description' => :'String',
|
188
|
+
:'full_description' => :'String',
|
189
|
+
:'free_shipping' => :'BOOLEAN',
|
190
|
+
:'sku' => :'String',
|
191
|
+
:'price' => :'Integer',
|
192
|
+
:'cost_price' => :'Integer',
|
193
|
+
:'retail_price' => :'Integer',
|
194
|
+
:'sale_price' => :'Integer',
|
195
|
+
:'manage_inventory' => :'BOOLEAN',
|
196
|
+
:'stock_level' => :'Integer',
|
197
|
+
:'minimum_stock_level' => :'Integer',
|
198
|
+
:'maximum_sell_count' => :'Integer',
|
199
|
+
:'item_dimensions' => :'Dimensions',
|
200
|
+
:'package_dimensions' => :'Dimensions',
|
201
|
+
:'package_weight' => :'Weight',
|
202
|
+
:'require_shipping' => :'BOOLEAN',
|
203
|
+
:'availability' => :'String',
|
204
|
+
:'availability_date' => :'Date',
|
205
|
+
:'allow_pre_order' => :'BOOLEAN',
|
206
|
+
:'brand' => :'Brand',
|
207
|
+
:'main_photo' => :'Photo',
|
208
|
+
:'photos' => :'Array<Photo>',
|
209
|
+
:'files' => :'Array<StorageFile>',
|
210
|
+
:'promotions' => :'Array<Promotion>',
|
211
|
+
:'related_products' => :'Array<Product>',
|
212
|
+
:'stock_status' => :'String',
|
213
|
+
:'categories' => :'Array<Category>',
|
214
|
+
:'tax_class' => :'TaxClass',
|
215
|
+
:'option_set' => :'OptionSet',
|
216
|
+
:'variants' => :'Array<Variant>'
|
217
|
+
}
|
218
|
+
end
|
219
|
+
|
220
|
+
# Initializes the object
|
221
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
222
|
+
def initialize(attributes = {})
|
223
|
+
return unless attributes.is_a?(Hash)
|
224
|
+
|
225
|
+
# convert string to symbol for hash key
|
226
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
227
|
+
if attributes.has_key?(:'id')
|
228
|
+
self.id = attributes[:'id']
|
229
|
+
end
|
230
|
+
|
231
|
+
if attributes.has_key?(:'__meta')
|
232
|
+
self.__meta = attributes[:'__meta']
|
233
|
+
end
|
234
|
+
|
235
|
+
if attributes.has_key?(:'createdAt')
|
236
|
+
self.created_at = attributes[:'createdAt']
|
237
|
+
end
|
238
|
+
|
239
|
+
if attributes.has_key?(:'created_at')
|
240
|
+
self.created_at = attributes[:'created_at']
|
241
|
+
end
|
242
|
+
|
243
|
+
if attributes.has_key?(:'updatedAt')
|
244
|
+
self.updated_at = attributes[:'updatedAt']
|
245
|
+
end
|
246
|
+
|
247
|
+
if attributes.has_key?(:'updated_at')
|
248
|
+
self.updated_at = attributes[:'updated_at']
|
249
|
+
end
|
250
|
+
|
251
|
+
if attributes.has_key?(:'name')
|
252
|
+
self.name = attributes[:'name']
|
253
|
+
end
|
254
|
+
|
255
|
+
if attributes.has_key?(:'slug')
|
256
|
+
self.slug = attributes[:'slug']
|
257
|
+
end
|
258
|
+
|
259
|
+
if attributes.has_key?(:'model')
|
260
|
+
self.model = attributes[:'model']
|
261
|
+
end
|
262
|
+
|
263
|
+
if attributes.has_key?(:'status')
|
264
|
+
self.status = attributes[:'status']
|
265
|
+
end
|
266
|
+
|
267
|
+
if attributes.has_key?(:'type')
|
268
|
+
self.type = attributes[:'type']
|
269
|
+
end
|
270
|
+
|
271
|
+
if attributes.has_key?(:'shortDescription')
|
272
|
+
self.short_description = attributes[:'shortDescription']
|
273
|
+
end
|
274
|
+
|
275
|
+
if attributes.has_key?(:'short_description')
|
276
|
+
self.short_description = attributes[:'short_description']
|
277
|
+
end
|
278
|
+
|
279
|
+
if attributes.has_key?(:'fullDescription')
|
280
|
+
self.full_description = attributes[:'fullDescription']
|
281
|
+
end
|
282
|
+
|
283
|
+
if attributes.has_key?(:'full_description')
|
284
|
+
self.full_description = attributes[:'full_description']
|
285
|
+
end
|
286
|
+
|
287
|
+
if attributes.has_key?(:'freeShipping')
|
288
|
+
self.free_shipping = attributes[:'freeShipping']
|
289
|
+
end
|
290
|
+
|
291
|
+
if attributes.has_key?(:'free_shipping')
|
292
|
+
self.free_shipping = attributes[:'free_shipping']
|
293
|
+
end
|
294
|
+
|
295
|
+
if attributes.has_key?(:'sku')
|
296
|
+
self.sku = attributes[:'sku']
|
297
|
+
end
|
298
|
+
|
299
|
+
if attributes.has_key?(:'price')
|
300
|
+
self.price = attributes[:'price']
|
301
|
+
end
|
302
|
+
|
303
|
+
if attributes.has_key?(:'costPrice')
|
304
|
+
self.cost_price = attributes[:'costPrice']
|
305
|
+
end
|
306
|
+
|
307
|
+
if attributes.has_key?(:'cost_price')
|
308
|
+
self.cost_price = attributes[:'cost_price']
|
309
|
+
end
|
310
|
+
|
311
|
+
if attributes.has_key?(:'retailPrice')
|
312
|
+
self.retail_price = attributes[:'retailPrice']
|
313
|
+
end
|
314
|
+
|
315
|
+
if attributes.has_key?(:'retail_price')
|
316
|
+
self.retail_price = attributes[:'retail_price']
|
317
|
+
end
|
318
|
+
|
319
|
+
if attributes.has_key?(:'salePrice')
|
320
|
+
self.sale_price = attributes[:'salePrice']
|
321
|
+
end
|
322
|
+
|
323
|
+
if attributes.has_key?(:'sale_price')
|
324
|
+
self.sale_price = attributes[:'sale_price']
|
325
|
+
end
|
326
|
+
|
327
|
+
if attributes.has_key?(:'manageInventory')
|
328
|
+
self.manage_inventory = attributes[:'manageInventory']
|
329
|
+
end
|
330
|
+
|
331
|
+
if attributes.has_key?(:'manage_inventory')
|
332
|
+
self.manage_inventory = attributes[:'manage_inventory']
|
333
|
+
end
|
334
|
+
|
335
|
+
if attributes.has_key?(:'stockLevel')
|
336
|
+
self.stock_level = attributes[:'stockLevel']
|
337
|
+
end
|
338
|
+
|
339
|
+
if attributes.has_key?(:'stock_level')
|
340
|
+
self.stock_level = attributes[:'stock_level']
|
341
|
+
end
|
342
|
+
|
343
|
+
if attributes.has_key?(:'minimumStockLevel')
|
344
|
+
self.minimum_stock_level = attributes[:'minimumStockLevel']
|
345
|
+
end
|
346
|
+
|
347
|
+
if attributes.has_key?(:'minimum_stock_level')
|
348
|
+
self.minimum_stock_level = attributes[:'minimum_stock_level']
|
349
|
+
end
|
350
|
+
|
351
|
+
if attributes.has_key?(:'maximumSellCount')
|
352
|
+
self.maximum_sell_count = attributes[:'maximumSellCount']
|
353
|
+
end
|
354
|
+
|
355
|
+
if attributes.has_key?(:'maximum_sell_count')
|
356
|
+
self.maximum_sell_count = attributes[:'maximum_sell_count']
|
357
|
+
end
|
358
|
+
|
359
|
+
if attributes.has_key?(:'itemDimensions')
|
360
|
+
self.item_dimensions = attributes[:'itemDimensions']
|
361
|
+
end
|
362
|
+
|
363
|
+
if attributes.has_key?(:'item_dimensions')
|
364
|
+
self.item_dimensions = attributes[:'item_dimensions']
|
365
|
+
end
|
366
|
+
|
367
|
+
if attributes.has_key?(:'packageDimensions')
|
368
|
+
self.package_dimensions = attributes[:'packageDimensions']
|
369
|
+
end
|
370
|
+
|
371
|
+
if attributes.has_key?(:'package_dimensions')
|
372
|
+
self.package_dimensions = attributes[:'package_dimensions']
|
373
|
+
end
|
374
|
+
|
375
|
+
if attributes.has_key?(:'packageWeight')
|
376
|
+
self.package_weight = attributes[:'packageWeight']
|
377
|
+
end
|
378
|
+
|
379
|
+
if attributes.has_key?(:'package_weight')
|
380
|
+
self.package_weight = attributes[:'package_weight']
|
381
|
+
end
|
382
|
+
|
383
|
+
if attributes.has_key?(:'requireShipping')
|
384
|
+
self.require_shipping = attributes[:'requireShipping']
|
385
|
+
end
|
386
|
+
|
387
|
+
if attributes.has_key?(:'require_shipping')
|
388
|
+
self.require_shipping = attributes[:'require_shipping']
|
389
|
+
end
|
390
|
+
|
391
|
+
if attributes.has_key?(:'availability')
|
392
|
+
self.availability = attributes[:'availability']
|
393
|
+
end
|
394
|
+
|
395
|
+
if attributes.has_key?(:'availabilityDate')
|
396
|
+
self.availability_date = attributes[:'availabilityDate']
|
397
|
+
end
|
398
|
+
|
399
|
+
if attributes.has_key?(:'availability_date')
|
400
|
+
self.availability_date = attributes[:'availability_date']
|
401
|
+
end
|
402
|
+
|
403
|
+
if attributes.has_key?(:'allowPreOrder')
|
404
|
+
self.allow_pre_order = attributes[:'allowPreOrder']
|
405
|
+
end
|
406
|
+
|
407
|
+
if attributes.has_key?(:'allow_pre_order')
|
408
|
+
self.allow_pre_order = attributes[:'allow_pre_order']
|
409
|
+
end
|
410
|
+
|
411
|
+
if attributes.has_key?(:'brand')
|
412
|
+
self.brand = attributes[:'brand']
|
413
|
+
end
|
414
|
+
|
415
|
+
if attributes.has_key?(:'mainPhoto')
|
416
|
+
self.main_photo = attributes[:'mainPhoto']
|
417
|
+
end
|
418
|
+
|
419
|
+
if attributes.has_key?(:'main_photo')
|
420
|
+
self.main_photo = attributes[:'main_photo']
|
421
|
+
end
|
422
|
+
|
423
|
+
if attributes.has_key?(:'photos')
|
424
|
+
if (value = attributes[:'photos']).is_a?(Array)
|
425
|
+
self.photos = value
|
426
|
+
end
|
427
|
+
end
|
428
|
+
|
429
|
+
if attributes.has_key?(:'files')
|
430
|
+
if (value = attributes[:'files']).is_a?(Array)
|
431
|
+
self.files = value
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
if attributes.has_key?(:'promotions')
|
436
|
+
if (value = attributes[:'promotions']).is_a?(Array)
|
437
|
+
self.promotions = value
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
if attributes.has_key?(:'relatedProducts')
|
442
|
+
if (value = attributes[:'relatedProducts']).is_a?(Array)
|
443
|
+
self.related_products = value
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
if attributes.has_key?(:'related_products')
|
448
|
+
if (value = attributes[:'related_products']).is_a?(Array)
|
449
|
+
self.related_products = value
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
if attributes.has_key?(:'stockStatus')
|
454
|
+
self.stock_status = attributes[:'stockStatus']
|
455
|
+
end
|
456
|
+
|
457
|
+
if attributes.has_key?(:'stock_status')
|
458
|
+
self.stock_status = attributes[:'stock_status']
|
459
|
+
end
|
460
|
+
|
461
|
+
if attributes.has_key?(:'categories')
|
462
|
+
if (value = attributes[:'categories']).is_a?(Array)
|
463
|
+
self.categories = value
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
if attributes.has_key?(:'taxClass')
|
468
|
+
self.tax_class = attributes[:'taxClass']
|
469
|
+
end
|
470
|
+
|
471
|
+
if attributes.has_key?(:'tax_class')
|
472
|
+
self.tax_class = attributes[:'tax_class']
|
473
|
+
end
|
474
|
+
|
475
|
+
if attributes.has_key?(:'optionSet')
|
476
|
+
self.option_set = attributes[:'optionSet']
|
477
|
+
end
|
478
|
+
|
479
|
+
if attributes.has_key?(:'option_set')
|
480
|
+
self.option_set = attributes[:'option_set']
|
481
|
+
end
|
482
|
+
|
483
|
+
if attributes.has_key?(:'variants')
|
484
|
+
if (value = attributes[:'variants']).is_a?(Array)
|
485
|
+
self.variants = value
|
486
|
+
end
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
491
|
+
# @return Array for valid properties with the reasons
|
492
|
+
def list_invalid_properties
|
493
|
+
invalid_properties = Array.new
|
494
|
+
if @name.nil?
|
495
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
496
|
+
end
|
497
|
+
|
498
|
+
if @slug.nil?
|
499
|
+
invalid_properties.push('invalid value for "slug", slug cannot be nil.')
|
500
|
+
end
|
501
|
+
|
502
|
+
if @status.nil?
|
503
|
+
invalid_properties.push('invalid value for "status", status cannot be nil.')
|
504
|
+
end
|
505
|
+
|
506
|
+
if @type.nil?
|
507
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
508
|
+
end
|
509
|
+
|
510
|
+
if @sku.nil?
|
511
|
+
invalid_properties.push('invalid value for "sku", sku cannot be nil.')
|
512
|
+
end
|
513
|
+
|
514
|
+
if @price.nil?
|
515
|
+
invalid_properties.push('invalid value for "price", price cannot be nil.')
|
516
|
+
end
|
517
|
+
|
518
|
+
if @categories.nil?
|
519
|
+
invalid_properties.push('invalid value for "categories", categories cannot be nil.')
|
520
|
+
end
|
521
|
+
|
522
|
+
invalid_properties
|
523
|
+
end
|
524
|
+
|
525
|
+
# Check to see if the all the properties in the model are valid
|
526
|
+
# @return true if the model is valid
|
527
|
+
def valid?
|
528
|
+
return false if @name.nil?
|
529
|
+
return false if @slug.nil?
|
530
|
+
return false if @status.nil?
|
531
|
+
status_validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
|
532
|
+
return false unless status_validator.valid?(@status)
|
533
|
+
return false if @type.nil?
|
534
|
+
type_validator = EnumAttributeValidator.new('String', ['digital', 'physical'])
|
535
|
+
return false unless type_validator.valid?(@type)
|
536
|
+
return false if @sku.nil?
|
537
|
+
return false if @price.nil?
|
538
|
+
availability_validator = EnumAttributeValidator.new('String', ['available', 'comingSoon', 'retired'])
|
539
|
+
return false unless availability_validator.valid?(@availability)
|
540
|
+
stock_status_validator = EnumAttributeValidator.new('String', ['available', 'alert', 'unavailable'])
|
541
|
+
return false unless stock_status_validator.valid?(@stock_status)
|
542
|
+
return false if @categories.nil?
|
543
|
+
true
|
544
|
+
end
|
545
|
+
|
546
|
+
# Custom attribute writer method checking allowed values (enum).
|
547
|
+
# @param [Object] status Object to be assigned
|
548
|
+
def status=(status)
|
549
|
+
validator = EnumAttributeValidator.new('String', ['enabled', 'disabled'])
|
550
|
+
unless validator.valid?(status)
|
551
|
+
fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
|
552
|
+
end
|
553
|
+
@status = status
|
554
|
+
end
|
555
|
+
|
556
|
+
# Custom attribute writer method checking allowed values (enum).
|
557
|
+
# @param [Object] type Object to be assigned
|
558
|
+
def type=(type)
|
559
|
+
validator = EnumAttributeValidator.new('String', ['digital', 'physical'])
|
560
|
+
unless validator.valid?(type)
|
561
|
+
fail ArgumentError, 'invalid value for "type", must be one of #{validator.allowable_values}.'
|
562
|
+
end
|
563
|
+
@type = type
|
564
|
+
end
|
565
|
+
|
566
|
+
# Custom attribute writer method checking allowed values (enum).
|
567
|
+
# @param [Object] availability Object to be assigned
|
568
|
+
def availability=(availability)
|
569
|
+
validator = EnumAttributeValidator.new('String', ['available', 'comingSoon', 'retired'])
|
570
|
+
unless validator.valid?(availability)
|
571
|
+
fail ArgumentError, 'invalid value for "availability", must be one of #{validator.allowable_values}.'
|
572
|
+
end
|
573
|
+
@availability = availability
|
574
|
+
end
|
575
|
+
|
576
|
+
# Custom attribute writer method checking allowed values (enum).
|
577
|
+
# @param [Object] stock_status Object to be assigned
|
578
|
+
def stock_status=(stock_status)
|
579
|
+
validator = EnumAttributeValidator.new('String', ['available', 'alert', 'unavailable'])
|
580
|
+
unless validator.valid?(stock_status)
|
581
|
+
fail ArgumentError, 'invalid value for "stock_status", must be one of #{validator.allowable_values}.'
|
582
|
+
end
|
583
|
+
@stock_status = stock_status
|
584
|
+
end
|
585
|
+
|
586
|
+
# Checks equality by comparing each attribute.
|
587
|
+
# @param [Object] Object to be compared
|
588
|
+
def ==(o)
|
589
|
+
return true if self.equal?(o)
|
590
|
+
self.class == o.class &&
|
591
|
+
__meta == o.__meta &&
|
592
|
+
created_at == o.created_at &&
|
593
|
+
updated_at == o.updated_at &&
|
594
|
+
name == o.name &&
|
595
|
+
slug == o.slug &&
|
596
|
+
model == o.model &&
|
597
|
+
status == o.status &&
|
598
|
+
type == o.type &&
|
599
|
+
short_description == o.short_description &&
|
600
|
+
full_description == o.full_description &&
|
601
|
+
free_shipping == o.free_shipping &&
|
602
|
+
sku == o.sku &&
|
603
|
+
price == o.price &&
|
604
|
+
cost_price == o.cost_price &&
|
605
|
+
retail_price == o.retail_price &&
|
606
|
+
sale_price == o.sale_price &&
|
607
|
+
manage_inventory == o.manage_inventory &&
|
608
|
+
stock_level == o.stock_level &&
|
609
|
+
minimum_stock_level == o.minimum_stock_level &&
|
610
|
+
maximum_sell_count == o.maximum_sell_count &&
|
611
|
+
item_dimensions == o.item_dimensions &&
|
612
|
+
package_dimensions == o.package_dimensions &&
|
613
|
+
package_weight == o.package_weight &&
|
614
|
+
require_shipping == o.require_shipping &&
|
615
|
+
availability == o.availability &&
|
616
|
+
availability_date == o.availability_date &&
|
617
|
+
allow_pre_order == o.allow_pre_order &&
|
618
|
+
brand == o.brand &&
|
619
|
+
main_photo == o.main_photo &&
|
620
|
+
photos == o.photos &&
|
621
|
+
files == o.files &&
|
622
|
+
promotions == o.promotions &&
|
623
|
+
related_products == o.related_products &&
|
624
|
+
stock_status == o.stock_status &&
|
625
|
+
categories == o.categories &&
|
626
|
+
tax_class == o.tax_class &&
|
627
|
+
option_set == o.option_set &&
|
628
|
+
variants == o.variants
|
629
|
+
end
|
630
|
+
|
631
|
+
# @see the `==` method
|
632
|
+
# @param [Object] Object to be compared
|
633
|
+
def eql?(o)
|
634
|
+
self == o
|
635
|
+
end
|
636
|
+
|
637
|
+
# Calculates hash code according to all attributes.
|
638
|
+
# @return [Fixnum] Hash code
|
639
|
+
def hash
|
640
|
+
[__meta, created_at, updated_at, name, slug, model, status, type, short_description, full_description, free_shipping, sku, price, cost_price, retail_price, sale_price, manage_inventory, stock_level, minimum_stock_level, maximum_sell_count, item_dimensions, package_dimensions, package_weight, require_shipping, availability, availability_date, allow_pre_order, brand, main_photo, photos, files, promotions, related_products, stock_status, categories, tax_class, option_set, variants].hash
|
641
|
+
end
|
642
|
+
|
643
|
+
# Builds the object from hash
|
644
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
645
|
+
# @return [Object] Returns the model itself
|
646
|
+
def build_from_hash(attributes)
|
647
|
+
return nil unless attributes.is_a?(Hash)
|
648
|
+
self.class.swagger_types.each_pair do |key, type|
|
649
|
+
if type =~ /\AArray<(.*)>/i
|
650
|
+
# check to ensure the input is an array given that the the attribute
|
651
|
+
# is documented as an array but the input is not
|
652
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
653
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
654
|
+
end
|
655
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
656
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
657
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
658
|
+
end
|
659
|
+
|
660
|
+
self
|
661
|
+
end
|
662
|
+
|
663
|
+
# Deserializes the data based on type
|
664
|
+
# @param string type Data type
|
665
|
+
# @param string value Value to be deserialized
|
666
|
+
# @return [Object] Deserialized data
|
667
|
+
def _deserialize(type, value)
|
668
|
+
case type.to_sym
|
669
|
+
when :DateTime
|
670
|
+
DateTime.parse(value)
|
671
|
+
when :Date
|
672
|
+
Date.parse(value)
|
673
|
+
when :String
|
674
|
+
value.to_s
|
675
|
+
when :Integer
|
676
|
+
value.to_i
|
677
|
+
when :Float
|
678
|
+
value.to_f
|
679
|
+
when :BOOLEAN
|
680
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
681
|
+
true
|
682
|
+
else
|
683
|
+
false
|
684
|
+
end
|
685
|
+
when :Object
|
686
|
+
# generic object (usually a Hash), return directly
|
687
|
+
value
|
688
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
689
|
+
inner_type = Regexp.last_match[:inner_type]
|
690
|
+
value.map { |v| _deserialize(inner_type, v) }
|
691
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
692
|
+
k_type = Regexp.last_match[:k_type]
|
693
|
+
v_type = Regexp.last_match[:v_type]
|
694
|
+
{}.tap do |hash|
|
695
|
+
value.each do |k, v|
|
696
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
697
|
+
end
|
698
|
+
end
|
699
|
+
else # model
|
700
|
+
temp_model = Tradenity.const_get(type).new
|
701
|
+
temp_model.build_from_hash(value)
|
702
|
+
end
|
703
|
+
end
|
704
|
+
|
705
|
+
# Returns the string representation of the object
|
706
|
+
# @return [String] String presentation of the object
|
707
|
+
def to_s
|
708
|
+
to_hash.to_s
|
709
|
+
end
|
710
|
+
|
711
|
+
# to_body is an alias to to_hash (backward compatibility)
|
712
|
+
# @return [Hash] Returns the object in the form of hash
|
713
|
+
def to_body
|
714
|
+
to_hash
|
715
|
+
end
|
716
|
+
|
717
|
+
# Returns the object in the form of hash
|
718
|
+
# @return [Hash] Returns the object in the form of hash
|
719
|
+
def to_hash
|
720
|
+
hash = {}
|
721
|
+
self.class.attribute_map.each_pair do |attr, param|
|
722
|
+
value = self.send(attr)
|
723
|
+
next if value.nil?
|
724
|
+
hash[param] = _to_hash(value)
|
725
|
+
end
|
726
|
+
hash
|
727
|
+
end
|
728
|
+
|
729
|
+
# Outputs non-array value in the form of hash
|
730
|
+
# For object, use to_hash. Otherwise, just return the value
|
731
|
+
# @param [Object] value Any valid value
|
732
|
+
# @return [Hash] Returns the value in the form of hash
|
733
|
+
def _to_hash(value)
|
734
|
+
if value.is_a?(Array)
|
735
|
+
value.compact.map { |v| _to_hash(v) }
|
736
|
+
elsif value.is_a?(Hash)
|
737
|
+
{}.tap do |hash|
|
738
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
739
|
+
end
|
740
|
+
elsif value.respond_to? :to_hash
|
741
|
+
value.to_hash
|
742
|
+
else
|
743
|
+
value
|
744
|
+
end
|
745
|
+
end
|
746
|
+
|
747
|
+
|
748
|
+
def self.api_client
|
749
|
+
ApiClient.default
|
750
|
+
end
|
751
|
+
|
752
|
+
# Create Product
|
753
|
+
# Create a new Product
|
754
|
+
def create
|
755
|
+
data = self.class.create_product(self)
|
756
|
+
self.id = data.id
|
757
|
+
data
|
758
|
+
end
|
759
|
+
|
760
|
+
# Update Product
|
761
|
+
# Update attributes of Product
|
762
|
+
# @return [Product]
|
763
|
+
def update
|
764
|
+
self.class.update_product_by_id(self.id, self)
|
765
|
+
end
|
766
|
+
|
767
|
+
# Delete Product
|
768
|
+
# Delete this instance of Product.
|
769
|
+
# @return [nil]
|
770
|
+
def delete
|
771
|
+
self.class.delete_product_by_id(self.id)
|
772
|
+
end
|
773
|
+
|
774
|
+
class << self
|
775
|
+
|
776
|
+
# List Products
|
777
|
+
# Return a list of Products
|
778
|
+
# @param [Hash] opts the optional parameters
|
779
|
+
# @return [Page<Product>]
|
780
|
+
def find_all
|
781
|
+
list_all_products
|
782
|
+
end
|
783
|
+
|
784
|
+
# Find List of Product
|
785
|
+
# Return multiple instances of Product by its attributes.
|
786
|
+
# @param [Hash] opts the search parameters
|
787
|
+
# @return [Page<Collection>]
|
788
|
+
def find_all_by(opts = {})
|
789
|
+
list_all_products(opts)
|
790
|
+
end
|
791
|
+
|
792
|
+
# Find Product by its parameters
|
793
|
+
# Return single instance of Collection by its attributes.
|
794
|
+
# @param [Hash] opts search parameters
|
795
|
+
# @return [Product]
|
796
|
+
def find_one_by(opts = {})
|
797
|
+
list_all_products(opts)[0]
|
798
|
+
end
|
799
|
+
|
800
|
+
# Find Product
|
801
|
+
# Return single instance of Product by its ID.
|
802
|
+
# @param id ID of Product to return
|
803
|
+
# @return [Product]
|
804
|
+
def find_by_id(id)
|
805
|
+
get_product_by_id(id)
|
806
|
+
end
|
807
|
+
|
808
|
+
# Delete Product
|
809
|
+
# Delete an instance of Product by its ID.
|
810
|
+
# @param id ID of Product to delete.
|
811
|
+
# @return [nil]
|
812
|
+
def delete_by_id(id)
|
813
|
+
delete_product_by_id(id)
|
814
|
+
end
|
815
|
+
|
816
|
+
# Create Product
|
817
|
+
# Create a new Product
|
818
|
+
# @param product Attributes of product to create
|
819
|
+
# @param [Hash] opts the optional parameters
|
820
|
+
# @return [Product]
|
821
|
+
def create_product(product, opts = {})
|
822
|
+
data, _status_code, _headers = create_product_with_http_info(product, opts)
|
823
|
+
data
|
824
|
+
end
|
825
|
+
|
826
|
+
# Create Product
|
827
|
+
# Create a new Product
|
828
|
+
# @param product Attributes of product to create
|
829
|
+
# @param [Hash] opts the optional parameters
|
830
|
+
# @return [Array<(Product, Fixnum, Hash)>] Product data, response status code and response headers
|
831
|
+
def create_product_with_http_info(product, opts = {})
|
832
|
+
if api_client.config.debugging
|
833
|
+
api_client.config.logger.debug 'Calling API: Product.create_product ...'
|
834
|
+
end
|
835
|
+
# verify the required parameter 'product' is set
|
836
|
+
if api_client.config.client_side_validation && product.nil?
|
837
|
+
fail ArgumentError, "Missing the required parameter 'product' when calling Product.create_product"
|
838
|
+
end
|
839
|
+
# resource path
|
840
|
+
local_var_path = '/products'
|
841
|
+
|
842
|
+
# query parameters
|
843
|
+
query_params = opts
|
844
|
+
|
845
|
+
# header parameters
|
846
|
+
header_params = {}
|
847
|
+
# HTTP header 'Accept' (if needed)
|
848
|
+
header_params['Accept'] = api_client.select_header_accept(['application/json'])
|
849
|
+
# HTTP header 'Content-Type'
|
850
|
+
header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
|
851
|
+
|
852
|
+
# form parameters
|
853
|
+
form_params = {}
|
854
|
+
|
855
|
+
# http body (model)
|
856
|
+
post_body = api_client.object_to_http_body(product)
|
857
|
+
auth_names = []
|
858
|
+
data, status_code, headers = api_client.call_api(:POST, local_var_path,
|
859
|
+
:header_params => header_params,
|
860
|
+
:query_params => query_params,
|
861
|
+
:form_params => form_params,
|
862
|
+
:body => post_body,
|
863
|
+
:auth_names => auth_names,
|
864
|
+
:return_type => 'Product')
|
865
|
+
if api_client.config.debugging
|
866
|
+
api_client.config.logger.debug "API called: Product#create_product\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
867
|
+
end
|
868
|
+
return data, status_code, headers
|
869
|
+
end
|
870
|
+
# Delete Product
|
871
|
+
# Delete an instance of Product by its ID.
|
872
|
+
# @param product_id ID of product to delete.
|
873
|
+
# @param [Hash] opts the optional parameters
|
874
|
+
# @return [nil]
|
875
|
+
def delete_product_by_id(product_id, opts = {})
|
876
|
+
delete_product_by_id_with_http_info(product_id, opts)
|
877
|
+
nil
|
878
|
+
end
|
879
|
+
|
880
|
+
# Delete Product
|
881
|
+
# Delete an instance of Product by its ID.
|
882
|
+
# @param product_id ID of product to delete.
|
883
|
+
# @param [Hash] opts the optional parameters
|
884
|
+
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
|
885
|
+
def delete_product_by_id_with_http_info(product_id, opts = {})
|
886
|
+
if api_client.config.debugging
|
887
|
+
api_client.config.logger.debug 'Calling API: Product.delete_product_by_id ...'
|
888
|
+
end
|
889
|
+
# verify the required parameter 'product_id' is set
|
890
|
+
if api_client.config.client_side_validation && product_id.nil?
|
891
|
+
fail ArgumentError, "Missing the required parameter 'product_id' when calling Product.delete_product_by_id"
|
892
|
+
end
|
893
|
+
# resource path
|
894
|
+
local_var_path = '/products/{productId}'.sub('{' + 'productId' + '}', product_id.to_s)
|
895
|
+
|
896
|
+
# query parameters
|
897
|
+
query_params = opts
|
898
|
+
|
899
|
+
# header parameters
|
900
|
+
header_params = {}
|
901
|
+
# HTTP header 'Accept' (if needed)
|
902
|
+
header_params['Accept'] = api_client.select_header_accept(['application/json'])
|
903
|
+
# HTTP header 'Content-Type'
|
904
|
+
header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
|
905
|
+
|
906
|
+
# form parameters
|
907
|
+
form_params = {}
|
908
|
+
|
909
|
+
# http body (model)
|
910
|
+
post_body = nil
|
911
|
+
auth_names = []
|
912
|
+
data, status_code, headers = api_client.call_api(:DELETE, local_var_path,
|
913
|
+
:header_params => header_params,
|
914
|
+
:query_params => query_params,
|
915
|
+
:form_params => form_params,
|
916
|
+
:body => post_body,
|
917
|
+
:auth_names => auth_names)
|
918
|
+
if api_client.config.debugging
|
919
|
+
api_client.config.logger.debug "API called: Product#delete_product_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
920
|
+
end
|
921
|
+
return data, status_code, headers
|
922
|
+
end
|
923
|
+
# Find Product
|
924
|
+
# Return single instance of Product by its ID.
|
925
|
+
# @param product_id ID of product to return
|
926
|
+
# @param [Hash] opts the optional parameters
|
927
|
+
# @return [Product]
|
928
|
+
def get_product_by_id(product_id, opts = {})
|
929
|
+
data, _status_code, _headers = get_product_by_id_with_http_info(product_id, opts)
|
930
|
+
data
|
931
|
+
end
|
932
|
+
|
933
|
+
# Find Product
|
934
|
+
# Return single instance of Product by its ID.
|
935
|
+
# @param product_id ID of product to return
|
936
|
+
# @param [Hash] opts the optional parameters
|
937
|
+
# @return [Array<(Product, Fixnum, Hash)>] Product data, response status code and response headers
|
938
|
+
def get_product_by_id_with_http_info(product_id, opts = {})
|
939
|
+
if api_client.config.debugging
|
940
|
+
api_client.config.logger.debug 'Calling API: Product.get_product_by_id ...'
|
941
|
+
end
|
942
|
+
# verify the required parameter 'product_id' is set
|
943
|
+
if api_client.config.client_side_validation && product_id.nil?
|
944
|
+
fail ArgumentError, "Missing the required parameter 'product_id' when calling Product.get_product_by_id"
|
945
|
+
end
|
946
|
+
# resource path
|
947
|
+
local_var_path = '/products/{productId}'.sub('{' + 'productId' + '}', product_id.to_s)
|
948
|
+
|
949
|
+
# query parameters
|
950
|
+
query_params = opts
|
951
|
+
|
952
|
+
# header parameters
|
953
|
+
header_params = {}
|
954
|
+
# HTTP header 'Accept' (if needed)
|
955
|
+
header_params['Accept'] = api_client.select_header_accept(['application/json'])
|
956
|
+
# HTTP header 'Content-Type'
|
957
|
+
header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
|
958
|
+
|
959
|
+
# form parameters
|
960
|
+
form_params = {}
|
961
|
+
|
962
|
+
# http body (model)
|
963
|
+
post_body = nil
|
964
|
+
auth_names = []
|
965
|
+
data, status_code, headers = api_client.call_api(:GET, local_var_path,
|
966
|
+
:header_params => header_params,
|
967
|
+
:query_params => query_params,
|
968
|
+
:form_params => form_params,
|
969
|
+
:body => post_body,
|
970
|
+
:auth_names => auth_names,
|
971
|
+
:return_type => 'Product')
|
972
|
+
if api_client.config.debugging
|
973
|
+
api_client.config.logger.debug "API called: Product#get_product_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
974
|
+
end
|
975
|
+
return data, status_code, headers
|
976
|
+
end
|
977
|
+
# List Products
|
978
|
+
# Return a list of Products
|
979
|
+
# @param [Hash] opts the optional parameters
|
980
|
+
# @option opts [Integer] :page page number
|
981
|
+
# @option opts [Integer] :size page size
|
982
|
+
# @option opts [String] :sort page order
|
983
|
+
# @return [Page<Product>]
|
984
|
+
def list_all_products(opts = {})
|
985
|
+
data, _status_code, _headers = list_all_products_with_http_info(opts)
|
986
|
+
data
|
987
|
+
end
|
988
|
+
|
989
|
+
# List Products
|
990
|
+
# Return a list of Products
|
991
|
+
# @param [Hash] opts the optional parameters
|
992
|
+
# @option opts [Integer] :page page number
|
993
|
+
# @option opts [Integer] :size page size
|
994
|
+
# @option opts [String] :sort page order
|
995
|
+
# @return [Array<(Page<Product>, Fixnum, Hash)>] Page<Product> data, response status code and response headers
|
996
|
+
def list_all_products_with_http_info(opts = {})
|
997
|
+
if api_client.config.debugging
|
998
|
+
api_client.config.logger.debug 'Calling API: Product.list_all_products ...'
|
999
|
+
end
|
1000
|
+
# resource path
|
1001
|
+
local_var_path = '/products'
|
1002
|
+
|
1003
|
+
# query parameters
|
1004
|
+
query_params = opts
|
1005
|
+
# query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
|
1006
|
+
# query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
|
1007
|
+
# query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
|
1008
|
+
|
1009
|
+
# header parameters
|
1010
|
+
header_params = {}
|
1011
|
+
# HTTP header 'Accept' (if needed)
|
1012
|
+
header_params['Accept'] = api_client.select_header_accept(['application/json'])
|
1013
|
+
# HTTP header 'Content-Type'
|
1014
|
+
header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
|
1015
|
+
|
1016
|
+
# form parameters
|
1017
|
+
form_params = {}
|
1018
|
+
|
1019
|
+
# http body (model)
|
1020
|
+
post_body = nil
|
1021
|
+
auth_names = []
|
1022
|
+
data, status_code, headers = api_client.call_api(:GET, local_var_path,
|
1023
|
+
:header_params => header_params,
|
1024
|
+
:query_params => query_params,
|
1025
|
+
:form_params => form_params,
|
1026
|
+
:body => post_body,
|
1027
|
+
:auth_names => auth_names,
|
1028
|
+
:return_type => 'Page<Product>')
|
1029
|
+
if api_client.config.debugging
|
1030
|
+
api_client.config.logger.debug "API called: Product#list_all_products\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
1031
|
+
end
|
1032
|
+
return data, status_code, headers
|
1033
|
+
end
|
1034
|
+
# Replace Product
|
1035
|
+
# Replace all attributes of Product
|
1036
|
+
# @param product_id ID of product to replace
|
1037
|
+
# @param product Attributes of product to replace
|
1038
|
+
# @param [Hash] opts the optional parameters
|
1039
|
+
# @return [Product]
|
1040
|
+
def replace_product_by_id(product_id, product, opts = {})
|
1041
|
+
data, _status_code, _headers = replace_product_by_id_with_http_info(product_id, product, opts)
|
1042
|
+
data
|
1043
|
+
end
|
1044
|
+
|
1045
|
+
# Replace Product
|
1046
|
+
# Replace all attributes of Product
|
1047
|
+
# @param product_id ID of product to replace
|
1048
|
+
# @param product Attributes of product to replace
|
1049
|
+
# @param [Hash] opts the optional parameters
|
1050
|
+
# @return [Array<(Product, Fixnum, Hash)>] Product data, response status code and response headers
|
1051
|
+
def replace_product_by_id_with_http_info(product_id, product, opts = {})
|
1052
|
+
if api_client.config.debugging
|
1053
|
+
api_client.config.logger.debug 'Calling API: Product.replace_product_by_id ...'
|
1054
|
+
end
|
1055
|
+
# verify the required parameter 'product_id' is set
|
1056
|
+
if api_client.config.client_side_validation && product_id.nil?
|
1057
|
+
fail ArgumentError, "Missing the required parameter 'product_id' when calling Product.replace_product_by_id"
|
1058
|
+
end
|
1059
|
+
# verify the required parameter 'product' is set
|
1060
|
+
if api_client.config.client_side_validation && product.nil?
|
1061
|
+
fail ArgumentError, "Missing the required parameter 'product' when calling Product.replace_product_by_id"
|
1062
|
+
end
|
1063
|
+
# resource path
|
1064
|
+
local_var_path = '/products/{productId}'.sub('{' + 'productId' + '}', product_id.to_s)
|
1065
|
+
|
1066
|
+
# query parameters
|
1067
|
+
query_params = opts
|
1068
|
+
|
1069
|
+
# header parameters
|
1070
|
+
header_params = {}
|
1071
|
+
# HTTP header 'Accept' (if needed)
|
1072
|
+
header_params['Accept'] = api_client.select_header_accept(['application/json'])
|
1073
|
+
# HTTP header 'Content-Type'
|
1074
|
+
header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
|
1075
|
+
|
1076
|
+
# form parameters
|
1077
|
+
form_params = {}
|
1078
|
+
|
1079
|
+
# http body (model)
|
1080
|
+
post_body = api_client.object_to_http_body(product)
|
1081
|
+
auth_names = []
|
1082
|
+
data, status_code, headers = api_client.call_api(:PUT, local_var_path,
|
1083
|
+
:header_params => header_params,
|
1084
|
+
:query_params => query_params,
|
1085
|
+
:form_params => form_params,
|
1086
|
+
:body => post_body,
|
1087
|
+
:auth_names => auth_names,
|
1088
|
+
:return_type => 'Product')
|
1089
|
+
if api_client.config.debugging
|
1090
|
+
api_client.config.logger.debug "API called: Product#replace_product_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
1091
|
+
end
|
1092
|
+
return data, status_code, headers
|
1093
|
+
end
|
1094
|
+
# Update Product
|
1095
|
+
# Update attributes of Product
|
1096
|
+
# @param product_id ID of product to update.
|
1097
|
+
# @param product Attributes of product to update.
|
1098
|
+
# @param [Hash] opts the optional parameters
|
1099
|
+
# @return [Product]
|
1100
|
+
def update_product_by_id(product_id, product, opts = {})
|
1101
|
+
data, _status_code, _headers = update_product_by_id_with_http_info(product_id, product, opts)
|
1102
|
+
data
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
# Update Product
|
1106
|
+
# Update attributes of Product
|
1107
|
+
# @param product_id ID of product to update.
|
1108
|
+
# @param product Attributes of product to update.
|
1109
|
+
# @param [Hash] opts the optional parameters
|
1110
|
+
# @return [Array<(Product, Fixnum, Hash)>] Product data, response status code and response headers
|
1111
|
+
def update_product_by_id_with_http_info(product_id, product, opts = {})
|
1112
|
+
if api_client.config.debugging
|
1113
|
+
api_client.config.logger.debug 'Calling API: Product.update_product_by_id ...'
|
1114
|
+
end
|
1115
|
+
# verify the required parameter 'product_id' is set
|
1116
|
+
if api_client.config.client_side_validation && product_id.nil?
|
1117
|
+
fail ArgumentError, "Missing the required parameter 'product_id' when calling Product.update_product_by_id"
|
1118
|
+
end
|
1119
|
+
# verify the required parameter 'product' is set
|
1120
|
+
if api_client.config.client_side_validation && product.nil?
|
1121
|
+
fail ArgumentError, "Missing the required parameter 'product' when calling Product.update_product_by_id"
|
1122
|
+
end
|
1123
|
+
# resource path
|
1124
|
+
local_var_path = '/products/{productId}'.sub('{' + 'productId' + '}', product_id.to_s)
|
1125
|
+
|
1126
|
+
# query parameters
|
1127
|
+
query_params = opts
|
1128
|
+
|
1129
|
+
# header parameters
|
1130
|
+
header_params = {}
|
1131
|
+
# HTTP header 'Accept' (if needed)
|
1132
|
+
header_params['Accept'] = api_client.select_header_accept(['application/json'])
|
1133
|
+
# HTTP header 'Content-Type'
|
1134
|
+
header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
|
1135
|
+
|
1136
|
+
# form parameters
|
1137
|
+
form_params = {}
|
1138
|
+
|
1139
|
+
# http body (model)
|
1140
|
+
post_body = api_client.object_to_http_body(product)
|
1141
|
+
auth_names = []
|
1142
|
+
data, status_code, headers = api_client.call_api(:PATCH, local_var_path,
|
1143
|
+
:header_params => header_params,
|
1144
|
+
:query_params => query_params,
|
1145
|
+
:form_params => form_params,
|
1146
|
+
:body => post_body,
|
1147
|
+
:auth_names => auth_names,
|
1148
|
+
:return_type => 'Product')
|
1149
|
+
if api_client.config.debugging
|
1150
|
+
api_client.config.logger.debug "API called: Product#update_product_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
1151
|
+
end
|
1152
|
+
return data, status_code, headers
|
1153
|
+
end
|
1154
|
+
end
|
1155
|
+
end
|
1156
|
+
end
|