sezzle_client 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +611 -0
- data/Rakefile +8 -0
- data/docs/Address.md +14 -0
- data/docs/AllOfSessionCustomer.md +13 -0
- data/docs/AllOfSessionOrder.md +18 -0
- data/docs/Authorization.md +14 -0
- data/docs/BearerAuthenticationApi.md +52 -0
- data/docs/Body.md +8 -0
- data/docs/Body1.md +7 -0
- data/docs/Body2.md +6 -0
- data/docs/Body3.md +8 -0
- data/docs/Body4.md +8 -0
- data/docs/Capture.md +8 -0
- data/docs/Customer.md +13 -0
- data/docs/CustomerApi.md +269 -0
- data/docs/Discount.md +8 -0
- data/docs/Error.md +6 -0
- data/docs/ErrorInner.md +10 -0
- data/docs/InlineResponse200.md +10 -0
- data/docs/InlineResponse2001.md +15 -0
- data/docs/InlineResponse2002.md +9 -0
- data/docs/InlineResponse2003.md +15 -0
- data/docs/InlineResponse2004.md +8 -0
- data/docs/InlineResponse2005.md +12 -0
- data/docs/InlineResponse2006.md +7 -0
- data/docs/InlineResponse2007.md +14 -0
- data/docs/InlineResponse2008.md +8 -0
- data/docs/InlineResponse2009.md +7 -0
- data/docs/InlineResponse200Order.md +10 -0
- data/docs/InlineResponse201.md +9 -0
- data/docs/InlineResponse2011.md +10 -0
- data/docs/InlineResponse2011Order.md +9 -0
- data/docs/InlineResponse2011Tokenize.md +10 -0
- data/docs/InstallmentPlan.md +6 -0
- data/docs/Intent.md +6 -0
- data/docs/LineItem.md +10 -0
- data/docs/Link.md +9 -0
- data/docs/Notification.md +9 -0
- data/docs/Order.md +15 -0
- data/docs/OrderApi.md +391 -0
- data/docs/OrderAuthorization.md +12 -0
- data/docs/Payout.md +6 -0
- data/docs/PayoutInner.md +12 -0
- data/docs/Price.md +8 -0
- data/docs/Refund.md +8 -0
- data/docs/ReportsApi.md +230 -0
- data/docs/Session.md +10 -0
- data/docs/SessionApi.md +113 -0
- data/docs/SessionCancelUrl.md +8 -0
- data/docs/SessionStatus.md +8 -0
- data/docs/Token.md +10 -0
- data/docs/TokenApi.md +110 -0
- data/docs/Webhook.md +8 -0
- data/docs/WebhooksApi.md +157 -0
- data/git_push.sh +55 -0
- data/lib/sezzle_client.rb +90 -0
- data/lib/sezzle_client/api/bearer_authentication_api.rb +76 -0
- data/lib/sezzle_client/api/customer_api.rb +295 -0
- data/lib/sezzle_client/api/order_api.rb +430 -0
- data/lib/sezzle_client/api/reports_api.rb +253 -0
- data/lib/sezzle_client/api/session_api.rb +132 -0
- data/lib/sezzle_client/api/token_api.rb +126 -0
- data/lib/sezzle_client/api/webhooks_api.rb +178 -0
- data/lib/sezzle_client/api_client.rb +388 -0
- data/lib/sezzle_client/api_error.rb +57 -0
- data/lib/sezzle_client/configuration.rb +205 -0
- data/lib/sezzle_client/models/address.rb +297 -0
- data/lib/sezzle_client/models/all_of_session_customer.rb +260 -0
- data/lib/sezzle_client/models/all_of_session_order.rb +314 -0
- data/lib/sezzle_client/models/authorization.rb +281 -0
- data/lib/sezzle_client/models/body.rb +215 -0
- data/lib/sezzle_client/models/body_1.rb +206 -0
- data/lib/sezzle_client/models/body_2.rb +197 -0
- data/lib/sezzle_client/models/body_3.rb +215 -0
- data/lib/sezzle_client/models/body_4.rb +215 -0
- data/lib/sezzle_client/models/capture.rb +215 -0
- data/lib/sezzle_client/models/customer.rb +260 -0
- data/lib/sezzle_client/models/discount.rb +225 -0
- data/lib/sezzle_client/models/error.rb +201 -0
- data/lib/sezzle_client/models/error_inner.rb +233 -0
- data/lib/sezzle_client/models/inline_response_200.rb +239 -0
- data/lib/sezzle_client/models/inline_response_200_1.rb +286 -0
- data/lib/sezzle_client/models/inline_response_200_2.rb +226 -0
- data/lib/sezzle_client/models/inline_response_200_3.rb +284 -0
- data/lib/sezzle_client/models/inline_response_200_4.rb +215 -0
- data/lib/sezzle_client/models/inline_response_200_5.rb +257 -0
- data/lib/sezzle_client/models/inline_response_200_6.rb +206 -0
- data/lib/sezzle_client/models/inline_response_200_7.rb +277 -0
- data/lib/sezzle_client/models/inline_response_200_8.rb +217 -0
- data/lib/sezzle_client/models/inline_response_200_9.rb +206 -0
- data/lib/sezzle_client/models/inline_response_200_order.rb +235 -0
- data/lib/sezzle_client/models/inline_response_201.rb +224 -0
- data/lib/sezzle_client/models/inline_response_201_1.rb +235 -0
- data/lib/sezzle_client/models/inline_response_201_1_order.rb +226 -0
- data/lib/sezzle_client/models/inline_response_201_1_tokenize.rb +235 -0
- data/lib/sezzle_client/models/installment_plan.rb +28 -0
- data/lib/sezzle_client/models/intent.rb +28 -0
- data/lib/sezzle_client/models/line_item.rb +253 -0
- data/lib/sezzle_client/models/link.rb +224 -0
- data/lib/sezzle_client/models/notification.rb +224 -0
- data/lib/sezzle_client/models/order.rb +284 -0
- data/lib/sezzle_client/models/order_authorization.rb +257 -0
- data/lib/sezzle_client/models/payout.rb +201 -0
- data/lib/sezzle_client/models/payout_inner.rb +251 -0
- data/lib/sezzle_client/models/price.rb +225 -0
- data/lib/sezzle_client/models/refund.rb +215 -0
- data/lib/sezzle_client/models/session.rb +243 -0
- data/lib/sezzle_client/models/session_cancel_url.rb +215 -0
- data/lib/sezzle_client/models/session_status.rb +217 -0
- data/lib/sezzle_client/models/token.rb +235 -0
- data/lib/sezzle_client/models/webhook.rb +222 -0
- data/lib/sezzle_client/version.rb +14 -0
- data/sezzle_client.gemspec +38 -0
- data/spec/.DS_Store +0 -0
- data/spec/api/bearer_authentication_api_spec.rb +45 -0
- data/spec/api/customer_api_spec.rb +91 -0
- data/spec/api/order_api_spec.rb +119 -0
- data/spec/api/reports_api_spec.rb +84 -0
- data/spec/api/session_api_spec.rb +57 -0
- data/spec/api/token_api_spec.rb +56 -0
- data/spec/api/webhooks_api_spec.rb +66 -0
- data/spec/api_client_spec.rb +225 -0
- data/spec/base_object_spec.rb +109 -0
- data/spec/configuration_spec.rb +41 -0
- data/spec/models/address_spec.rb +82 -0
- data/spec/models/all_of_session_customer_spec.rb +76 -0
- data/spec/models/all_of_session_order_spec.rb +106 -0
- data/spec/models/authorization_spec.rb +82 -0
- data/spec/models/body_1_spec.rb +40 -0
- data/spec/models/body_2_spec.rb +34 -0
- data/spec/models/body_3_spec.rb +46 -0
- data/spec/models/body_4_spec.rb +46 -0
- data/spec/models/body_spec.rb +46 -0
- data/spec/models/capture_spec.rb +46 -0
- data/spec/models/customer_spec.rb +76 -0
- data/spec/models/discount_spec.rb +46 -0
- data/spec/models/error_inner_spec.rb +58 -0
- data/spec/models/error_spec.rb +34 -0
- data/spec/models/inline_response_200_1_spec.rb +88 -0
- data/spec/models/inline_response_200_2_spec.rb +52 -0
- data/spec/models/inline_response_200_3_spec.rb +88 -0
- data/spec/models/inline_response_200_4_spec.rb +46 -0
- data/spec/models/inline_response_200_5_spec.rb +70 -0
- data/spec/models/inline_response_200_6_spec.rb +40 -0
- data/spec/models/inline_response_200_7_spec.rb +82 -0
- data/spec/models/inline_response_200_8_spec.rb +46 -0
- data/spec/models/inline_response_200_9_spec.rb +40 -0
- data/spec/models/inline_response_200_order_spec.rb +58 -0
- data/spec/models/inline_response_200_spec.rb +58 -0
- data/spec/models/inline_response_201_1_order_spec.rb +52 -0
- data/spec/models/inline_response_201_1_spec.rb +58 -0
- data/spec/models/inline_response_201_1_tokenize_spec.rb +58 -0
- data/spec/models/inline_response_201_spec.rb +52 -0
- data/spec/models/installment_plan_spec.rb +34 -0
- data/spec/models/intent_spec.rb +34 -0
- data/spec/models/line_item_spec.rb +58 -0
- data/spec/models/link_spec.rb +52 -0
- data/spec/models/notification_spec.rb +52 -0
- data/spec/models/order_authorization_spec.rb +70 -0
- data/spec/models/order_spec.rb +88 -0
- data/spec/models/payout_inner_spec.rb +70 -0
- data/spec/models/payout_spec.rb +34 -0
- data/spec/models/price_spec.rb +46 -0
- data/spec/models/refund_spec.rb +46 -0
- data/spec/models/session_cancel_url_spec.rb +46 -0
- data/spec/models/session_spec.rb +58 -0
- data/spec/models/session_status_spec.rb +46 -0
- data/spec/models/token_spec.rb +58 -0
- data/spec/models/webhook_spec.rb +46 -0
- data/spec/spec_helper.rb +110 -0
- metadata +331 -0
@@ -0,0 +1,257 @@
|
|
1
|
+
=begin
|
2
|
+
#Sezzle API
|
3
|
+
|
4
|
+
#The Sezzle API is intended for merchants interested in accepting Sezzle Pay as a payment option.
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.25
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module SezzleClient
|
15
|
+
class OrderAuthorization
|
16
|
+
attr_accessor :authorization_amount
|
17
|
+
|
18
|
+
attr_accessor :approved
|
19
|
+
|
20
|
+
attr_accessor :expiration
|
21
|
+
|
22
|
+
attr_accessor :releases
|
23
|
+
|
24
|
+
attr_accessor :captures
|
25
|
+
|
26
|
+
attr_accessor :refunds
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
:'authorization_amount' => :'authorization_amount',
|
32
|
+
:'approved' => :'approved',
|
33
|
+
:'expiration' => :'expiration',
|
34
|
+
:'releases' => :'releases',
|
35
|
+
:'captures' => :'captures',
|
36
|
+
:'refunds' => :'refunds'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Attribute type mapping.
|
41
|
+
def self.openapi_types
|
42
|
+
{
|
43
|
+
:'authorization_amount' => :'Object',
|
44
|
+
:'approved' => :'Object',
|
45
|
+
:'expiration' => :'Object',
|
46
|
+
:'releases' => :'Object',
|
47
|
+
:'captures' => :'Object',
|
48
|
+
:'refunds' => :'Object'
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
# List of attributes with nullable: true
|
53
|
+
def self.openapi_nullable
|
54
|
+
Set.new([
|
55
|
+
])
|
56
|
+
end
|
57
|
+
|
58
|
+
# Initializes the object
|
59
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
60
|
+
def initialize(attributes = {})
|
61
|
+
if (!attributes.is_a?(Hash))
|
62
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SezzleClient::OrderAuthorization` initialize method"
|
63
|
+
end
|
64
|
+
|
65
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
66
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
67
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
68
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SezzleClient::OrderAuthorization`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
69
|
+
end
|
70
|
+
h[k.to_sym] = v
|
71
|
+
}
|
72
|
+
|
73
|
+
if attributes.key?(:'authorization_amount')
|
74
|
+
self.authorization_amount = attributes[:'authorization_amount']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:'approved')
|
78
|
+
self.approved = attributes[:'approved']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.key?(:'expiration')
|
82
|
+
self.expiration = attributes[:'expiration']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'releases')
|
86
|
+
if (value = attributes[:'releases']).is_a?(Array)
|
87
|
+
self.releases = value
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.key?(:'captures')
|
92
|
+
if (value = attributes[:'captures']).is_a?(Array)
|
93
|
+
self.captures = value
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'refunds')
|
98
|
+
if (value = attributes[:'refunds']).is_a?(Array)
|
99
|
+
self.refunds = value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
105
|
+
# @return Array for valid properties with the reasons
|
106
|
+
def list_invalid_properties
|
107
|
+
invalid_properties = Array.new
|
108
|
+
invalid_properties
|
109
|
+
end
|
110
|
+
|
111
|
+
# Check to see if the all the properties in the model are valid
|
112
|
+
# @return true if the model is valid
|
113
|
+
def valid?
|
114
|
+
true
|
115
|
+
end
|
116
|
+
|
117
|
+
# Checks equality by comparing each attribute.
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def ==(o)
|
120
|
+
return true if self.equal?(o)
|
121
|
+
self.class == o.class &&
|
122
|
+
authorization_amount == o.authorization_amount &&
|
123
|
+
approved == o.approved &&
|
124
|
+
expiration == o.expiration &&
|
125
|
+
releases == o.releases &&
|
126
|
+
captures == o.captures &&
|
127
|
+
refunds == o.refunds
|
128
|
+
end
|
129
|
+
|
130
|
+
# @see the `==` method
|
131
|
+
# @param [Object] Object to be compared
|
132
|
+
def eql?(o)
|
133
|
+
self == o
|
134
|
+
end
|
135
|
+
|
136
|
+
# Calculates hash code according to all attributes.
|
137
|
+
# @return [Integer] Hash code
|
138
|
+
def hash
|
139
|
+
[authorization_amount, approved, expiration, releases, captures, refunds].hash
|
140
|
+
end
|
141
|
+
|
142
|
+
# Builds the object from hash
|
143
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
144
|
+
# @return [Object] Returns the model itself
|
145
|
+
def self.build_from_hash(attributes)
|
146
|
+
new.build_from_hash(attributes)
|
147
|
+
end
|
148
|
+
|
149
|
+
# Builds the object from hash
|
150
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
151
|
+
# @return [Object] Returns the model itself
|
152
|
+
def build_from_hash(attributes)
|
153
|
+
return nil unless attributes.is_a?(Hash)
|
154
|
+
self.class.openapi_types.each_pair do |key, type|
|
155
|
+
if type =~ /\AArray<(.*)>/i
|
156
|
+
# check to ensure the input is an array given that the attribute
|
157
|
+
# is documented as an array but the input is not
|
158
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
159
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
160
|
+
end
|
161
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
162
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
163
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
164
|
+
self.send("#{key}=", nil)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
self
|
169
|
+
end
|
170
|
+
|
171
|
+
# Deserializes the data based on type
|
172
|
+
# @param string type Data type
|
173
|
+
# @param string value Value to be deserialized
|
174
|
+
# @return [Object] Deserialized data
|
175
|
+
def _deserialize(type, value)
|
176
|
+
case type.to_sym
|
177
|
+
when :DateTime
|
178
|
+
DateTime.parse(value)
|
179
|
+
when :Date
|
180
|
+
Date.parse(value)
|
181
|
+
when :String
|
182
|
+
value.to_s
|
183
|
+
when :Integer
|
184
|
+
value.to_i
|
185
|
+
when :Float
|
186
|
+
value.to_f
|
187
|
+
when :Boolean
|
188
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
189
|
+
true
|
190
|
+
else
|
191
|
+
false
|
192
|
+
end
|
193
|
+
when :Object
|
194
|
+
# generic object (usually a Hash), return directly
|
195
|
+
value
|
196
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
197
|
+
inner_type = Regexp.last_match[:inner_type]
|
198
|
+
value.map { |v| _deserialize(inner_type, v) }
|
199
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
200
|
+
k_type = Regexp.last_match[:k_type]
|
201
|
+
v_type = Regexp.last_match[:v_type]
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each do |k, v|
|
204
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else # model
|
208
|
+
SezzleClient.const_get(type).build_from_hash(value)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the string representation of the object
|
213
|
+
# @return [String] String presentation of the object
|
214
|
+
def to_s
|
215
|
+
to_hash.to_s
|
216
|
+
end
|
217
|
+
|
218
|
+
# to_body is an alias to to_hash (backward compatibility)
|
219
|
+
# @return [Hash] Returns the object in the form of hash
|
220
|
+
def to_body
|
221
|
+
to_hash
|
222
|
+
end
|
223
|
+
|
224
|
+
# Returns the object in the form of hash
|
225
|
+
# @return [Hash] Returns the object in the form of hash
|
226
|
+
def to_hash
|
227
|
+
hash = {}
|
228
|
+
self.class.attribute_map.each_pair do |attr, param|
|
229
|
+
value = self.send(attr)
|
230
|
+
if value.nil?
|
231
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
232
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
233
|
+
end
|
234
|
+
|
235
|
+
hash[param] = _to_hash(value)
|
236
|
+
end
|
237
|
+
hash
|
238
|
+
end
|
239
|
+
|
240
|
+
# Outputs non-array value in the form of hash
|
241
|
+
# For object, use to_hash. Otherwise, just return the value
|
242
|
+
# @param [Object] value Any valid value
|
243
|
+
# @return [Hash] Returns the value in the form of hash
|
244
|
+
def _to_hash(value)
|
245
|
+
if value.is_a?(Array)
|
246
|
+
value.compact.map { |v| _to_hash(v) }
|
247
|
+
elsif value.is_a?(Hash)
|
248
|
+
{}.tap do |hash|
|
249
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
250
|
+
end
|
251
|
+
elsif value.respond_to? :to_hash
|
252
|
+
value.to_hash
|
253
|
+
else
|
254
|
+
value
|
255
|
+
end
|
256
|
+
end end
|
257
|
+
end
|
@@ -0,0 +1,201 @@
|
|
1
|
+
=begin
|
2
|
+
#Sezzle API
|
3
|
+
|
4
|
+
#The Sezzle API is intended for merchants interested in accepting Sezzle Pay as a payment option.
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.0.0
|
7
|
+
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 3.0.25
|
10
|
+
=end
|
11
|
+
|
12
|
+
require 'date'
|
13
|
+
|
14
|
+
module SezzleClient
|
15
|
+
class Payout
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# Attribute type mapping.
|
23
|
+
def self.openapi_types
|
24
|
+
{
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# List of attributes with nullable: true
|
29
|
+
def self.openapi_nullable
|
30
|
+
Set.new([
|
31
|
+
])
|
32
|
+
end
|
33
|
+
|
34
|
+
# Initializes the object
|
35
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
36
|
+
def initialize(attributes = {})
|
37
|
+
if (!attributes.is_a?(Hash))
|
38
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SezzleClient::Payout` initialize method"
|
39
|
+
end
|
40
|
+
|
41
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
42
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
43
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
44
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SezzleClient::Payout`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
45
|
+
end
|
46
|
+
h[k.to_sym] = v
|
47
|
+
}
|
48
|
+
|
49
|
+
# call parent's initialize
|
50
|
+
super(attributes)
|
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 = super
|
57
|
+
invalid_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check to see if the all the properties in the model are valid
|
61
|
+
# @return true if the model is valid
|
62
|
+
def valid?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(o)
|
69
|
+
return true if self.equal?(o)
|
70
|
+
self.class == o.class && super(o)
|
71
|
+
end
|
72
|
+
|
73
|
+
# @see the `==` method
|
74
|
+
# @param [Object] Object to be compared
|
75
|
+
def eql?(o)
|
76
|
+
self == o
|
77
|
+
end
|
78
|
+
|
79
|
+
# Calculates hash code according to all attributes.
|
80
|
+
# @return [Integer] Hash code
|
81
|
+
def hash
|
82
|
+
[].hash
|
83
|
+
end
|
84
|
+
|
85
|
+
# Builds the object from hash
|
86
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
87
|
+
# @return [Object] Returns the model itself
|
88
|
+
def self.build_from_hash(attributes)
|
89
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
96
|
+
return nil unless attributes.is_a?(Hash)
|
97
|
+
super(attributes)
|
98
|
+
self.class.openapi_types.each_pair do |key, type|
|
99
|
+
if type =~ /\AArray<(.*)>/i
|
100
|
+
# check to ensure the input is an array given that the attribute
|
101
|
+
# is documented as an array but the input is not
|
102
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
103
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
104
|
+
end
|
105
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
106
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
107
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
108
|
+
self.send("#{key}=", nil)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
self
|
113
|
+
end
|
114
|
+
|
115
|
+
# Deserializes the data based on type
|
116
|
+
# @param string type Data type
|
117
|
+
# @param string value Value to be deserialized
|
118
|
+
# @return [Object] Deserialized data
|
119
|
+
def _deserialize(type, value)
|
120
|
+
case type.to_sym
|
121
|
+
when :DateTime
|
122
|
+
DateTime.parse(value)
|
123
|
+
when :Date
|
124
|
+
Date.parse(value)
|
125
|
+
when :String
|
126
|
+
value.to_s
|
127
|
+
when :Integer
|
128
|
+
value.to_i
|
129
|
+
when :Float
|
130
|
+
value.to_f
|
131
|
+
when :Boolean
|
132
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
133
|
+
true
|
134
|
+
else
|
135
|
+
false
|
136
|
+
end
|
137
|
+
when :Object
|
138
|
+
# generic object (usually a Hash), return directly
|
139
|
+
value
|
140
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
141
|
+
inner_type = Regexp.last_match[:inner_type]
|
142
|
+
value.map { |v| _deserialize(inner_type, v) }
|
143
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
144
|
+
k_type = Regexp.last_match[:k_type]
|
145
|
+
v_type = Regexp.last_match[:v_type]
|
146
|
+
{}.tap do |hash|
|
147
|
+
value.each do |k, v|
|
148
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
else # model
|
152
|
+
SezzleClient.const_get(type).build_from_hash(value)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# Returns the string representation of the object
|
157
|
+
# @return [String] String presentation of the object
|
158
|
+
def to_s
|
159
|
+
to_hash.to_s
|
160
|
+
end
|
161
|
+
|
162
|
+
# to_body is an alias to to_hash (backward compatibility)
|
163
|
+
# @return [Hash] Returns the object in the form of hash
|
164
|
+
def to_body
|
165
|
+
to_hash
|
166
|
+
end
|
167
|
+
|
168
|
+
# Returns the object in the form of hash
|
169
|
+
# @return [Hash] Returns the object in the form of hash
|
170
|
+
def to_hash
|
171
|
+
hash = super
|
172
|
+
self.class.attribute_map.each_pair do |attr, param|
|
173
|
+
value = self.send(attr)
|
174
|
+
if value.nil?
|
175
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
176
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
177
|
+
end
|
178
|
+
|
179
|
+
hash[param] = _to_hash(value)
|
180
|
+
end
|
181
|
+
hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Outputs non-array value in the form of hash
|
185
|
+
# For object, use to_hash. Otherwise, just return the value
|
186
|
+
# @param [Object] value Any valid value
|
187
|
+
# @return [Hash] Returns the value in the form of hash
|
188
|
+
def _to_hash(value)
|
189
|
+
if value.is_a?(Array)
|
190
|
+
value.compact.map { |v| _to_hash(v) }
|
191
|
+
elsif value.is_a?(Hash)
|
192
|
+
{}.tap do |hash|
|
193
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
194
|
+
end
|
195
|
+
elsif value.respond_to? :to_hash
|
196
|
+
value.to_hash
|
197
|
+
else
|
198
|
+
value
|
199
|
+
end
|
200
|
+
end end
|
201
|
+
end
|