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,341 @@
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 'date'
12
+
13
+ module Tradenity
14
+ class Photo
15
+
16
+ def id=(id)
17
+ @id = id
18
+ end
19
+
20
+ def id
21
+ if instance_variable_defined?('@id') && @id != nil
22
+ @id
23
+ elsif __meta && __meta.href != nil
24
+ @id = __meta.href.split('/')[-1]
25
+ @id
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ attr_accessor :__meta
32
+
33
+ attr_accessor :created_at
34
+
35
+ attr_accessor :updated_at
36
+
37
+ attr_accessor :name
38
+
39
+ attr_accessor :title
40
+
41
+ attr_accessor :description
42
+
43
+ attr_accessor :position
44
+
45
+ attr_accessor :mime_type
46
+
47
+ attr_accessor :storage_type
48
+
49
+ attr_accessor :storage_path
50
+
51
+ attr_accessor :url
52
+
53
+ attr_accessor :account
54
+
55
+ # Attribute mapping from ruby-style variable name to JSON key.
56
+ def self.attribute_map
57
+ {
58
+ :'id' => :'id',
59
+ :'__meta' => :'__meta',
60
+ :'created_at' => :'createdAt',
61
+ :'updated_at' => :'updatedAt',
62
+ :'name' => :'name',
63
+ :'title' => :'title',
64
+ :'description' => :'description',
65
+ :'position' => :'position',
66
+ :'mime_type' => :'mimeType',
67
+ :'storage_type' => :'storageType',
68
+ :'storage_path' => :'storagePath',
69
+ :'url' => :'url',
70
+ :'account' => :'account'
71
+ }
72
+ end
73
+
74
+ # Attribute type mapping.
75
+ def self.swagger_types
76
+ {
77
+ :'id' => :'String',
78
+ :'__meta' => :'InstanceMeta',
79
+ :'created_at' => :'DateTime',
80
+ :'updated_at' => :'DateTime',
81
+ :'name' => :'String',
82
+ :'title' => :'String',
83
+ :'description' => :'String',
84
+ :'position' => :'Integer',
85
+ :'mime_type' => :'String',
86
+ :'storage_type' => :'String',
87
+ :'storage_path' => :'String',
88
+ :'url' => :'String',
89
+ :'account' => :'Account'
90
+ }
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ return unless attributes.is_a?(Hash)
97
+
98
+ # convert string to symbol for hash key
99
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
100
+ if attributes.has_key?(:'id')
101
+ self.id = attributes[:'id']
102
+ end
103
+
104
+ if attributes.has_key?(:'__meta')
105
+ self.__meta = attributes[:'__meta']
106
+ end
107
+
108
+ if attributes.has_key?(:'createdAt')
109
+ self.created_at = attributes[:'createdAt']
110
+ end
111
+ if attributes.has_key?(:'created_at')
112
+ self.created_at = attributes[:'created_at']
113
+ end
114
+
115
+ if attributes.has_key?(:'updatedAt')
116
+ self.updated_at = attributes[:'updatedAt']
117
+ end
118
+ if attributes.has_key?(:'updated_at')
119
+ self.updated_at = attributes[:'updated_at']
120
+ end
121
+
122
+ if attributes.has_key?(:'name')
123
+ self.name = attributes[:'name']
124
+ end
125
+
126
+ if attributes.has_key?(:'title')
127
+ self.title = attributes[:'title']
128
+ end
129
+
130
+ if attributes.has_key?(:'description')
131
+ self.description = attributes[:'description']
132
+ end
133
+
134
+ if attributes.has_key?(:'position')
135
+ self.position = attributes[:'position']
136
+ end
137
+
138
+ if attributes.has_key?(:'mimeType')
139
+ self.mime_type = attributes[:'mimeType']
140
+ end
141
+ if attributes.has_key?(:'mime_type')
142
+ self.mime_type = attributes[:'mime_type']
143
+ end
144
+
145
+ if attributes.has_key?(:'storageType')
146
+ self.storage_type = attributes[:'storageType']
147
+ end
148
+ if attributes.has_key?(:'storage_type')
149
+ self.storage_type = attributes[:'storage_type']
150
+ end
151
+
152
+ if attributes.has_key?(:'storagePath')
153
+ self.storage_path = attributes[:'storagePath']
154
+ end
155
+ if attributes.has_key?(:'storage_path')
156
+ self.storage_path = attributes[:'storage_path']
157
+ end
158
+
159
+ if attributes.has_key?(:'url')
160
+ self.url = attributes[:'url']
161
+ end
162
+
163
+ if attributes.has_key?(:'account')
164
+ self.account = attributes[:'account']
165
+ end
166
+ end
167
+
168
+ # Show invalid properties with the reasons. Usually used together with valid?
169
+ # @return Array for valid properties with the reasons
170
+ def list_invalid_properties
171
+ invalid_properties = Array.new
172
+ if @name.nil?
173
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
174
+ end
175
+
176
+ if @title.nil?
177
+ invalid_properties.push('invalid value for "title", title cannot be nil.')
178
+ end
179
+
180
+ if @mime_type.nil?
181
+ invalid_properties.push('invalid value for "mime_type", mime_type cannot be nil.')
182
+ end
183
+
184
+ if @storage_type.nil?
185
+ invalid_properties.push('invalid value for "storage_type", storage_type cannot be nil.')
186
+ end
187
+
188
+ if @storage_path.nil?
189
+ invalid_properties.push('invalid value for "storage_path", storage_path cannot be nil.')
190
+ end
191
+
192
+ invalid_properties
193
+ end
194
+
195
+ # Check to see if the all the properties in the model are valid
196
+ # @return true if the model is valid
197
+ def valid?
198
+ return false if @name.nil?
199
+ return false if @title.nil?
200
+ return false if @mime_type.nil?
201
+ return false if @storage_type.nil?
202
+ return false if @storage_path.nil?
203
+ true
204
+ end
205
+
206
+ # Checks equality by comparing each attribute.
207
+ # @param [Object] Object to be compared
208
+ def ==(o)
209
+ return true if self.equal?(o)
210
+ self.class == o.class &&
211
+ __meta == o.__meta &&
212
+ created_at == o.created_at &&
213
+ updated_at == o.updated_at &&
214
+ name == o.name &&
215
+ title == o.title &&
216
+ description == o.description &&
217
+ position == o.position &&
218
+ mime_type == o.mime_type &&
219
+ storage_type == o.storage_type &&
220
+ storage_path == o.storage_path &&
221
+ url == o.url &&
222
+ account == o.account
223
+ end
224
+
225
+ # @see the `==` method
226
+ # @param [Object] Object to be compared
227
+ def eql?(o)
228
+ self == o
229
+ end
230
+
231
+ # Calculates hash code according to all attributes.
232
+ # @return [Fixnum] Hash code
233
+ def hash
234
+ [__meta, created_at, updated_at, name, title, description, position, mime_type, storage_type, storage_path, url, account].hash
235
+ end
236
+
237
+ # Builds the object from hash
238
+ # @param [Hash] attributes Model attributes in the form of hash
239
+ # @return [Object] Returns the model itself
240
+ def build_from_hash(attributes)
241
+ return nil unless attributes.is_a?(Hash)
242
+ self.class.swagger_types.each_pair do |key, type|
243
+ if type =~ /\AArray<(.*)>/i
244
+ # check to ensure the input is an array given that the the attribute
245
+ # is documented as an array but the input is not
246
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
247
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
248
+ end
249
+ elsif !attributes[self.class.attribute_map[key]].nil?
250
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
251
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
252
+ end
253
+
254
+ self
255
+ end
256
+
257
+ # Deserializes the data based on type
258
+ # @param string type Data type
259
+ # @param string value Value to be deserialized
260
+ # @return [Object] Deserialized data
261
+ def _deserialize(type, value)
262
+ case type.to_sym
263
+ when :DateTime
264
+ DateTime.parse(value)
265
+ when :Date
266
+ Date.parse(value)
267
+ when :String
268
+ value.to_s
269
+ when :Integer
270
+ value.to_i
271
+ when :Float
272
+ value.to_f
273
+ when :BOOLEAN
274
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
275
+ true
276
+ else
277
+ false
278
+ end
279
+ when :Object
280
+ # generic object (usually a Hash), return directly
281
+ value
282
+ when /\AArray<(?<inner_type>.+)>\z/
283
+ inner_type = Regexp.last_match[:inner_type]
284
+ value.map { |v| _deserialize(inner_type, v) }
285
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
286
+ k_type = Regexp.last_match[:k_type]
287
+ v_type = Regexp.last_match[:v_type]
288
+ {}.tap do |hash|
289
+ value.each do |k, v|
290
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
291
+ end
292
+ end
293
+ else # model
294
+ temp_model = Tradenity.const_get(type).new
295
+ temp_model.build_from_hash(value)
296
+ end
297
+ end
298
+
299
+ # Returns the string representation of the object
300
+ # @return [String] String presentation of the object
301
+ def to_s
302
+ to_hash.to_s
303
+ end
304
+
305
+ # to_body is an alias to to_hash (backward compatibility)
306
+ # @return [Hash] Returns the object in the form of hash
307
+ def to_body
308
+ to_hash
309
+ end
310
+
311
+ # Returns the object in the form of hash
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_hash
314
+ hash = {}
315
+ self.class.attribute_map.each_pair do |attr, param|
316
+ value = self.send(attr)
317
+ next if value.nil?
318
+ hash[param] = _to_hash(value)
319
+ end
320
+ hash
321
+ end
322
+
323
+ # Outputs non-array value in the form of hash
324
+ # For object, use to_hash. Otherwise, just return the value
325
+ # @param [Object] value Any valid value
326
+ # @return [Hash] Returns the value in the form of hash
327
+ def _to_hash(value)
328
+ if value.is_a?(Array)
329
+ value.compact.map { |v| _to_hash(v) }
330
+ elsif value.is_a?(Hash)
331
+ {}.tap do |hash|
332
+ value.each { |k, v| hash[k] = _to_hash(v) }
333
+ end
334
+ elsif value.respond_to? :to_hash
335
+ value.to_hash
336
+ else
337
+ value
338
+ end
339
+ end
340
+ end
341
+ end