citypay_api_client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/README.md +176 -0
- data/Rakefile +10 -0
- data/citypay_api_client.gemspec +39 -0
- data/docs/AccountCreate.md +19 -0
- data/docs/AccountStatus.md +17 -0
- data/docs/Acknowledgement.md +23 -0
- data/docs/AirlineAdvice.md +47 -0
- data/docs/AirlineSegment.md +31 -0
- data/docs/AuthReference.md +43 -0
- data/docs/AuthReferences.md +17 -0
- data/docs/AuthRequest.md +59 -0
- data/docs/AuthResponse.md +69 -0
- data/docs/AuthenRequired.md +21 -0
- data/docs/CResAuthRequest.md +17 -0
- data/docs/CaptureRequest.md +27 -0
- data/docs/Card.md +51 -0
- data/docs/CardHolderAccount.md +31 -0
- data/docs/CardHolderAccountApi.md +515 -0
- data/docs/CardStatus.md +19 -0
- data/docs/ChargeRequest.md +41 -0
- data/docs/ContactDetails.md +41 -0
- data/docs/Decision.md +21 -0
- data/docs/Error.md +23 -0
- data/docs/ExternalMPI.md +25 -0
- data/docs/ListMerchantsResponse.md +21 -0
- data/docs/MCC6012.md +23 -0
- data/docs/Merchant.md +25 -0
- data/docs/OperationalApi.md +118 -0
- data/docs/PaResAuthRequest.md +19 -0
- data/docs/PaymentProcessingApi.md +338 -0
- data/docs/Ping.md +17 -0
- data/docs/RegisterCard.md +23 -0
- data/docs/RequestChallenged.md +25 -0
- data/docs/RetrieveRequest.md +21 -0
- data/docs/ThreeDSecure.md +25 -0
- data/docs/VoidRequest.md +23 -0
- data/git_push.sh +58 -0
- data/lib/citypay_api_client.rb +72 -0
- data/lib/citypay_api_client/api/card_holder_account_api.rb +628 -0
- data/lib/citypay_api_client/api/operational_api.rb +148 -0
- data/lib/citypay_api_client/api/payment_processing_api.rb +406 -0
- data/lib/citypay_api_client/api_client.rb +388 -0
- data/lib/citypay_api_client/api_error.rb +57 -0
- data/lib/citypay_api_client/configuration.rb +252 -0
- data/lib/citypay_api_client/models/account_create.rb +249 -0
- data/lib/citypay_api_client/models/account_status.rb +207 -0
- data/lib/citypay_api_client/models/acknowledgement.rb +285 -0
- data/lib/citypay_api_client/models/airline_advice.rb +551 -0
- data/lib/citypay_api_client/models/airline_segment.rb +408 -0
- data/lib/citypay_api_client/models/api_key.rb +53 -0
- data/lib/citypay_api_client/models/auth_reference.rb +400 -0
- data/lib/citypay_api_client/models/auth_references.rb +208 -0
- data/lib/citypay_api_client/models/auth_request.rb +631 -0
- data/lib/citypay_api_client/models/auth_response.rb +563 -0
- data/lib/citypay_api_client/models/authen_required.rb +227 -0
- data/lib/citypay_api_client/models/c_res_auth_request.rb +207 -0
- data/lib/citypay_api_client/models/capture_request.rb +285 -0
- data/lib/citypay_api_client/models/card.rb +425 -0
- data/lib/citypay_api_client/models/card_holder_account.rb +315 -0
- data/lib/citypay_api_client/models/card_status.rb +217 -0
- data/lib/citypay_api_client/models/charge_request.rb +453 -0
- data/lib/citypay_api_client/models/contact_details.rb +456 -0
- data/lib/citypay_api_client/models/decision.rb +224 -0
- data/lib/citypay_api_client/models/error.rb +285 -0
- data/lib/citypay_api_client/models/external_mpi.rb +307 -0
- data/lib/citypay_api_client/models/list_merchants_response.rb +252 -0
- data/lib/citypay_api_client/models/mcc6012.rb +237 -0
- data/lib/citypay_api_client/models/merchant.rb +247 -0
- data/lib/citypay_api_client/models/pa_res_auth_request.rb +227 -0
- data/lib/citypay_api_client/models/ping.rb +231 -0
- data/lib/citypay_api_client/models/register_card.rb +336 -0
- data/lib/citypay_api_client/models/request_challenged.rb +247 -0
- data/lib/citypay_api_client/models/retrieve_request.rb +256 -0
- data/lib/citypay_api_client/models/three_d_secure.rb +247 -0
- data/lib/citypay_api_client/models/void_request.rb +266 -0
- data/lib/citypay_api_client/version.rb +15 -0
- data/spec/api/card_holder_account_api_spec.rb +149 -0
- data/spec/api/operational_api_spec.rb +59 -0
- data/spec/api/payment_processing_api_spec.rb +107 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/account_create_spec.rb +47 -0
- data/spec/models/account_status_spec.rb +41 -0
- data/spec/models/acknowledgement_spec.rb +59 -0
- data/spec/models/airline_advice_spec.rb +131 -0
- data/spec/models/airline_segment_spec.rb +83 -0
- data/spec/models/auth_reference_spec.rb +119 -0
- data/spec/models/auth_references_spec.rb +41 -0
- data/spec/models/auth_request_spec.rb +167 -0
- data/spec/models/auth_response_spec.rb +197 -0
- data/spec/models/authen_required_spec.rb +53 -0
- data/spec/models/c_res_auth_request_spec.rb +41 -0
- data/spec/models/capture_request_spec.rb +71 -0
- data/spec/models/card_holder_account_spec.rb +83 -0
- data/spec/models/card_spec.rb +143 -0
- data/spec/models/card_status_spec.rb +47 -0
- data/spec/models/charge_request_spec.rb +113 -0
- data/spec/models/contact_details_spec.rb +113 -0
- data/spec/models/decision_spec.rb +53 -0
- data/spec/models/error_spec.rb +59 -0
- data/spec/models/external_mpi_spec.rb +65 -0
- data/spec/models/list_merchants_response_spec.rb +53 -0
- data/spec/models/mcc6012_spec.rb +59 -0
- data/spec/models/merchant_spec.rb +65 -0
- data/spec/models/pa_res_auth_request_spec.rb +47 -0
- data/spec/models/ping_spec.rb +41 -0
- data/spec/models/register_card_spec.rb +59 -0
- data/spec/models/request_challenged_spec.rb +65 -0
- data/spec/models/retrieve_request_spec.rb +53 -0
- data/spec/models/three_d_secure_spec.rb +65 -0
- data/spec/models/void_request_spec.rb +59 -0
- data/spec/spec_helper.rb +111 -0
- metadata +252 -0
@@ -0,0 +1,456 @@
|
|
1
|
+
=begin
|
2
|
+
#CityPay Payment API
|
3
|
+
|
4
|
+
# This CityPay API is a HTTP RESTful payment API used for direct server to server transactional processing. It provides a number of payment mechanisms including: Internet, MOTO, Continuous Authority transaction processing, 3-D Secure decision handling using RFA Secure, Authorisation, Refunding, Pre-Authorisation, Cancellation/Voids and Completion processing. The API is also capable of tokinsed payments using Card Holder Accounts. ## Compliance and Security <aside class=\"notice\"> Before we begin a reminder that your application will need to adhere to PCI-DSS standards to operate safely and to meet requirements set out by Visa and MasterCard and the PCI Security Standards Council including: </aside> * Data must be collected using TLS version 1.2 using [strong cryptography](#enabled-tls-ciphers). We will not accept calls to our API at lower grade encryption levels. We regularly scan our TLS endpoints for vulnerabilities and perform TLS assessments as part of our compliance program. * The application must not store sensitive card holder data (CHD) such as the card security code (CSC) or primary access number (PAN) * The application must not display the full card number on receipts, it is recommended to mask the PAN and show the last 4 digits. The API will return this for you for ease of receipt creation * If you are developing a website, you will be required to perform regular scans on the network where you host the application to meet your compliance obligations * You will be required to be PCI Compliant and the application must adhere to the security standard. Further information is available from [https://www.pcisecuritystandards.org/](https://www.pcisecuritystandards.org/) * The API verifies that the request is for a valid account and originates from a trusted source using the remote IP address. Our application firewalls analyse data that may be an attempt to break a large number of security common security vulnerabilities.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 6.0.0
|
7
|
+
Contact: support@citypay.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.0.0-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CityPayApiClient
|
16
|
+
class ContactDetails
|
17
|
+
# The first line of the address for the card holder.
|
18
|
+
attr_accessor :address1
|
19
|
+
|
20
|
+
# The second line of the address for the card holder.
|
21
|
+
attr_accessor :address2
|
22
|
+
|
23
|
+
# The third line of the address for the card holder.
|
24
|
+
attr_accessor :address3
|
25
|
+
|
26
|
+
# The area such as city, department, parish for the card holder.
|
27
|
+
attr_accessor :area
|
28
|
+
|
29
|
+
# The company name for the card holder if the contact is a corporate contact.
|
30
|
+
attr_accessor :company
|
31
|
+
|
32
|
+
# The country code in ISO 3166 format. The country value may be used for fraud analysis and for acceptance of the transaction.
|
33
|
+
attr_accessor :country
|
34
|
+
|
35
|
+
# An email address for the card holder which may be used for correspondence.
|
36
|
+
attr_accessor :email
|
37
|
+
|
38
|
+
# The first name of the card holder.
|
39
|
+
attr_accessor :firstname
|
40
|
+
|
41
|
+
# The last name or surname of the card holder.
|
42
|
+
attr_accessor :lastname
|
43
|
+
|
44
|
+
# A mobile number for the card holder the mobile number is often required by delivery companies to ensure they are able to be in contact when required.
|
45
|
+
attr_accessor :mobile_no
|
46
|
+
|
47
|
+
# The postcode or zip code of the address which may be used for fraud analysis.
|
48
|
+
attr_accessor :postcode
|
49
|
+
|
50
|
+
# A telephone number for the card holder.
|
51
|
+
attr_accessor :telephone_no
|
52
|
+
|
53
|
+
# A title for the card holder such as Mr, Mrs, Ms, M. Mme. etc.
|
54
|
+
attr_accessor :title
|
55
|
+
|
56
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
57
|
+
def self.attribute_map
|
58
|
+
{
|
59
|
+
:'address1' => :'address1',
|
60
|
+
:'address2' => :'address2',
|
61
|
+
:'address3' => :'address3',
|
62
|
+
:'area' => :'area',
|
63
|
+
:'company' => :'company',
|
64
|
+
:'country' => :'country',
|
65
|
+
:'email' => :'email',
|
66
|
+
:'firstname' => :'firstname',
|
67
|
+
:'lastname' => :'lastname',
|
68
|
+
:'mobile_no' => :'mobile_no',
|
69
|
+
:'postcode' => :'postcode',
|
70
|
+
:'telephone_no' => :'telephone_no',
|
71
|
+
:'title' => :'title'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# Attribute type mapping.
|
76
|
+
def self.openapi_types
|
77
|
+
{
|
78
|
+
:'address1' => :'String',
|
79
|
+
:'address2' => :'String',
|
80
|
+
:'address3' => :'String',
|
81
|
+
:'area' => :'String',
|
82
|
+
:'company' => :'String',
|
83
|
+
:'country' => :'String',
|
84
|
+
:'email' => :'String',
|
85
|
+
:'firstname' => :'String',
|
86
|
+
:'lastname' => :'String',
|
87
|
+
:'mobile_no' => :'String',
|
88
|
+
:'postcode' => :'String',
|
89
|
+
:'telephone_no' => :'String',
|
90
|
+
:'title' => :'String'
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
# List of attributes with nullable: true
|
95
|
+
def self.openapi_nullable
|
96
|
+
Set.new([
|
97
|
+
])
|
98
|
+
end
|
99
|
+
|
100
|
+
# Initializes the object
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
def initialize(attributes = {})
|
103
|
+
if (!attributes.is_a?(Hash))
|
104
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::ContactDetails` initialize method"
|
105
|
+
end
|
106
|
+
|
107
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
108
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
109
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
110
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::ContactDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
111
|
+
end
|
112
|
+
h[k.to_sym] = v
|
113
|
+
}
|
114
|
+
|
115
|
+
if attributes.key?(:'address1')
|
116
|
+
self.address1 = attributes[:'address1']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'address2')
|
120
|
+
self.address2 = attributes[:'address2']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'address3')
|
124
|
+
self.address3 = attributes[:'address3']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'area')
|
128
|
+
self.area = attributes[:'area']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'company')
|
132
|
+
self.company = attributes[:'company']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'country')
|
136
|
+
self.country = attributes[:'country']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'email')
|
140
|
+
self.email = attributes[:'email']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:'firstname')
|
144
|
+
self.firstname = attributes[:'firstname']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.key?(:'lastname')
|
148
|
+
self.lastname = attributes[:'lastname']
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.key?(:'mobile_no')
|
152
|
+
self.mobile_no = attributes[:'mobile_no']
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.key?(:'postcode')
|
156
|
+
self.postcode = attributes[:'postcode']
|
157
|
+
end
|
158
|
+
|
159
|
+
if attributes.key?(:'telephone_no')
|
160
|
+
self.telephone_no = attributes[:'telephone_no']
|
161
|
+
end
|
162
|
+
|
163
|
+
if attributes.key?(:'title')
|
164
|
+
self.title = attributes[:'title']
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
169
|
+
# @return Array for valid properties with the reasons
|
170
|
+
def list_invalid_properties
|
171
|
+
invalid_properties = Array.new
|
172
|
+
if !@address1.nil? && @address1.to_s.length > 40
|
173
|
+
invalid_properties.push('invalid value for "address1", the character length must be smaller than or equal to 40.')
|
174
|
+
end
|
175
|
+
|
176
|
+
if !@address2.nil? && @address2.to_s.length > 30
|
177
|
+
invalid_properties.push('invalid value for "address2", the character length must be smaller than or equal to 30.')
|
178
|
+
end
|
179
|
+
|
180
|
+
if !@address3.nil? && @address3.to_s.length > 20
|
181
|
+
invalid_properties.push('invalid value for "address3", the character length must be smaller than or equal to 20.')
|
182
|
+
end
|
183
|
+
|
184
|
+
if !@area.nil? && @area.to_s.length > 20
|
185
|
+
invalid_properties.push('invalid value for "area", the character length must be smaller than or equal to 20.')
|
186
|
+
end
|
187
|
+
|
188
|
+
if !@country.nil? && @country.to_s.length > 2
|
189
|
+
invalid_properties.push('invalid value for "country", the character length must be smaller than or equal to 2.')
|
190
|
+
end
|
191
|
+
|
192
|
+
if !@country.nil? && @country.to_s.length < 2
|
193
|
+
invalid_properties.push('invalid value for "country", the character length must be great than or equal to 2.')
|
194
|
+
end
|
195
|
+
|
196
|
+
if !@mobile_no.nil? && @mobile_no.to_s.length > 20
|
197
|
+
invalid_properties.push('invalid value for "mobile_no", the character length must be smaller than or equal to 20.')
|
198
|
+
end
|
199
|
+
|
200
|
+
if !@postcode.nil? && @postcode.to_s.length > 10
|
201
|
+
invalid_properties.push('invalid value for "postcode", the character length must be smaller than or equal to 10.')
|
202
|
+
end
|
203
|
+
|
204
|
+
if !@telephone_no.nil? && @telephone_no.to_s.length > 20
|
205
|
+
invalid_properties.push('invalid value for "telephone_no", the character length must be smaller than or equal to 20.')
|
206
|
+
end
|
207
|
+
|
208
|
+
invalid_properties
|
209
|
+
end
|
210
|
+
|
211
|
+
# Check to see if the all the properties in the model are valid
|
212
|
+
# @return true if the model is valid
|
213
|
+
def valid?
|
214
|
+
return false if !@address1.nil? && @address1.to_s.length > 40
|
215
|
+
return false if !@address2.nil? && @address2.to_s.length > 30
|
216
|
+
return false if !@address3.nil? && @address3.to_s.length > 20
|
217
|
+
return false if !@area.nil? && @area.to_s.length > 20
|
218
|
+
return false if !@country.nil? && @country.to_s.length > 2
|
219
|
+
return false if !@country.nil? && @country.to_s.length < 2
|
220
|
+
return false if !@mobile_no.nil? && @mobile_no.to_s.length > 20
|
221
|
+
return false if !@postcode.nil? && @postcode.to_s.length > 10
|
222
|
+
return false if !@telephone_no.nil? && @telephone_no.to_s.length > 20
|
223
|
+
true
|
224
|
+
end
|
225
|
+
|
226
|
+
# Custom attribute writer method with validation
|
227
|
+
# @param [Object] address1 Value to be assigned
|
228
|
+
def address1=(address1)
|
229
|
+
if !address1.nil? && address1.to_s.length > 40
|
230
|
+
fail ArgumentError, 'invalid value for "address1", the character length must be smaller than or equal to 40.'
|
231
|
+
end
|
232
|
+
|
233
|
+
@address1 = address1
|
234
|
+
end
|
235
|
+
|
236
|
+
# Custom attribute writer method with validation
|
237
|
+
# @param [Object] address2 Value to be assigned
|
238
|
+
def address2=(address2)
|
239
|
+
if !address2.nil? && address2.to_s.length > 30
|
240
|
+
fail ArgumentError, 'invalid value for "address2", the character length must be smaller than or equal to 30.'
|
241
|
+
end
|
242
|
+
|
243
|
+
@address2 = address2
|
244
|
+
end
|
245
|
+
|
246
|
+
# Custom attribute writer method with validation
|
247
|
+
# @param [Object] address3 Value to be assigned
|
248
|
+
def address3=(address3)
|
249
|
+
if !address3.nil? && address3.to_s.length > 20
|
250
|
+
fail ArgumentError, 'invalid value for "address3", the character length must be smaller than or equal to 20.'
|
251
|
+
end
|
252
|
+
|
253
|
+
@address3 = address3
|
254
|
+
end
|
255
|
+
|
256
|
+
# Custom attribute writer method with validation
|
257
|
+
# @param [Object] area Value to be assigned
|
258
|
+
def area=(area)
|
259
|
+
if !area.nil? && area.to_s.length > 20
|
260
|
+
fail ArgumentError, 'invalid value for "area", the character length must be smaller than or equal to 20.'
|
261
|
+
end
|
262
|
+
|
263
|
+
@area = area
|
264
|
+
end
|
265
|
+
|
266
|
+
# Custom attribute writer method with validation
|
267
|
+
# @param [Object] country Value to be assigned
|
268
|
+
def country=(country)
|
269
|
+
if !country.nil? && country.to_s.length > 2
|
270
|
+
fail ArgumentError, 'invalid value for "country", the character length must be smaller than or equal to 2.'
|
271
|
+
end
|
272
|
+
|
273
|
+
if !country.nil? && country.to_s.length < 2
|
274
|
+
fail ArgumentError, 'invalid value for "country", the character length must be great than or equal to 2.'
|
275
|
+
end
|
276
|
+
|
277
|
+
@country = country
|
278
|
+
end
|
279
|
+
|
280
|
+
# Custom attribute writer method with validation
|
281
|
+
# @param [Object] mobile_no Value to be assigned
|
282
|
+
def mobile_no=(mobile_no)
|
283
|
+
if !mobile_no.nil? && mobile_no.to_s.length > 20
|
284
|
+
fail ArgumentError, 'invalid value for "mobile_no", the character length must be smaller than or equal to 20.'
|
285
|
+
end
|
286
|
+
|
287
|
+
@mobile_no = mobile_no
|
288
|
+
end
|
289
|
+
|
290
|
+
# Custom attribute writer method with validation
|
291
|
+
# @param [Object] postcode Value to be assigned
|
292
|
+
def postcode=(postcode)
|
293
|
+
if !postcode.nil? && postcode.to_s.length > 10
|
294
|
+
fail ArgumentError, 'invalid value for "postcode", the character length must be smaller than or equal to 10.'
|
295
|
+
end
|
296
|
+
|
297
|
+
@postcode = postcode
|
298
|
+
end
|
299
|
+
|
300
|
+
# Custom attribute writer method with validation
|
301
|
+
# @param [Object] telephone_no Value to be assigned
|
302
|
+
def telephone_no=(telephone_no)
|
303
|
+
if !telephone_no.nil? && telephone_no.to_s.length > 20
|
304
|
+
fail ArgumentError, 'invalid value for "telephone_no", the character length must be smaller than or equal to 20.'
|
305
|
+
end
|
306
|
+
|
307
|
+
@telephone_no = telephone_no
|
308
|
+
end
|
309
|
+
|
310
|
+
# Checks equality by comparing each attribute.
|
311
|
+
# @param [Object] Object to be compared
|
312
|
+
def ==(o)
|
313
|
+
return true if self.equal?(o)
|
314
|
+
self.class == o.class &&
|
315
|
+
address1 == o.address1 &&
|
316
|
+
address2 == o.address2 &&
|
317
|
+
address3 == o.address3 &&
|
318
|
+
area == o.area &&
|
319
|
+
company == o.company &&
|
320
|
+
country == o.country &&
|
321
|
+
email == o.email &&
|
322
|
+
firstname == o.firstname &&
|
323
|
+
lastname == o.lastname &&
|
324
|
+
mobile_no == o.mobile_no &&
|
325
|
+
postcode == o.postcode &&
|
326
|
+
telephone_no == o.telephone_no &&
|
327
|
+
title == o.title
|
328
|
+
end
|
329
|
+
|
330
|
+
# @see the `==` method
|
331
|
+
# @param [Object] Object to be compared
|
332
|
+
def eql?(o)
|
333
|
+
self == o
|
334
|
+
end
|
335
|
+
|
336
|
+
# Calculates hash code according to all attributes.
|
337
|
+
# @return [Integer] Hash code
|
338
|
+
def hash
|
339
|
+
[address1, address2, address3, area, company, country, email, firstname, lastname, mobile_no, postcode, telephone_no, title].hash
|
340
|
+
end
|
341
|
+
|
342
|
+
# Builds the object from hash
|
343
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
344
|
+
# @return [Object] Returns the model itself
|
345
|
+
def self.build_from_hash(attributes)
|
346
|
+
new.build_from_hash(attributes)
|
347
|
+
end
|
348
|
+
|
349
|
+
# Builds the object from hash
|
350
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
351
|
+
# @return [Object] Returns the model itself
|
352
|
+
def build_from_hash(attributes)
|
353
|
+
return nil unless attributes.is_a?(Hash)
|
354
|
+
self.class.openapi_types.each_pair do |key, type|
|
355
|
+
if type =~ /\AArray<(.*)>/i
|
356
|
+
# check to ensure the input is an array given that the attribute
|
357
|
+
# is documented as an array but the input is not
|
358
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
359
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
360
|
+
end
|
361
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
362
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
363
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
364
|
+
end
|
365
|
+
|
366
|
+
self
|
367
|
+
end
|
368
|
+
|
369
|
+
# Deserializes the data based on type
|
370
|
+
# @param string type Data type
|
371
|
+
# @param string value Value to be deserialized
|
372
|
+
# @return [Object] Deserialized data
|
373
|
+
def _deserialize(type, value)
|
374
|
+
case type.to_sym
|
375
|
+
when :DateTime
|
376
|
+
DateTime.parse(value)
|
377
|
+
when :Date
|
378
|
+
Date.parse(value)
|
379
|
+
when :String
|
380
|
+
value.to_s
|
381
|
+
when :Integer
|
382
|
+
value.to_i
|
383
|
+
when :Float
|
384
|
+
value.to_f
|
385
|
+
when :Boolean
|
386
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
387
|
+
true
|
388
|
+
else
|
389
|
+
false
|
390
|
+
end
|
391
|
+
when :Object
|
392
|
+
# generic object (usually a Hash), return directly
|
393
|
+
value
|
394
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
395
|
+
inner_type = Regexp.last_match[:inner_type]
|
396
|
+
value.map { |v| _deserialize(inner_type, v) }
|
397
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
398
|
+
k_type = Regexp.last_match[:k_type]
|
399
|
+
v_type = Regexp.last_match[:v_type]
|
400
|
+
{}.tap do |hash|
|
401
|
+
value.each do |k, v|
|
402
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
403
|
+
end
|
404
|
+
end
|
405
|
+
else # model
|
406
|
+
CityPayApiClient.const_get(type).build_from_hash(value)
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
# Returns the string representation of the object
|
411
|
+
# @return [String] String presentation of the object
|
412
|
+
def to_s
|
413
|
+
to_hash.to_s
|
414
|
+
end
|
415
|
+
|
416
|
+
# to_body is an alias to to_hash (backward compatibility)
|
417
|
+
# @return [Hash] Returns the object in the form of hash
|
418
|
+
def to_body
|
419
|
+
to_hash
|
420
|
+
end
|
421
|
+
|
422
|
+
# Returns the object in the form of hash
|
423
|
+
# @return [Hash] Returns the object in the form of hash
|
424
|
+
def to_hash
|
425
|
+
hash = {}
|
426
|
+
self.class.attribute_map.each_pair do |attr, param|
|
427
|
+
value = self.send(attr)
|
428
|
+
if value.nil?
|
429
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
430
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
431
|
+
end
|
432
|
+
|
433
|
+
hash[param] = _to_hash(value)
|
434
|
+
end
|
435
|
+
hash
|
436
|
+
end
|
437
|
+
|
438
|
+
# Outputs non-array value in the form of hash
|
439
|
+
# For object, use to_hash. Otherwise, just return the value
|
440
|
+
# @param [Object] value Any valid value
|
441
|
+
# @return [Hash] Returns the value in the form of hash
|
442
|
+
def _to_hash(value)
|
443
|
+
if value.is_a?(Array)
|
444
|
+
value.compact.map { |v| _to_hash(v) }
|
445
|
+
elsif value.is_a?(Hash)
|
446
|
+
{}.tap do |hash|
|
447
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
448
|
+
end
|
449
|
+
elsif value.respond_to? :to_hash
|
450
|
+
value.to_hash
|
451
|
+
else
|
452
|
+
value
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
end
|