Creizer-Meli 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +137 -0
  4. data/Rakefile +10 -0
  5. data/creizer-meli.gemspec +33 -0
  6. data/docs/Attributes.md +31 -0
  7. data/docs/AttributesValueStruct.md +19 -0
  8. data/docs/AttributesValues.md +21 -0
  9. data/docs/CategoriesApi.md +150 -0
  10. data/docs/InlineObject.md +27 -0
  11. data/docs/Item.md +41 -0
  12. data/docs/ItemPictures.md +17 -0
  13. data/docs/ItemsApi.md +152 -0
  14. data/docs/ItemsHealthApi.md +150 -0
  15. data/docs/OAuth20Api.md +117 -0
  16. data/docs/RestClientApi.md +204 -0
  17. data/docs/Variations.md +25 -0
  18. data/docs/VariationsAttributeCombinations.md +21 -0
  19. data/examples/get_token.rb +21 -0
  20. data/examples/restclient_post.rb +73 -0
  21. data/lib/meli.rb +52 -0
  22. data/lib/meli/api/categories_api.rb +216 -0
  23. data/lib/meli/api/items_api.rb +226 -0
  24. data/lib/meli/api/items_health_api.rb +216 -0
  25. data/lib/meli/api/o_auth20_api.rb +178 -0
  26. data/lib/meli/api/rest_client_api.rb +306 -0
  27. data/lib/meli/api_client.rb +387 -0
  28. data/lib/meli/api_error.rb +57 -0
  29. data/lib/meli/configuration.rb +297 -0
  30. data/lib/meli/models/attributes.rb +273 -0
  31. data/lib/meli/models/attributes_value_struct.rb +215 -0
  32. data/lib/meli/models/attributes_values.rb +226 -0
  33. data/lib/meli/models/inline_object.rb +251 -0
  34. data/lib/meli/models/item.rb +375 -0
  35. data/lib/meli/models/item_pictures.rb +206 -0
  36. data/lib/meli/models/variations.rb +246 -0
  37. data/lib/meli/models/variations_attribute_combinations.rb +224 -0
  38. data/lib/meli/version.rb +15 -0
  39. data/spec/api/categories_api_spec.rb +70 -0
  40. data/spec/api/items_api_spec.rb +71 -0
  41. data/spec/api/items_health_api_spec.rb +70 -0
  42. data/spec/api/o_auth20_api_spec.rb +65 -0
  43. data/spec/api/rest_client_api_spec.rb +85 -0
  44. data/spec/api_client_spec.rb +226 -0
  45. data/spec/configuration_spec.rb +42 -0
  46. data/spec/models/attributes_spec.rb +83 -0
  47. data/spec/models/attributes_value_struct_spec.rb +47 -0
  48. data/spec/models/attributes_values_spec.rb +53 -0
  49. data/spec/models/inline_object_spec.rb +71 -0
  50. data/spec/models/item_pictures_spec.rb +41 -0
  51. data/spec/models/item_spec.rb +113 -0
  52. data/spec/models/variations_attribute_combinations_spec.rb +53 -0
  53. data/spec/models/variations_spec.rb +65 -0
  54. data/spec/spec_helper.rb +111 -0
  55. metadata +173 -0
@@ -0,0 +1,375 @@
1
+ =begin
2
+ #MELI Markeplace SDK
3
+
4
+ #This is a the codebase to generate a SDK for Open Platform Marketplace
5
+
6
+ The version of the OpenAPI document: 3.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Meli
16
+ class Item
17
+ attr_accessor :title
18
+
19
+ attr_accessor :category_id
20
+
21
+ attr_accessor :price
22
+
23
+ attr_accessor :currency_id
24
+
25
+ attr_accessor :available_quantity
26
+
27
+ attr_accessor :buying_mode
28
+
29
+ attr_accessor :listing_type_id
30
+
31
+ attr_accessor :condition
32
+
33
+ attr_accessor :description
34
+
35
+ attr_accessor :video_id
36
+
37
+ attr_accessor :pictures
38
+
39
+ attr_accessor :attributes
40
+
41
+ attr_accessor :variations
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'title' => :'title',
47
+ :'category_id' => :'category_id',
48
+ :'price' => :'price',
49
+ :'currency_id' => :'currency_id',
50
+ :'available_quantity' => :'available_quantity',
51
+ :'buying_mode' => :'buying_mode',
52
+ :'listing_type_id' => :'listing_type_id',
53
+ :'condition' => :'condition',
54
+ :'description' => :'description',
55
+ :'video_id' => :'video_id',
56
+ :'pictures' => :'pictures',
57
+ :'attributes' => :'attributes',
58
+ :'variations' => :'variations'
59
+ }
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'title' => :'String',
66
+ :'category_id' => :'String',
67
+ :'price' => :'Integer',
68
+ :'currency_id' => :'String',
69
+ :'available_quantity' => :'String',
70
+ :'buying_mode' => :'String',
71
+ :'listing_type_id' => :'String',
72
+ :'condition' => :'String',
73
+ :'description' => :'String',
74
+ :'video_id' => :'String',
75
+ :'pictures' => :'Array<ItemPictures>',
76
+ :'attributes' => :'Array<Attributes>',
77
+ :'variations' => :'Array<Variations>'
78
+ }
79
+ end
80
+
81
+ # List of attributes with nullable: true
82
+ def self.openapi_nullable
83
+ Set.new([
84
+ ])
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Meli::Item` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h|
96
+ if (!self.class.attribute_map.key?(k.to_sym))
97
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Meli::Item`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
98
+ end
99
+ h[k.to_sym] = v
100
+ }
101
+
102
+ if attributes.key?(:'title')
103
+ self.title = attributes[:'title']
104
+ end
105
+
106
+ if attributes.key?(:'category_id')
107
+ self.category_id = attributes[:'category_id']
108
+ end
109
+
110
+ if attributes.key?(:'price')
111
+ self.price = attributes[:'price']
112
+ end
113
+
114
+ if attributes.key?(:'currency_id')
115
+ self.currency_id = attributes[:'currency_id']
116
+ end
117
+
118
+ if attributes.key?(:'available_quantity')
119
+ self.available_quantity = attributes[:'available_quantity']
120
+ end
121
+
122
+ if attributes.key?(:'buying_mode')
123
+ self.buying_mode = attributes[:'buying_mode']
124
+ end
125
+
126
+ if attributes.key?(:'listing_type_id')
127
+ self.listing_type_id = attributes[:'listing_type_id']
128
+ end
129
+
130
+ if attributes.key?(:'condition')
131
+ self.condition = attributes[:'condition']
132
+ end
133
+
134
+ if attributes.key?(:'description')
135
+ self.description = attributes[:'description']
136
+ end
137
+
138
+ if attributes.key?(:'video_id')
139
+ self.video_id = attributes[:'video_id']
140
+ end
141
+
142
+ if attributes.key?(:'pictures')
143
+ if (value = attributes[:'pictures']).is_a?(Array)
144
+ self.pictures = value
145
+ end
146
+ end
147
+
148
+ if attributes.key?(:'attributes')
149
+ if (value = attributes[:'attributes']).is_a?(Array)
150
+ self.attributes = value
151
+ end
152
+ end
153
+
154
+ if attributes.key?(:'variations')
155
+ if (value = attributes[:'variations']).is_a?(Array)
156
+ self.variations = value
157
+ end
158
+ end
159
+ end
160
+
161
+ # Show invalid properties with the reasons. Usually used together with valid?
162
+ # @return Array for valid properties with the reasons
163
+ def list_invalid_properties
164
+ invalid_properties = Array.new
165
+ if @title.nil?
166
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
167
+ end
168
+
169
+ if @category_id.nil?
170
+ invalid_properties.push('invalid value for "category_id", category_id cannot be nil.')
171
+ end
172
+
173
+ if @price.nil?
174
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
175
+ end
176
+
177
+ if @currency_id.nil?
178
+ invalid_properties.push('invalid value for "currency_id", currency_id cannot be nil.')
179
+ end
180
+
181
+ if @available_quantity.nil?
182
+ invalid_properties.push('invalid value for "available_quantity", available_quantity cannot be nil.')
183
+ end
184
+
185
+ if @buying_mode.nil?
186
+ invalid_properties.push('invalid value for "buying_mode", buying_mode cannot be nil.')
187
+ end
188
+
189
+ if @listing_type_id.nil?
190
+ invalid_properties.push('invalid value for "listing_type_id", listing_type_id cannot be nil.')
191
+ end
192
+
193
+ if @condition.nil?
194
+ invalid_properties.push('invalid value for "condition", condition cannot be nil.')
195
+ end
196
+
197
+ if @description.nil?
198
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
199
+ end
200
+
201
+ if @video_id.nil?
202
+ invalid_properties.push('invalid value for "video_id", video_id cannot be nil.')
203
+ end
204
+
205
+ if @pictures.nil?
206
+ invalid_properties.push('invalid value for "pictures", pictures cannot be nil.')
207
+ end
208
+
209
+ invalid_properties
210
+ end
211
+
212
+ # Check to see if the all the properties in the model are valid
213
+ # @return true if the model is valid
214
+ def valid?
215
+ return false if @title.nil?
216
+ return false if @category_id.nil?
217
+ return false if @price.nil?
218
+ return false if @currency_id.nil?
219
+ return false if @available_quantity.nil?
220
+ return false if @buying_mode.nil?
221
+ return false if @listing_type_id.nil?
222
+ return false if @condition.nil?
223
+ return false if @description.nil?
224
+ return false if @video_id.nil?
225
+ return false if @pictures.nil?
226
+ true
227
+ end
228
+
229
+ # Checks equality by comparing each attribute.
230
+ # @param [Object] Object to be compared
231
+ def ==(o)
232
+ return true if self.equal?(o)
233
+ self.class == o.class &&
234
+ title == o.title &&
235
+ category_id == o.category_id &&
236
+ price == o.price &&
237
+ currency_id == o.currency_id &&
238
+ available_quantity == o.available_quantity &&
239
+ buying_mode == o.buying_mode &&
240
+ listing_type_id == o.listing_type_id &&
241
+ condition == o.condition &&
242
+ description == o.description &&
243
+ video_id == o.video_id &&
244
+ pictures == o.pictures &&
245
+ attributes == o.attributes &&
246
+ variations == o.variations
247
+ end
248
+
249
+ # @see the `==` method
250
+ # @param [Object] Object to be compared
251
+ def eql?(o)
252
+ self == o
253
+ end
254
+
255
+ # Calculates hash code according to all attributes.
256
+ # @return [Integer] Hash code
257
+ def hash
258
+ [title, category_id, price, currency_id, available_quantity, buying_mode, listing_type_id, condition, description, video_id, pictures, attributes, variations].hash
259
+ end
260
+
261
+ # Builds the object from hash
262
+ # @param [Hash] attributes Model attributes in the form of hash
263
+ # @return [Object] Returns the model itself
264
+ def self.build_from_hash(attributes)
265
+ new.build_from_hash(attributes)
266
+ end
267
+
268
+ # Builds the object from hash
269
+ # @param [Hash] attributes Model attributes in the form of hash
270
+ # @return [Object] Returns the model itself
271
+ def build_from_hash(attributes)
272
+ return nil unless attributes.is_a?(Hash)
273
+ self.class.openapi_types.each_pair do |key, type|
274
+ if type =~ /\AArray<(.*)>/i
275
+ # check to ensure the input is an array given that the attribute
276
+ # is documented as an array but the input is not
277
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
278
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
279
+ end
280
+ elsif !attributes[self.class.attribute_map[key]].nil?
281
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
282
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
283
+ end
284
+
285
+ self
286
+ end
287
+
288
+ # Deserializes the data based on type
289
+ # @param string type Data type
290
+ # @param string value Value to be deserialized
291
+ # @return [Object] Deserialized data
292
+ def _deserialize(type, value)
293
+ case type.to_sym
294
+ when :DateTime
295
+ DateTime.parse(value)
296
+ when :Date
297
+ Date.parse(value)
298
+ when :String
299
+ value.to_s
300
+ when :Integer
301
+ value.to_i
302
+ when :Float
303
+ value.to_f
304
+ when :Boolean
305
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
306
+ true
307
+ else
308
+ false
309
+ end
310
+ when :Object
311
+ # generic object (usually a Hash), return directly
312
+ value
313
+ when /\AArray<(?<inner_type>.+)>\z/
314
+ inner_type = Regexp.last_match[:inner_type]
315
+ value.map { |v| _deserialize(inner_type, v) }
316
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
317
+ k_type = Regexp.last_match[:k_type]
318
+ v_type = Regexp.last_match[:v_type]
319
+ {}.tap do |hash|
320
+ value.each do |k, v|
321
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
322
+ end
323
+ end
324
+ else # model
325
+ Meli.const_get(type).build_from_hash(value)
326
+ end
327
+ end
328
+
329
+ # Returns the string representation of the object
330
+ # @return [String] String presentation of the object
331
+ def to_s
332
+ to_hash.to_s
333
+ end
334
+
335
+ # to_body is an alias to to_hash (backward compatibility)
336
+ # @return [Hash] Returns the object in the form of hash
337
+ def to_body
338
+ to_hash
339
+ end
340
+
341
+ # Returns the object in the form of hash
342
+ # @return [Hash] Returns the object in the form of hash
343
+ def to_hash
344
+ hash = {}
345
+ self.class.attribute_map.each_pair do |attr, param|
346
+ value = self.send(attr)
347
+ if value.nil?
348
+ is_nullable = self.class.openapi_nullable.include?(attr)
349
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
350
+ end
351
+
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
+ end
375
+ end
@@ -0,0 +1,206 @@
1
+ =begin
2
+ #MELI Markeplace SDK
3
+
4
+ #This is a the codebase to generate a SDK for Open Platform Marketplace
5
+
6
+ The version of the OpenAPI document: 3.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Meli
16
+ class ItemPictures
17
+ attr_accessor :source
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'source' => :'source'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ :'source' => :'String'
30
+ }
31
+ end
32
+
33
+ # List of attributes with nullable: true
34
+ def self.openapi_nullable
35
+ Set.new([
36
+ ])
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(attributes = {})
42
+ if (!attributes.is_a?(Hash))
43
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Meli::ItemPictures` initialize method"
44
+ end
45
+
46
+ # check to see if the attribute exists and convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Meli::ItemPictures`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
50
+ end
51
+ h[k.to_sym] = v
52
+ }
53
+
54
+ if attributes.key?(:'source')
55
+ self.source = attributes[:'source']
56
+ end
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+ true
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(o)
75
+ return true if self.equal?(o)
76
+ self.class == o.class &&
77
+ source == o.source
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(o)
83
+ self == o
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Integer] Hash code
88
+ def hash
89
+ [source].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def self.build_from_hash(attributes)
96
+ new.build_from_hash(attributes)
97
+ end
98
+
99
+ # Builds the object from hash
100
+ # @param [Hash] attributes Model attributes in the form of hash
101
+ # @return [Object] Returns the model itself
102
+ def build_from_hash(attributes)
103
+ return nil unless attributes.is_a?(Hash)
104
+ self.class.openapi_types.each_pair do |key, type|
105
+ if type =~ /\AArray<(.*)>/i
106
+ # check to ensure the input is an array given that the attribute
107
+ # is documented as an array but the input is not
108
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
109
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
110
+ end
111
+ elsif !attributes[self.class.attribute_map[key]].nil?
112
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
113
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
114
+ end
115
+
116
+ self
117
+ end
118
+
119
+ # Deserializes the data based on type
120
+ # @param string type Data type
121
+ # @param string value Value to be deserialized
122
+ # @return [Object] Deserialized data
123
+ def _deserialize(type, value)
124
+ case type.to_sym
125
+ when :DateTime
126
+ DateTime.parse(value)
127
+ when :Date
128
+ Date.parse(value)
129
+ when :String
130
+ value.to_s
131
+ when :Integer
132
+ value.to_i
133
+ when :Float
134
+ value.to_f
135
+ when :Boolean
136
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
137
+ true
138
+ else
139
+ false
140
+ end
141
+ when :Object
142
+ # generic object (usually a Hash), return directly
143
+ value
144
+ when /\AArray<(?<inner_type>.+)>\z/
145
+ inner_type = Regexp.last_match[:inner_type]
146
+ value.map { |v| _deserialize(inner_type, v) }
147
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
148
+ k_type = Regexp.last_match[:k_type]
149
+ v_type = Regexp.last_match[:v_type]
150
+ {}.tap do |hash|
151
+ value.each do |k, v|
152
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
153
+ end
154
+ end
155
+ else # model
156
+ Meli.const_get(type).build_from_hash(value)
157
+ end
158
+ end
159
+
160
+ # Returns the string representation of the object
161
+ # @return [String] String presentation of the object
162
+ def to_s
163
+ to_hash.to_s
164
+ end
165
+
166
+ # to_body is an alias to to_hash (backward compatibility)
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_body
169
+ to_hash
170
+ end
171
+
172
+ # Returns the object in the form of hash
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_hash
175
+ hash = {}
176
+ self.class.attribute_map.each_pair do |attr, param|
177
+ value = self.send(attr)
178
+ if value.nil?
179
+ is_nullable = self.class.openapi_nullable.include?(attr)
180
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
181
+ end
182
+
183
+ hash[param] = _to_hash(value)
184
+ end
185
+ hash
186
+ end
187
+
188
+ # Outputs non-array value in the form of hash
189
+ # For object, use to_hash. Otherwise, just return the value
190
+ # @param [Object] value Any valid value
191
+ # @return [Hash] Returns the value in the form of hash
192
+ def _to_hash(value)
193
+ if value.is_a?(Array)
194
+ value.compact.map { |v| _to_hash(v) }
195
+ elsif value.is_a?(Hash)
196
+ {}.tap do |hash|
197
+ value.each { |k, v| hash[k] = _to_hash(v) }
198
+ end
199
+ elsif value.respond_to? :to_hash
200
+ value.to_hash
201
+ else
202
+ value
203
+ end
204
+ end
205
+ end
206
+ end