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,38 @@
1
+ module Tradenity
2
+
3
+ class Page < Array
4
+
5
+ attr_accessor :total_pages
6
+
7
+ attr_accessor :total_elements
8
+
9
+ attr_accessor :number
10
+
11
+ attr_accessor :size
12
+
13
+ attr_accessor :number_of_elements
14
+
15
+ def initialize(content=[], total_pages, total_elements, number, size, number_of_elements)
16
+ concat(content)
17
+ @total_pages = total_pages
18
+ @total_elements = total_elements
19
+ @number = number
20
+ @size = size
21
+ @number_of_elements = number_of_elements
22
+ end
23
+
24
+ def is_empty?
25
+ @size <= 0
26
+ end
27
+
28
+ end
29
+
30
+
31
+ class PageRequest
32
+ def initialize(page, size)
33
+ @page_number = page
34
+ @page_size = size
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,429 @@
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 Payment
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 :amount
39
+
40
+ attr_accessor :order
41
+
42
+ attr_accessor :payment_source
43
+
44
+ attr_accessor :currency
45
+
46
+ attr_accessor :status
47
+
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'id' => :'id',
74
+ :'__meta' => :'__meta',
75
+ :'created_at' => :'createdAt',
76
+ :'updated_at' => :'updatedAt',
77
+ :'amount' => :'amount',
78
+ :'order' => :'order',
79
+ :'payment_source' => :'paymentSource',
80
+ :'currency' => :'currency',
81
+ :'status' => :'status'
82
+ }
83
+ end
84
+
85
+ # Attribute type mapping.
86
+ def self.swagger_types
87
+ {
88
+ :'id' => :'String',
89
+ :'__meta' => :'InstanceMeta',
90
+ :'created_at' => :'DateTime',
91
+ :'updated_at' => :'DateTime',
92
+ :'amount' => :'Integer',
93
+ :'order' => :'Order',
94
+ :'payment_source' => :'PaymentSource',
95
+ :'currency' => :'Currency',
96
+ :'status' => :'String'
97
+ }
98
+ end
99
+
100
+ # Initializes the object
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ def initialize(attributes = {})
103
+ return unless attributes.is_a?(Hash)
104
+
105
+ # convert string to symbol for hash key
106
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
107
+ if attributes.has_key?(:'id')
108
+ self.id = attributes[:'id']
109
+ end
110
+
111
+ if attributes.has_key?(:'__meta')
112
+ self.__meta = attributes[:'__meta']
113
+ end
114
+
115
+ if attributes.has_key?(:'createdAt')
116
+ self.created_at = attributes[:'createdAt']
117
+ end
118
+
119
+ if attributes.has_key?(:'created_at')
120
+ self.created_at = attributes[:'created_at']
121
+ end
122
+
123
+ if attributes.has_key?(:'updatedAt')
124
+ self.updated_at = attributes[:'updatedAt']
125
+ end
126
+
127
+ if attributes.has_key?(:'updated_at')
128
+ self.updated_at = attributes[:'updated_at']
129
+ end
130
+
131
+ if attributes.has_key?(:'amount')
132
+ self.amount = attributes[:'amount']
133
+ end
134
+
135
+ if attributes.has_key?(:'order')
136
+ self.order = attributes[:'order']
137
+ end
138
+
139
+ if attributes.has_key?(:'paymentSource')
140
+ self.payment_source = attributes[:'paymentSource']
141
+ end
142
+
143
+ if attributes.has_key?(:'payment_source')
144
+ self.payment_source = attributes[:'payment_source']
145
+ end
146
+
147
+ if attributes.has_key?(:'currency')
148
+ self.currency = attributes[:'currency']
149
+ end
150
+
151
+ if attributes.has_key?(:'status')
152
+ self.status = attributes[:'status']
153
+ end
154
+ end
155
+
156
+ # Show invalid properties with the reasons. Usually used together with valid?
157
+ # @return Array for valid properties with the reasons
158
+ def list_invalid_properties
159
+ invalid_properties = Array.new
160
+ if @amount.nil?
161
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
162
+ end
163
+
164
+ if @order.nil?
165
+ invalid_properties.push('invalid value for "order", order cannot be nil.')
166
+ end
167
+
168
+ if @payment_source.nil?
169
+ invalid_properties.push('invalid value for "payment_source", payment_source cannot be nil.')
170
+ end
171
+
172
+ if @currency.nil?
173
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
174
+ end
175
+
176
+ if @status.nil?
177
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
178
+ end
179
+
180
+ invalid_properties
181
+ end
182
+
183
+ # Check to see if the all the properties in the model are valid
184
+ # @return true if the model is valid
185
+ def valid?
186
+ return false if @amount.nil?
187
+ return false if @order.nil?
188
+ return false if @payment_source.nil?
189
+ return false if @currency.nil?
190
+ return false if @status.nil?
191
+ status_validator = EnumAttributeValidator.new('String', ['pending', 'awaitingRetry', 'successful', 'failed'])
192
+ return false unless status_validator.valid?(@status)
193
+ true
194
+ end
195
+
196
+ # Custom attribute writer method checking allowed values (enum).
197
+ # @param [Object] status Object to be assigned
198
+ def status=(status)
199
+ validator = EnumAttributeValidator.new('String', ['pending', 'awaitingRetry', 'successful', 'failed'])
200
+ unless validator.valid?(status)
201
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
202
+ end
203
+ @status = status
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
+ amount == o.amount &&
215
+ order == o.order &&
216
+ payment_source == o.payment_source &&
217
+ currency == o.currency &&
218
+ status == o.status
219
+ end
220
+
221
+ # @see the `==` method
222
+ # @param [Object] Object to be compared
223
+ def eql?(o)
224
+ self == o
225
+ end
226
+
227
+ # Calculates hash code according to all attributes.
228
+ # @return [Fixnum] Hash code
229
+ def hash
230
+ [__meta, created_at, updated_at, amount, order, payment_source, currency, status].hash
231
+ end
232
+
233
+ # Builds the object from hash
234
+ # @param [Hash] attributes Model attributes in the form of hash
235
+ # @return [Object] Returns the model itself
236
+ def build_from_hash(attributes)
237
+ return nil unless attributes.is_a?(Hash)
238
+ self.class.swagger_types.each_pair do |key, type|
239
+ if type =~ /\AArray<(.*)>/i
240
+ # check to ensure the input is an array given that the the attribute
241
+ # is documented as an array but the input is not
242
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
243
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
244
+ end
245
+ elsif !attributes[self.class.attribute_map[key]].nil?
246
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
247
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
248
+ end
249
+
250
+ self
251
+ end
252
+
253
+ # Deserializes the data based on type
254
+ # @param string type Data type
255
+ # @param string value Value to be deserialized
256
+ # @return [Object] Deserialized data
257
+ def _deserialize(type, value)
258
+ case type.to_sym
259
+ when :DateTime
260
+ DateTime.parse(value)
261
+ when :Date
262
+ Date.parse(value)
263
+ when :String
264
+ value.to_s
265
+ when :Integer
266
+ value.to_i
267
+ when :Float
268
+ value.to_f
269
+ when :BOOLEAN
270
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
271
+ true
272
+ else
273
+ false
274
+ end
275
+ when :Object
276
+ # generic object (usually a Hash), return directly
277
+ value
278
+ when /\AArray<(?<inner_type>.+)>\z/
279
+ inner_type = Regexp.last_match[:inner_type]
280
+ value.map { |v| _deserialize(inner_type, v) }
281
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
282
+ k_type = Regexp.last_match[:k_type]
283
+ v_type = Regexp.last_match[:v_type]
284
+ {}.tap do |hash|
285
+ value.each do |k, v|
286
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
287
+ end
288
+ end
289
+ else # model
290
+ temp_model = Tradenity.const_get(type).new
291
+ temp_model.build_from_hash(value)
292
+ end
293
+ end
294
+
295
+ # Returns the string representation of the object
296
+ # @return [String] String presentation of the object
297
+ def to_s
298
+ to_hash.to_s
299
+ end
300
+
301
+ # to_body is an alias to to_hash (backward compatibility)
302
+ # @return [Hash] Returns the object in the form of hash
303
+ def to_body
304
+ to_hash
305
+ end
306
+
307
+ # Returns the object in the form of hash
308
+ # @return [Hash] Returns the object in the form of hash
309
+ def to_hash
310
+ hash = {}
311
+ self.class.attribute_map.each_pair do |attr, param|
312
+ value = self.send(attr)
313
+ next if value.nil?
314
+ hash[param] = _to_hash(value)
315
+ end
316
+ hash
317
+ end
318
+
319
+ # Outputs non-array value in the form of hash
320
+ # For object, use to_hash. Otherwise, just return the value
321
+ # @param [Object] value Any valid value
322
+ # @return [Hash] Returns the value in the form of hash
323
+ def _to_hash(value)
324
+ if value.is_a?(Array)
325
+ value.compact.map { |v| _to_hash(v) }
326
+ elsif value.is_a?(Hash)
327
+ {}.tap do |hash|
328
+ value.each { |k, v| hash[k] = _to_hash(v) }
329
+ end
330
+ elsif value.respond_to? :to_hash
331
+ value.to_hash
332
+ else
333
+ value
334
+ end
335
+ end
336
+
337
+
338
+ def self.api_client
339
+ ApiClient.default
340
+ end
341
+
342
+
343
+ class << self
344
+
345
+ # List Payments
346
+ # Return a list of Payments
347
+ # @param [Hash] opts the optional parameters
348
+ # @return [Page<Payment>]
349
+ def find_all
350
+ list_all_payments
351
+ end
352
+
353
+ # Find List of Payment
354
+ # Return multiple instances of Payment by its attributes.
355
+ # @param [Hash] opts the search parameters
356
+ # @return [Page<Collection>]
357
+ def find_all_by(opts = {})
358
+ list_all_payments(opts)
359
+ end
360
+
361
+ # Find Payment by its parameters
362
+ # Return single instance of Collection by its attributes.
363
+ # @param [Hash] opts search parameters
364
+ # @return [Payment]
365
+ def find_one_by(opts = {})
366
+ list_all_payments(opts)[0]
367
+ end
368
+
369
+
370
+ # List Payments
371
+ # Return a list of Payments
372
+ # @param [Hash] opts the optional parameters
373
+ # @option opts [Integer] :page page number
374
+ # @option opts [Integer] :size page size
375
+ # @option opts [String] :sort page order
376
+ # @return [Page<Payment>]
377
+ def list_all_payments(opts = {})
378
+ data, _status_code, _headers = list_all_payments_with_http_info(opts)
379
+ data
380
+ end
381
+
382
+ # List Payments
383
+ # Return a list of Payments
384
+ # @param [Hash] opts the optional parameters
385
+ # @option opts [Integer] :page page number
386
+ # @option opts [Integer] :size page size
387
+ # @option opts [String] :sort page order
388
+ # @return [Array<(Page<Payment>, Fixnum, Hash)>] Page<Payment> data, response status code and response headers
389
+ def list_all_payments_with_http_info(opts = {})
390
+ if api_client.config.debugging
391
+ api_client.config.logger.debug 'Calling API: Payment.list_all_payments ...'
392
+ end
393
+ # resource path
394
+ local_var_path = '/payments'
395
+
396
+ # query parameters
397
+ query_params = opts
398
+ # query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
399
+ # query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
400
+ # query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
401
+
402
+ # header parameters
403
+ header_params = {}
404
+ # HTTP header 'Accept' (if needed)
405
+ header_params['Accept'] = api_client.select_header_accept(['application/json'])
406
+ # HTTP header 'Content-Type'
407
+ header_params['Content-Type'] = api_client.select_header_content_type(['application/json'])
408
+
409
+ # form parameters
410
+ form_params = {}
411
+
412
+ # http body (model)
413
+ post_body = nil
414
+ auth_names = []
415
+ data, status_code, headers = api_client.call_api(:GET, local_var_path,
416
+ :header_params => header_params,
417
+ :query_params => query_params,
418
+ :form_params => form_params,
419
+ :body => post_body,
420
+ :auth_names => auth_names,
421
+ :return_type => 'Page<Payment>')
422
+ if api_client.config.debugging
423
+ api_client.config.logger.debug "API called: Payment#list_all_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
424
+ end
425
+ return data, status_code, headers
426
+ end
427
+ end
428
+ end
429
+ end