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,57 @@
|
|
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
|
+
module SezzleClient
|
13
|
+
class ApiError < StandardError
|
14
|
+
attr_reader :code, :response_headers, :response_body
|
15
|
+
|
16
|
+
# Usage examples:
|
17
|
+
# ApiError.new
|
18
|
+
# ApiError.new("message")
|
19
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
20
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
21
|
+
def initialize(arg = nil)
|
22
|
+
if arg.is_a? Hash
|
23
|
+
if arg.key?(:message) || arg.key?('message')
|
24
|
+
super(arg[:message] || arg['message'])
|
25
|
+
else
|
26
|
+
super arg
|
27
|
+
end
|
28
|
+
|
29
|
+
arg.each do |k, v|
|
30
|
+
instance_variable_set "@#{k}", v
|
31
|
+
end
|
32
|
+
else
|
33
|
+
super arg
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Override to_s to display a friendly error message
|
38
|
+
def to_s
|
39
|
+
message
|
40
|
+
end
|
41
|
+
|
42
|
+
def message
|
43
|
+
if @message.nil?
|
44
|
+
msg = "Error message: the server returns an error"
|
45
|
+
else
|
46
|
+
msg = @message
|
47
|
+
end
|
48
|
+
|
49
|
+
msg += "\nHTTP status code: #{code}" if code
|
50
|
+
msg += "\nResponse headers: #{response_headers}" if response_headers
|
51
|
+
msg += "\nResponse body: #{response_body}" if response_body
|
52
|
+
|
53
|
+
msg
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,205 @@
|
|
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
|
+
module SezzleClient
|
13
|
+
class Configuration
|
14
|
+
# Defines url scheme
|
15
|
+
attr_accessor :scheme
|
16
|
+
|
17
|
+
# Defines url host
|
18
|
+
attr_accessor :host
|
19
|
+
|
20
|
+
# Defines url base path
|
21
|
+
attr_accessor :base_path
|
22
|
+
|
23
|
+
# Defines API keys used with API Key authentications.
|
24
|
+
#
|
25
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
26
|
+
#
|
27
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
28
|
+
# config.api_key['api_key'] = 'xxx'
|
29
|
+
attr_accessor :api_key
|
30
|
+
|
31
|
+
# Defines API key prefixes used with API Key authentications.
|
32
|
+
#
|
33
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
34
|
+
#
|
35
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
36
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
37
|
+
attr_accessor :api_key_prefix
|
38
|
+
|
39
|
+
# Defines the username used with HTTP basic authentication.
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
attr_accessor :username
|
43
|
+
|
44
|
+
# Defines the password used with HTTP basic authentication.
|
45
|
+
#
|
46
|
+
# @return [String]
|
47
|
+
attr_accessor :password
|
48
|
+
|
49
|
+
# Defines the access token (Bearer) used with OAuth2.
|
50
|
+
attr_accessor :access_token
|
51
|
+
|
52
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
53
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
54
|
+
# Default to false.
|
55
|
+
#
|
56
|
+
# @return [true, false]
|
57
|
+
attr_accessor :debugging
|
58
|
+
|
59
|
+
# Defines the logger used for debugging.
|
60
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
61
|
+
#
|
62
|
+
# @return [#debug]
|
63
|
+
attr_accessor :logger
|
64
|
+
|
65
|
+
# Defines the temporary folder to store downloaded files
|
66
|
+
# (for API endpoints that have file response).
|
67
|
+
# Default to use `Tempfile`.
|
68
|
+
#
|
69
|
+
# @return [String]
|
70
|
+
attr_accessor :temp_folder_path
|
71
|
+
|
72
|
+
# The time limit for HTTP request in seconds.
|
73
|
+
# Default to 0 (never times out).
|
74
|
+
attr_accessor :timeout
|
75
|
+
|
76
|
+
# Set this to false to skip client side validation in the operation.
|
77
|
+
# Default to true.
|
78
|
+
# @return [true, false]
|
79
|
+
attr_accessor :client_side_validation
|
80
|
+
|
81
|
+
### TLS/SSL setting
|
82
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
83
|
+
# Default to true.
|
84
|
+
#
|
85
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
86
|
+
#
|
87
|
+
# @return [true, false]
|
88
|
+
attr_accessor :verify_ssl
|
89
|
+
|
90
|
+
### TLS/SSL setting
|
91
|
+
# Set this to false to skip verifying SSL host name
|
92
|
+
# Default to true.
|
93
|
+
#
|
94
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
95
|
+
#
|
96
|
+
# @return [true, false]
|
97
|
+
attr_accessor :verify_ssl_host
|
98
|
+
|
99
|
+
### TLS/SSL setting
|
100
|
+
# Set this to customize the certificate file to verify the peer.
|
101
|
+
#
|
102
|
+
# @return [String] the path to the certificate file
|
103
|
+
#
|
104
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
105
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
106
|
+
attr_accessor :ssl_ca_cert
|
107
|
+
|
108
|
+
### TLS/SSL setting
|
109
|
+
# Client certificate file (for client certificate)
|
110
|
+
attr_accessor :cert_file
|
111
|
+
|
112
|
+
### TLS/SSL setting
|
113
|
+
# Client private key file (for client certificate)
|
114
|
+
attr_accessor :key_file
|
115
|
+
|
116
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
117
|
+
# Default to nil.
|
118
|
+
#
|
119
|
+
# @see The params_encoding option of Ethon. Related source code:
|
120
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
121
|
+
attr_accessor :params_encoding
|
122
|
+
|
123
|
+
attr_accessor :inject_format
|
124
|
+
|
125
|
+
attr_accessor :force_ending_format
|
126
|
+
|
127
|
+
def initialize
|
128
|
+
@scheme = 'http'
|
129
|
+
@host = 'localhost'
|
130
|
+
@base_path = '//sandbox.gateway.sezzle.com/v2/'
|
131
|
+
@api_key = {}
|
132
|
+
@api_key_prefix = {}
|
133
|
+
@timeout = 0
|
134
|
+
@client_side_validation = true
|
135
|
+
@verify_ssl = true
|
136
|
+
@verify_ssl_host = true
|
137
|
+
@params_encoding = nil
|
138
|
+
@cert_file = nil
|
139
|
+
@key_file = nil
|
140
|
+
@debugging = false
|
141
|
+
@inject_format = false
|
142
|
+
@force_ending_format = false
|
143
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
144
|
+
|
145
|
+
yield(self) if block_given?
|
146
|
+
end
|
147
|
+
|
148
|
+
# The default Configuration object.
|
149
|
+
def self.default
|
150
|
+
@@default ||= Configuration.new
|
151
|
+
end
|
152
|
+
|
153
|
+
def configure
|
154
|
+
yield(self) if block_given?
|
155
|
+
end
|
156
|
+
|
157
|
+
def scheme=(scheme)
|
158
|
+
# remove :// from scheme
|
159
|
+
@scheme = scheme.sub(/:\/\//, '')
|
160
|
+
end
|
161
|
+
|
162
|
+
def host=(host)
|
163
|
+
# remove http(s):// and anything after a slash
|
164
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
165
|
+
end
|
166
|
+
|
167
|
+
def base_path=(base_path)
|
168
|
+
# Add leading and trailing slashes to base_path
|
169
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
170
|
+
@base_path = '' if @base_path == '/'
|
171
|
+
end
|
172
|
+
|
173
|
+
def base_url
|
174
|
+
"#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
175
|
+
end
|
176
|
+
|
177
|
+
# Gets API key (with prefix if set).
|
178
|
+
# @param [String] param_name the parameter name of API key auth
|
179
|
+
def api_key_with_prefix(param_name)
|
180
|
+
if @api_key_prefix[param_name]
|
181
|
+
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
182
|
+
else
|
183
|
+
@api_key[param_name]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# Gets Basic Auth token string
|
188
|
+
def basic_auth_token
|
189
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
190
|
+
end
|
191
|
+
|
192
|
+
# Returns Auth Settings hash for api client.
|
193
|
+
def auth_settings
|
194
|
+
{
|
195
|
+
'Bearer' =>
|
196
|
+
{
|
197
|
+
type: 'api_key',
|
198
|
+
in: 'header',
|
199
|
+
key: 'Authorization',
|
200
|
+
value: api_key_with_prefix('Authorization')
|
201
|
+
},
|
202
|
+
}
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,297 @@
|
|
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 Address
|
16
|
+
attr_accessor :city
|
17
|
+
|
18
|
+
attr_accessor :country_code
|
19
|
+
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
attr_accessor :phone
|
23
|
+
|
24
|
+
attr_accessor :postal_code
|
25
|
+
|
26
|
+
attr_accessor :state
|
27
|
+
|
28
|
+
attr_accessor :street
|
29
|
+
|
30
|
+
attr_accessor :street2
|
31
|
+
|
32
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
33
|
+
def self.attribute_map
|
34
|
+
{
|
35
|
+
:'city' => :'city',
|
36
|
+
:'country_code' => :'country_code',
|
37
|
+
:'name' => :'name',
|
38
|
+
:'phone' => :'phone',
|
39
|
+
:'postal_code' => :'postal_code',
|
40
|
+
:'state' => :'state',
|
41
|
+
:'street' => :'street',
|
42
|
+
:'street2' => :'street2'
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# Attribute type mapping.
|
47
|
+
def self.openapi_types
|
48
|
+
{
|
49
|
+
:'city' => :'Object',
|
50
|
+
:'country_code' => :'Object',
|
51
|
+
:'name' => :'Object',
|
52
|
+
:'phone' => :'Object',
|
53
|
+
:'postal_code' => :'Object',
|
54
|
+
:'state' => :'Object',
|
55
|
+
:'street' => :'Object',
|
56
|
+
:'street2' => :'Object'
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
# List of attributes with nullable: true
|
61
|
+
def self.openapi_nullable
|
62
|
+
Set.new([
|
63
|
+
:'name',
|
64
|
+
:'phone',
|
65
|
+
:'street2'
|
66
|
+
])
|
67
|
+
end
|
68
|
+
|
69
|
+
# Initializes the object
|
70
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
71
|
+
def initialize(attributes = {})
|
72
|
+
if (!attributes.is_a?(Hash))
|
73
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SezzleClient::Address` initialize method"
|
74
|
+
end
|
75
|
+
|
76
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
77
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
78
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
79
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SezzleClient::Address`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
80
|
+
end
|
81
|
+
h[k.to_sym] = v
|
82
|
+
}
|
83
|
+
|
84
|
+
if attributes.key?(:'city')
|
85
|
+
self.city = attributes[:'city']
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.key?(:'country_code')
|
89
|
+
self.country_code = attributes[:'country_code']
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.key?(:'name')
|
93
|
+
self.name = attributes[:'name']
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.key?(:'phone')
|
97
|
+
self.phone = attributes[:'phone']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.key?(:'postal_code')
|
101
|
+
self.postal_code = attributes[:'postal_code']
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.key?(:'state')
|
105
|
+
self.state = attributes[:'state']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.key?(:'street')
|
109
|
+
self.street = attributes[:'street']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:'street2')
|
113
|
+
self.street2 = attributes[:'street2']
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
118
|
+
# @return Array for valid properties with the reasons
|
119
|
+
def list_invalid_properties
|
120
|
+
invalid_properties = Array.new
|
121
|
+
if @city.nil?
|
122
|
+
invalid_properties.push('invalid value for "city", city cannot be nil.')
|
123
|
+
end
|
124
|
+
|
125
|
+
if @country_code.nil?
|
126
|
+
invalid_properties.push('invalid value for "country_code", country_code cannot be nil.')
|
127
|
+
end
|
128
|
+
|
129
|
+
if @postal_code.nil?
|
130
|
+
invalid_properties.push('invalid value for "postal_code", postal_code cannot be nil.')
|
131
|
+
end
|
132
|
+
|
133
|
+
if @state.nil?
|
134
|
+
invalid_properties.push('invalid value for "state", state cannot be nil.')
|
135
|
+
end
|
136
|
+
|
137
|
+
if @street.nil?
|
138
|
+
invalid_properties.push('invalid value for "street", street cannot be nil.')
|
139
|
+
end
|
140
|
+
|
141
|
+
invalid_properties
|
142
|
+
end
|
143
|
+
|
144
|
+
# Check to see if the all the properties in the model are valid
|
145
|
+
# @return true if the model is valid
|
146
|
+
def valid?
|
147
|
+
return false if @city.nil?
|
148
|
+
return false if @country_code.nil?
|
149
|
+
return false if @postal_code.nil?
|
150
|
+
return false if @state.nil?
|
151
|
+
return false if @street.nil?
|
152
|
+
true
|
153
|
+
end
|
154
|
+
|
155
|
+
# Checks equality by comparing each attribute.
|
156
|
+
# @param [Object] Object to be compared
|
157
|
+
def ==(o)
|
158
|
+
return true if self.equal?(o)
|
159
|
+
self.class == o.class &&
|
160
|
+
city == o.city &&
|
161
|
+
country_code == o.country_code &&
|
162
|
+
name == o.name &&
|
163
|
+
phone == o.phone &&
|
164
|
+
postal_code == o.postal_code &&
|
165
|
+
state == o.state &&
|
166
|
+
street == o.street &&
|
167
|
+
street2 == o.street2
|
168
|
+
end
|
169
|
+
|
170
|
+
# @see the `==` method
|
171
|
+
# @param [Object] Object to be compared
|
172
|
+
def eql?(o)
|
173
|
+
self == o
|
174
|
+
end
|
175
|
+
|
176
|
+
# Calculates hash code according to all attributes.
|
177
|
+
# @return [Integer] Hash code
|
178
|
+
def hash
|
179
|
+
[city, country_code, name, phone, postal_code, state, street, street2].hash
|
180
|
+
end
|
181
|
+
|
182
|
+
# Builds the object from hash
|
183
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
184
|
+
# @return [Object] Returns the model itself
|
185
|
+
def self.build_from_hash(attributes)
|
186
|
+
new.build_from_hash(attributes)
|
187
|
+
end
|
188
|
+
|
189
|
+
# Builds the object from hash
|
190
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
191
|
+
# @return [Object] Returns the model itself
|
192
|
+
def build_from_hash(attributes)
|
193
|
+
return nil unless attributes.is_a?(Hash)
|
194
|
+
self.class.openapi_types.each_pair do |key, type|
|
195
|
+
if type =~ /\AArray<(.*)>/i
|
196
|
+
# check to ensure the input is an array given that the attribute
|
197
|
+
# is documented as an array but the input is not
|
198
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
199
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
200
|
+
end
|
201
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
202
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
203
|
+
elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
204
|
+
self.send("#{key}=", nil)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
self
|
209
|
+
end
|
210
|
+
|
211
|
+
# Deserializes the data based on type
|
212
|
+
# @param string type Data type
|
213
|
+
# @param string value Value to be deserialized
|
214
|
+
# @return [Object] Deserialized data
|
215
|
+
def _deserialize(type, value)
|
216
|
+
case type.to_sym
|
217
|
+
when :DateTime
|
218
|
+
DateTime.parse(value)
|
219
|
+
when :Date
|
220
|
+
Date.parse(value)
|
221
|
+
when :String
|
222
|
+
value.to_s
|
223
|
+
when :Integer
|
224
|
+
value.to_i
|
225
|
+
when :Float
|
226
|
+
value.to_f
|
227
|
+
when :Boolean
|
228
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
229
|
+
true
|
230
|
+
else
|
231
|
+
false
|
232
|
+
end
|
233
|
+
when :Object
|
234
|
+
# generic object (usually a Hash), return directly
|
235
|
+
value
|
236
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
237
|
+
inner_type = Regexp.last_match[:inner_type]
|
238
|
+
value.map { |v| _deserialize(inner_type, v) }
|
239
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
240
|
+
k_type = Regexp.last_match[:k_type]
|
241
|
+
v_type = Regexp.last_match[:v_type]
|
242
|
+
{}.tap do |hash|
|
243
|
+
value.each do |k, v|
|
244
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
else # model
|
248
|
+
SezzleClient.const_get(type).build_from_hash(value)
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
# Returns the string representation of the object
|
253
|
+
# @return [String] String presentation of the object
|
254
|
+
def to_s
|
255
|
+
to_hash.to_s
|
256
|
+
end
|
257
|
+
|
258
|
+
# to_body is an alias to to_hash (backward compatibility)
|
259
|
+
# @return [Hash] Returns the object in the form of hash
|
260
|
+
def to_body
|
261
|
+
to_hash
|
262
|
+
end
|
263
|
+
|
264
|
+
# Returns the object in the form of hash
|
265
|
+
# @return [Hash] Returns the object in the form of hash
|
266
|
+
def to_hash
|
267
|
+
hash = {}
|
268
|
+
self.class.attribute_map.each_pair do |attr, param|
|
269
|
+
value = self.send(attr)
|
270
|
+
if value.nil?
|
271
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
272
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
273
|
+
end
|
274
|
+
|
275
|
+
hash[param] = _to_hash(value)
|
276
|
+
end
|
277
|
+
hash
|
278
|
+
end
|
279
|
+
|
280
|
+
# Outputs non-array value in the form of hash
|
281
|
+
# For object, use to_hash. Otherwise, just return the value
|
282
|
+
# @param [Object] value Any valid value
|
283
|
+
# @return [Hash] Returns the value in the form of hash
|
284
|
+
def _to_hash(value)
|
285
|
+
if value.is_a?(Array)
|
286
|
+
value.compact.map { |v| _to_hash(v) }
|
287
|
+
elsif value.is_a?(Hash)
|
288
|
+
{}.tap do |hash|
|
289
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
290
|
+
end
|
291
|
+
elsif value.respond_to? :to_hash
|
292
|
+
value.to_hash
|
293
|
+
else
|
294
|
+
value
|
295
|
+
end
|
296
|
+
end end
|
297
|
+
end
|