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