zip_money 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +69 -0
- data/README.md +128 -0
- data/Rakefile +8 -0
- data/docs/Address.md +15 -0
- data/docs/Authority.md +9 -0
- data/docs/CaptureChargeRequest.md +8 -0
- data/docs/Charge.md +17 -0
- data/docs/ChargeCollection.md +8 -0
- data/docs/ChargeOrder.md +11 -0
- data/docs/ChargesApi.md +307 -0
- data/docs/Checkout.md +18 -0
- data/docs/CheckoutConfiguration.md +8 -0
- data/docs/CheckoutFeatures.md +8 -0
- data/docs/CheckoutFeaturesTokenisation.md +8 -0
- data/docs/CheckoutOrder.md +13 -0
- data/docs/CheckoutsApi.md +119 -0
- data/docs/CreateChargeRequest.md +14 -0
- data/docs/CreateCheckoutRequest.md +13 -0
- data/docs/CreateCheckoutRequestFeatures.md +8 -0
- data/docs/CreateCheckoutRequestFeaturesTokenisation.md +8 -0
- data/docs/CreateRefundRequest.md +11 -0
- data/docs/CreateTokenRequest.md +8 -0
- data/docs/Customer.md +15 -0
- data/docs/CustomersApi.md +96 -0
- data/docs/ErrorResponse.md +8 -0
- data/docs/ErrorResponseError.md +10 -0
- data/docs/ErrorResponseErrorDetails.md +9 -0
- data/docs/InlineResponse200.md +8 -0
- data/docs/Metadata.md +7 -0
- data/docs/OrderItem.md +16 -0
- data/docs/OrderShipping.md +10 -0
- data/docs/OrderShippingTracking.md +10 -0
- data/docs/Refund.md +13 -0
- data/docs/RefundsApi.md +181 -0
- data/docs/SettlementsApi.md +96 -0
- data/docs/Shopper.md +17 -0
- data/docs/ShopperStatistics.md +16 -0
- data/docs/Token.md +11 -0
- data/docs/TokensApi.md +66 -0
- data/lib/zip_money.rb +68 -0
- data/lib/zip_money/api/charges_api.rb +301 -0
- data/lib/zip_money/api/checkouts_api.rb +120 -0
- data/lib/zip_money/api/customers_api.rb +116 -0
- data/lib/zip_money/api/refunds_api.rb +181 -0
- data/lib/zip_money/api/settlements_api.rb +116 -0
- data/lib/zip_money/api/tokens_api.rb +70 -0
- data/lib/zip_money/api_client.rb +386 -0
- data/lib/zip_money/api_error.rb +31 -0
- data/lib/zip_money/configuration.rb +238 -0
- data/lib/zip_money/models/address.rb +413 -0
- data/lib/zip_money/models/authority.rb +235 -0
- data/lib/zip_money/models/capture_charge_request.rb +206 -0
- data/lib/zip_money/models/charge.rb +369 -0
- data/lib/zip_money/models/charge_collection.rb +188 -0
- data/lib/zip_money/models/charge_order.rb +250 -0
- data/lib/zip_money/models/checkout.rb +344 -0
- data/lib/zip_money/models/checkout_configuration.rb +187 -0
- data/lib/zip_money/models/checkout_features.rb +181 -0
- data/lib/zip_money/models/checkout_features_tokenisation.rb +184 -0
- data/lib/zip_money/models/checkout_order.rb +299 -0
- data/lib/zip_money/models/create_charge_request.rb +289 -0
- data/lib/zip_money/models/create_checkout_request.rb +272 -0
- data/lib/zip_money/models/create_checkout_request_features.rb +181 -0
- data/lib/zip_money/models/create_checkout_request_features_tokenisation.rb +189 -0
- data/lib/zip_money/models/create_refund_request.rb +246 -0
- data/lib/zip_money/models/create_token_request.rb +186 -0
- data/lib/zip_money/models/customer.rb +310 -0
- data/lib/zip_money/models/error_response.rb +181 -0
- data/lib/zip_money/models/error_response_error.rb +211 -0
- data/lib/zip_money/models/error_response_error_details.rb +190 -0
- data/lib/zip_money/models/inline_response_200.rb +188 -0
- data/lib/zip_money/models/metadata.rb +172 -0
- data/lib/zip_money/models/order_item.rb +333 -0
- data/lib/zip_money/models/order_shipping.rb +200 -0
- data/lib/zip_money/models/order_shipping_tracking.rb +247 -0
- data/lib/zip_money/models/refund.rb +252 -0
- data/lib/zip_money/models/shopper.rb +339 -0
- data/lib/zip_money/models/shopper_statistics.rb +295 -0
- data/lib/zip_money/models/token.rb +228 -0
- data/lib/zip_money/version.rb +8 -0
- data/spec/api/charges_api_spec.rb +114 -0
- data/spec/api/checkouts_api_spec.rb +54 -0
- data/spec/api/customers_api_spec.rb +51 -0
- data/spec/api/refunds_api_spec.rb +67 -0
- data/spec/api/settlements_api_spec.rb +51 -0
- data/spec/api/tokens_api_spec.rb +41 -0
- data/spec/api_client_spec.rb +219 -0
- data/spec/configuration_spec.rb +50 -0
- data/spec/models/address_spec.rb +77 -0
- data/spec/models/authority_spec.rb +45 -0
- data/spec/models/capture_charge_request_spec.rb +35 -0
- data/spec/models/charge_collection_spec.rb +35 -0
- data/spec/models/charge_order_spec.rb +53 -0
- data/spec/models/charge_spec.rb +93 -0
- data/spec/models/checkout_configuration_spec.rb +35 -0
- data/spec/models/checkout_features_spec.rb +35 -0
- data/spec/models/checkout_features_tokenisation_spec.rb +35 -0
- data/spec/models/checkout_order_spec.rb +65 -0
- data/spec/models/checkout_spec.rb +103 -0
- data/spec/models/create_charge_request_spec.rb +75 -0
- data/spec/models/create_checkout_request_features_spec.rb +35 -0
- data/spec/models/create_checkout_request_features_tokenisation_spec.rb +35 -0
- data/spec/models/create_checkout_request_spec.rb +69 -0
- data/spec/models/create_refund_request_spec.rb +53 -0
- data/spec/models/create_token_request_spec.rb +35 -0
- data/spec/models/customer_spec.rb +81 -0
- data/spec/models/error_response_error_details_spec.rb +41 -0
- data/spec/models/error_response_error_spec.rb +47 -0
- data/spec/models/error_response_spec.rb +35 -0
- data/spec/models/inline_response_200_spec.rb +35 -0
- data/spec/models/metadata_spec.rb +29 -0
- data/spec/models/order_item_spec.rb +87 -0
- data/spec/models/order_shipping_spec.rb +47 -0
- data/spec/models/order_shipping_tracking_spec.rb +47 -0
- data/spec/models/refund_spec.rb +65 -0
- data/spec/models/shopper_spec.rb +92 -0
- data/spec/models/shopper_statistics_spec.rb +86 -0
- data/spec/models/token_spec.rb +52 -0
- data/spec/payload_helper.rb +96 -0
- data/spec/spec_helper.rb +104 -0
- data/zip_money.gemspec +38 -0
- metadata +380 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
#Merchant API
|
2
|
+
#ZipMoney Merchant API Initial build
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
4
|
+
|
5
|
+
|
6
|
+
module ZipMoney
|
7
|
+
class ApiError < StandardError
|
8
|
+
attr_reader :code, :response_headers, :response_body
|
9
|
+
|
10
|
+
# Usage examples:
|
11
|
+
# ApiError.new
|
12
|
+
# ApiError.new("message")
|
13
|
+
# ApiError.new(:code => 500, :response_headers => {}, :response_body => "")
|
14
|
+
# ApiError.new(:code => 404, :message => "Not Found")
|
15
|
+
def initialize(arg = nil)
|
16
|
+
if arg.is_a? Hash
|
17
|
+
if arg.key?(:message) || arg.key?('message')
|
18
|
+
super(arg[:message] || arg['message'])
|
19
|
+
else
|
20
|
+
super arg
|
21
|
+
end
|
22
|
+
|
23
|
+
arg.each do |k, v|
|
24
|
+
instance_variable_set "@#{k}", v
|
25
|
+
end
|
26
|
+
else
|
27
|
+
super arg
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
#Merchant API
|
2
|
+
#ZipMoney Merchant API Initial build
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
4
|
+
|
5
|
+
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
module ZipMoney
|
9
|
+
class Configuration
|
10
|
+
# Defines url scheme
|
11
|
+
attr_accessor :scheme
|
12
|
+
|
13
|
+
# Defines url host
|
14
|
+
attr_accessor :host
|
15
|
+
|
16
|
+
# Defines url base path
|
17
|
+
attr_accessor :base_path
|
18
|
+
|
19
|
+
# Supported environments
|
20
|
+
attr_accessor :supported_environments
|
21
|
+
|
22
|
+
# Current environment
|
23
|
+
attr_accessor :environment
|
24
|
+
|
25
|
+
# Defines API keys used with API Key authentications.
|
26
|
+
#
|
27
|
+
# @return [Hash] key: parameter name, value: parameter value (API key)
|
28
|
+
#
|
29
|
+
# @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
|
30
|
+
# config.api_key['api_key'] = 'xxx'
|
31
|
+
attr_accessor :api_key
|
32
|
+
|
33
|
+
# Defines API key prefixes used with API Key authentications.
|
34
|
+
#
|
35
|
+
# @return [Hash] key: parameter name, value: API key prefix
|
36
|
+
#
|
37
|
+
# @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
|
38
|
+
# config.api_key_prefix['api_key'] = 'Token'
|
39
|
+
attr_accessor :api_key_prefix
|
40
|
+
|
41
|
+
# Defines the username used with HTTP basic authentication.
|
42
|
+
#
|
43
|
+
# @return [String]
|
44
|
+
attr_accessor :username
|
45
|
+
|
46
|
+
# Defines the password used with HTTP basic authentication.
|
47
|
+
#
|
48
|
+
# @return [String]
|
49
|
+
attr_accessor :password
|
50
|
+
|
51
|
+
# Defines the access token (Bearer) used with OAuth2.
|
52
|
+
attr_accessor :access_token
|
53
|
+
|
54
|
+
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
55
|
+
# details will be logged with `logger.debug` (see the `logger` attribute).
|
56
|
+
# Default to false.
|
57
|
+
#
|
58
|
+
# @return [true, false]
|
59
|
+
attr_accessor :debugging
|
60
|
+
|
61
|
+
# Defines the logger used for debugging.
|
62
|
+
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
63
|
+
#
|
64
|
+
# @return [#debug]
|
65
|
+
attr_accessor :logger
|
66
|
+
|
67
|
+
# Defines the temporary folder to store downloaded files
|
68
|
+
# (for API endpoints that have file response).
|
69
|
+
# Default to use `Tempfile`.
|
70
|
+
#
|
71
|
+
# @return [String]
|
72
|
+
attr_accessor :temp_folder_path
|
73
|
+
|
74
|
+
# The time limit for HTTP request in seconds.
|
75
|
+
# Default to 0 (never times out).
|
76
|
+
attr_accessor :timeout
|
77
|
+
|
78
|
+
# Number of retries allowed if the first one fails.
|
79
|
+
# Default to 0 (no retries).
|
80
|
+
attr_accessor :num_retries
|
81
|
+
|
82
|
+
# Retry interval.
|
83
|
+
# Default to 0 (retry immediately).
|
84
|
+
attr_accessor :retry_interval
|
85
|
+
|
86
|
+
|
87
|
+
### TLS/SSL setting
|
88
|
+
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
89
|
+
# Default to true.
|
90
|
+
#
|
91
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
92
|
+
#
|
93
|
+
# @return [true, false]
|
94
|
+
attr_accessor :verify_ssl
|
95
|
+
|
96
|
+
### TLS/SSL setting
|
97
|
+
# Set this to false to skip verifying SSL host name
|
98
|
+
# Default to true.
|
99
|
+
#
|
100
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
101
|
+
#
|
102
|
+
# @return [true, false]
|
103
|
+
attr_accessor :verify_ssl_host
|
104
|
+
|
105
|
+
### TLS/SSL setting
|
106
|
+
# Set this to customize the certificate file to verify the peer.
|
107
|
+
#
|
108
|
+
# @return [String] the path to the certificate file
|
109
|
+
#
|
110
|
+
# @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
|
111
|
+
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
112
|
+
attr_accessor :ssl_ca_cert
|
113
|
+
|
114
|
+
### TLS/SSL setting
|
115
|
+
# Client certificate file (for client certificate)
|
116
|
+
attr_accessor :cert_file
|
117
|
+
|
118
|
+
### TLS/SSL setting
|
119
|
+
# Client private key file (for client certificate)
|
120
|
+
attr_accessor :key_file
|
121
|
+
|
122
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
123
|
+
# Default to nil.
|
124
|
+
#
|
125
|
+
# @see The params_encoding option of Ethon. Related source code:
|
126
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
127
|
+
attr_accessor :params_encoding
|
128
|
+
|
129
|
+
attr_accessor :inject_format
|
130
|
+
|
131
|
+
attr_accessor :force_ending_format
|
132
|
+
|
133
|
+
attr_accessor :api_version
|
134
|
+
|
135
|
+
attr_accessor :platform
|
136
|
+
|
137
|
+
attr_accessor :user_agent
|
138
|
+
|
139
|
+
def initialize
|
140
|
+
@scheme = 'https'
|
141
|
+
@host = 'api.sandbox.zipmoney.com.au'
|
142
|
+
@supported_environments = {:sandbox => "api.sandbox.zipmoney.com.au",:production => "api.zipmoney.com.au"}
|
143
|
+
@environment = "sandbox"
|
144
|
+
@base_path = '/merchant/v1'
|
145
|
+
@api_key = {}
|
146
|
+
@api_key_prefix = {}
|
147
|
+
@timeout = 0
|
148
|
+
@verify_ssl = true
|
149
|
+
@verify_ssl_host = true
|
150
|
+
@params_encoding = nil
|
151
|
+
@cert_file = nil
|
152
|
+
@key_file = nil
|
153
|
+
@debugging = false
|
154
|
+
@inject_format = false
|
155
|
+
@force_ending_format = false
|
156
|
+
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
157
|
+
@api_version = '2017-03-01'
|
158
|
+
@retry_interval = 0
|
159
|
+
@num_retries = 3
|
160
|
+
@user_agent = "merchantapi/#{VERSION}/ruby"
|
161
|
+
|
162
|
+
yield(self) if block_given?
|
163
|
+
end
|
164
|
+
|
165
|
+
# The default Configuration object.
|
166
|
+
def self.default
|
167
|
+
@@default ||= Configuration.new
|
168
|
+
end
|
169
|
+
|
170
|
+
def configure
|
171
|
+
yield(self) if block_given?
|
172
|
+
end
|
173
|
+
|
174
|
+
def scheme=(scheme)
|
175
|
+
# remove :// from scheme
|
176
|
+
@scheme = scheme.sub(/:\/\//, '')
|
177
|
+
end
|
178
|
+
|
179
|
+
def environment=(environment)
|
180
|
+
if @supported_environments[environment]
|
181
|
+
@environment = environment
|
182
|
+
@host = @supported_environments[environment]
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def host=(host)
|
187
|
+
# remove http(s):// and anything after a slash
|
188
|
+
@host = host.sub(/https?:\/\//, '').split('/').first
|
189
|
+
end
|
190
|
+
|
191
|
+
def base_path=(base_path)
|
192
|
+
# Add leading and trailing slashes to base_path
|
193
|
+
@base_path = "/#{base_path}".gsub(/\/+/, '/')
|
194
|
+
@base_path = "" if @base_path == "/"
|
195
|
+
end
|
196
|
+
|
197
|
+
def base_url
|
198
|
+
url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
|
199
|
+
URI.encode(url)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Gets API key (with prefix if set).
|
203
|
+
# @param [String] param_name the parameter name of API key auth
|
204
|
+
def api_key_with_prefix(param_name)
|
205
|
+
if @api_key_prefix[param_name]
|
206
|
+
"#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
|
207
|
+
else
|
208
|
+
@api_key[param_name]
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# Gets Basic Auth token string
|
213
|
+
def basic_auth_token
|
214
|
+
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
215
|
+
end
|
216
|
+
|
217
|
+
def user_agent=(user_agent)
|
218
|
+
@user_agent = user_agent
|
219
|
+
end
|
220
|
+
|
221
|
+
def platform=(platform)
|
222
|
+
@platform = platform
|
223
|
+
end
|
224
|
+
|
225
|
+
# Returns Auth Settings hash for api client.
|
226
|
+
def auth_settings
|
227
|
+
{
|
228
|
+
'Authorization' =>
|
229
|
+
{
|
230
|
+
type: 'api_key',
|
231
|
+
in: 'header',
|
232
|
+
key: 'Authorization',
|
233
|
+
value: api_key_with_prefix('Authorization')
|
234
|
+
},
|
235
|
+
}
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
@@ -0,0 +1,413 @@
|
|
1
|
+
#Merchant API
|
2
|
+
#ZipMoney Merchant API Initial build
|
3
|
+
#zipMoney Merchant API version: 2017-03-01
|
4
|
+
|
5
|
+
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
module ZipMoney
|
9
|
+
# The address object
|
10
|
+
class Address
|
11
|
+
# The first line in the address
|
12
|
+
attr_accessor :line1
|
13
|
+
|
14
|
+
# The (optional) second address line
|
15
|
+
attr_accessor :line2
|
16
|
+
|
17
|
+
# The address city
|
18
|
+
attr_accessor :city
|
19
|
+
|
20
|
+
# The state or province
|
21
|
+
attr_accessor :state
|
22
|
+
|
23
|
+
# The post or zip code
|
24
|
+
attr_accessor :postal_code
|
25
|
+
|
26
|
+
# The ISO-3166 country code. See https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2.
|
27
|
+
attr_accessor :country
|
28
|
+
|
29
|
+
# The recipient's first name
|
30
|
+
attr_accessor :first_name
|
31
|
+
|
32
|
+
# The recipient's last name
|
33
|
+
attr_accessor :last_name
|
34
|
+
|
35
|
+
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
:'line1' => :'line1',
|
40
|
+
:'line2' => :'line2',
|
41
|
+
:'city' => :'city',
|
42
|
+
:'state' => :'state',
|
43
|
+
:'postal_code' => :'postal_code',
|
44
|
+
:'country' => :'country',
|
45
|
+
:'first_name' => :'first_name',
|
46
|
+
:'last_name' => :'last_name'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Attribute type mapping.
|
51
|
+
def self.zip_types
|
52
|
+
{
|
53
|
+
:'line1' => :'String',
|
54
|
+
:'line2' => :'String',
|
55
|
+
:'city' => :'String',
|
56
|
+
:'state' => :'String',
|
57
|
+
:'postal_code' => :'String',
|
58
|
+
:'country' => :'String',
|
59
|
+
:'first_name' => :'String',
|
60
|
+
:'last_name' => :'String'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# Initializes the object
|
65
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
66
|
+
def initialize(attributes = {})
|
67
|
+
return unless attributes.is_a?(Hash)
|
68
|
+
|
69
|
+
# convert string to symbol for hash key
|
70
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
71
|
+
|
72
|
+
if attributes.has_key?(:'line1')
|
73
|
+
self.line1 = attributes[:'line1']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.has_key?(:'line2')
|
77
|
+
self.line2 = attributes[:'line2']
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.has_key?(:'city')
|
81
|
+
self.city = attributes[:'city']
|
82
|
+
end
|
83
|
+
|
84
|
+
if attributes.has_key?(:'state')
|
85
|
+
self.state = attributes[:'state']
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.has_key?(:'postal_code')
|
89
|
+
self.postal_code = attributes[:'postal_code']
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.has_key?(:'country')
|
93
|
+
self.country = attributes[:'country']
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.has_key?(:'first_name')
|
97
|
+
self.first_name = attributes[:'first_name']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.has_key?(:'last_name')
|
101
|
+
self.last_name = attributes[:'last_name']
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
107
|
+
# @return Array for valid properies with the reasons
|
108
|
+
def list_invalid_properties
|
109
|
+
invalid_properties = Array.new
|
110
|
+
if @line1.nil?
|
111
|
+
invalid_properties.push("invalid value for 'line1', line1 cannot be nil.")
|
112
|
+
end
|
113
|
+
|
114
|
+
if @line1.to_s.length > 200
|
115
|
+
invalid_properties.push("invalid value for 'line1', the character length must be smaller than or equal to 200.")
|
116
|
+
end
|
117
|
+
|
118
|
+
if !@line2.nil? && @line2.to_s.length > 200
|
119
|
+
invalid_properties.push("invalid value for 'line2', the character length must be smaller than or equal to 200.")
|
120
|
+
end
|
121
|
+
|
122
|
+
if @city.nil?
|
123
|
+
invalid_properties.push("invalid value for 'city', city cannot be nil.")
|
124
|
+
end
|
125
|
+
|
126
|
+
if @city.to_s.length > 50
|
127
|
+
invalid_properties.push("invalid value for 'city', the character length must be smaller than or equal to 50.")
|
128
|
+
end
|
129
|
+
|
130
|
+
if @state.nil?
|
131
|
+
invalid_properties.push("invalid value for 'state', state cannot be nil.")
|
132
|
+
end
|
133
|
+
|
134
|
+
if @state.to_s.length > 50
|
135
|
+
invalid_properties.push("invalid value for 'state', the character length must be smaller than or equal to 50.")
|
136
|
+
end
|
137
|
+
|
138
|
+
if @postal_code.nil?
|
139
|
+
invalid_properties.push("invalid value for 'postal_code', postal_code cannot be nil.")
|
140
|
+
end
|
141
|
+
|
142
|
+
if @postal_code.to_s.length > 15
|
143
|
+
invalid_properties.push("invalid value for 'postal_code', the character length must be smaller than or equal to 15.")
|
144
|
+
end
|
145
|
+
|
146
|
+
if @country.nil?
|
147
|
+
invalid_properties.push("invalid value for 'country', country cannot be nil.")
|
148
|
+
end
|
149
|
+
|
150
|
+
if @country.to_s.length > 2
|
151
|
+
invalid_properties.push("invalid value for 'country', the character length must be smaller than or equal to 2.")
|
152
|
+
end
|
153
|
+
|
154
|
+
if @country.to_s.length < 2
|
155
|
+
invalid_properties.push("invalid value for 'country', the character length must be great than or equal to 2.")
|
156
|
+
end
|
157
|
+
|
158
|
+
if !@first_name.nil? && @first_name.to_s.length > 200
|
159
|
+
invalid_properties.push("invalid value for 'first_name', the character length must be smaller than or equal to 200.")
|
160
|
+
end
|
161
|
+
|
162
|
+
return invalid_properties
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check to see if the all the properties in the model are valid
|
166
|
+
# @return true if the model is valid
|
167
|
+
def valid?
|
168
|
+
return false if @line1.nil?
|
169
|
+
return false if @line1.to_s.length > 200
|
170
|
+
return false if !@line2.nil? && @line2.to_s.length > 200
|
171
|
+
return false if @city.nil?
|
172
|
+
return false if @city.to_s.length > 50
|
173
|
+
return false if @state.nil?
|
174
|
+
return false if @state.to_s.length > 50
|
175
|
+
return false if @postal_code.nil?
|
176
|
+
return false if @postal_code.to_s.length > 15
|
177
|
+
return false if @country.nil?
|
178
|
+
return false if @country.to_s.length > 2
|
179
|
+
return false if @country.to_s.length < 2
|
180
|
+
return false if !@first_name.nil? && @first_name.to_s.length > 200
|
181
|
+
return true
|
182
|
+
end
|
183
|
+
|
184
|
+
# Custom attribute writer method with validation
|
185
|
+
# @param [Object] line1 Value to be assigned
|
186
|
+
def line1=(line1)
|
187
|
+
if line1.nil?
|
188
|
+
fail ArgumentError, "line1 cannot be nil"
|
189
|
+
end
|
190
|
+
|
191
|
+
if line1.to_s.length > 200
|
192
|
+
fail ArgumentError, "invalid value for 'line1', the character length must be smaller than or equal to 200."
|
193
|
+
end
|
194
|
+
|
195
|
+
@line1 = line1
|
196
|
+
end
|
197
|
+
|
198
|
+
# Custom attribute writer method with validation
|
199
|
+
# @param [Object] line2 Value to be assigned
|
200
|
+
def line2=(line2)
|
201
|
+
|
202
|
+
if !line2.nil? && line2.to_s.length > 200
|
203
|
+
fail ArgumentError, "invalid value for 'line2', the character length must be smaller than or equal to 200."
|
204
|
+
end
|
205
|
+
|
206
|
+
@line2 = line2
|
207
|
+
end
|
208
|
+
|
209
|
+
# Custom attribute writer method with validation
|
210
|
+
# @param [Object] city Value to be assigned
|
211
|
+
def city=(city)
|
212
|
+
if city.nil?
|
213
|
+
fail ArgumentError, "city cannot be nil"
|
214
|
+
end
|
215
|
+
|
216
|
+
if city.to_s.length > 50
|
217
|
+
fail ArgumentError, "invalid value for 'city', the character length must be smaller than or equal to 50."
|
218
|
+
end
|
219
|
+
|
220
|
+
@city = city
|
221
|
+
end
|
222
|
+
|
223
|
+
# Custom attribute writer method with validation
|
224
|
+
# @param [Object] state Value to be assigned
|
225
|
+
def state=(state)
|
226
|
+
if state.nil?
|
227
|
+
fail ArgumentError, "state cannot be nil"
|
228
|
+
end
|
229
|
+
|
230
|
+
if state.to_s.length > 50
|
231
|
+
fail ArgumentError, "invalid value for 'state', the character length must be smaller than or equal to 50."
|
232
|
+
end
|
233
|
+
|
234
|
+
@state = state
|
235
|
+
end
|
236
|
+
|
237
|
+
# Custom attribute writer method with validation
|
238
|
+
# @param [Object] postal_code Value to be assigned
|
239
|
+
def postal_code=(postal_code)
|
240
|
+
if postal_code.nil?
|
241
|
+
fail ArgumentError, "postal_code cannot be nil"
|
242
|
+
end
|
243
|
+
|
244
|
+
if postal_code.to_s.length > 15
|
245
|
+
fail ArgumentError, "invalid value for 'postal_code', the character length must be smaller than or equal to 15."
|
246
|
+
end
|
247
|
+
|
248
|
+
@postal_code = postal_code
|
249
|
+
end
|
250
|
+
|
251
|
+
# Custom attribute writer method with validation
|
252
|
+
# @param [Object] country Value to be assigned
|
253
|
+
def country=(country)
|
254
|
+
if country.nil?
|
255
|
+
fail ArgumentError, "country cannot be nil"
|
256
|
+
end
|
257
|
+
|
258
|
+
if country.to_s.length > 2
|
259
|
+
fail ArgumentError, "invalid value for 'country', the character length must be smaller than or equal to 2."
|
260
|
+
end
|
261
|
+
|
262
|
+
if country.to_s.length < 2
|
263
|
+
fail ArgumentError, "invalid value for 'country', the character length must be great than or equal to 2."
|
264
|
+
end
|
265
|
+
|
266
|
+
@country = country
|
267
|
+
end
|
268
|
+
|
269
|
+
# Custom attribute writer method with validation
|
270
|
+
# @param [Object] first_name Value to be assigned
|
271
|
+
def first_name=(first_name)
|
272
|
+
|
273
|
+
if !first_name.nil? && first_name.to_s.length > 200
|
274
|
+
fail ArgumentError, "invalid value for 'first_name', the character length must be smaller than or equal to 200."
|
275
|
+
end
|
276
|
+
|
277
|
+
@first_name = first_name
|
278
|
+
end
|
279
|
+
|
280
|
+
# Checks equality by comparing each attribute.
|
281
|
+
# @param [Object] Object to be compared
|
282
|
+
def ==(o)
|
283
|
+
return true if self.equal?(o)
|
284
|
+
self.class == o.class &&
|
285
|
+
line1 == o.line1 &&
|
286
|
+
line2 == o.line2 &&
|
287
|
+
city == o.city &&
|
288
|
+
state == o.state &&
|
289
|
+
postal_code == o.postal_code &&
|
290
|
+
country == o.country &&
|
291
|
+
first_name == o.first_name &&
|
292
|
+
last_name == o.last_name
|
293
|
+
end
|
294
|
+
|
295
|
+
# @see the `==` method
|
296
|
+
# @param [Object] Object to be compared
|
297
|
+
def eql?(o)
|
298
|
+
self == o
|
299
|
+
end
|
300
|
+
|
301
|
+
# Calculates hash code according to all attributes.
|
302
|
+
# @return [Fixnum] Hash code
|
303
|
+
def hash
|
304
|
+
[line1, line2, city, state, postal_code, country, first_name, last_name].hash
|
305
|
+
end
|
306
|
+
|
307
|
+
# Builds the object from hash
|
308
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
309
|
+
# @return [Object] Returns the model itself
|
310
|
+
def build_from_hash(attributes)
|
311
|
+
return nil unless attributes.is_a?(Hash)
|
312
|
+
self.class.zip_types.each_pair do |key, type|
|
313
|
+
if type =~ /\AArray<(.*)>/i
|
314
|
+
# check to ensure the input is an array given that the the attribute
|
315
|
+
# is documented as an array but the input is not
|
316
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
317
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
318
|
+
end
|
319
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
320
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
321
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
322
|
+
end
|
323
|
+
|
324
|
+
self
|
325
|
+
end
|
326
|
+
|
327
|
+
# Deserializes the data based on type
|
328
|
+
# @param string type Data type
|
329
|
+
# @param string value Value to be deserialized
|
330
|
+
# @return [Object] Deserialized data
|
331
|
+
def _deserialize(type, value)
|
332
|
+
case type.to_sym
|
333
|
+
when :DateTime
|
334
|
+
DateTime.parse(value)
|
335
|
+
when :Date
|
336
|
+
Date.parse(value)
|
337
|
+
when :String
|
338
|
+
value.to_s
|
339
|
+
when :Integer
|
340
|
+
value.to_i
|
341
|
+
when :Float
|
342
|
+
value.to_f
|
343
|
+
when :BOOLEAN
|
344
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
345
|
+
true
|
346
|
+
else
|
347
|
+
false
|
348
|
+
end
|
349
|
+
when :Object
|
350
|
+
# generic object (usually a Hash), return directly
|
351
|
+
value
|
352
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
353
|
+
inner_type = Regexp.last_match[:inner_type]
|
354
|
+
value.map { |v| _deserialize(inner_type, v) }
|
355
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
356
|
+
k_type = Regexp.last_match[:k_type]
|
357
|
+
v_type = Regexp.last_match[:v_type]
|
358
|
+
{}.tap do |hash|
|
359
|
+
value.each do |k, v|
|
360
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
else # model
|
364
|
+
temp_model = ZipMoney.const_get(type).new
|
365
|
+
temp_model.build_from_hash(value)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
# Returns the string representation of the object
|
370
|
+
# @return [String] String presentation of the object
|
371
|
+
def to_s
|
372
|
+
to_hash.to_s
|
373
|
+
end
|
374
|
+
|
375
|
+
# to_body is an alias to to_hash (backward compatibility)
|
376
|
+
# @return [Hash] Returns the object in the form of hash
|
377
|
+
def to_body
|
378
|
+
to_hash
|
379
|
+
end
|
380
|
+
|
381
|
+
# Returns the object in the form of hash
|
382
|
+
# @return [Hash] Returns the object in the form of hash
|
383
|
+
def to_hash
|
384
|
+
hash = {}
|
385
|
+
self.class.attribute_map.each_pair do |attr, param|
|
386
|
+
value = self.send(attr)
|
387
|
+
next if value.nil?
|
388
|
+
hash[param] = _to_hash(value)
|
389
|
+
end
|
390
|
+
hash
|
391
|
+
end
|
392
|
+
|
393
|
+
# Outputs non-array value in the form of hash
|
394
|
+
# For object, use to_hash. Otherwise, just return the value
|
395
|
+
# @param [Object] value Any valid value
|
396
|
+
# @return [Hash] Returns the value in the form of hash
|
397
|
+
def _to_hash(value)
|
398
|
+
if value.is_a?(Array)
|
399
|
+
value.compact.map{ |v| _to_hash(v) }
|
400
|
+
elsif value.is_a?(Hash)
|
401
|
+
{}.tap do |hash|
|
402
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
403
|
+
end
|
404
|
+
elsif value.respond_to? :to_hash
|
405
|
+
value.to_hash
|
406
|
+
else
|
407
|
+
value
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
end
|
412
|
+
|
413
|
+
end
|