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.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +176 -0
  4. data/Rakefile +10 -0
  5. data/citypay_api_client.gemspec +39 -0
  6. data/docs/AccountCreate.md +19 -0
  7. data/docs/AccountStatus.md +17 -0
  8. data/docs/Acknowledgement.md +23 -0
  9. data/docs/AirlineAdvice.md +47 -0
  10. data/docs/AirlineSegment.md +31 -0
  11. data/docs/AuthReference.md +43 -0
  12. data/docs/AuthReferences.md +17 -0
  13. data/docs/AuthRequest.md +59 -0
  14. data/docs/AuthResponse.md +69 -0
  15. data/docs/AuthenRequired.md +21 -0
  16. data/docs/CResAuthRequest.md +17 -0
  17. data/docs/CaptureRequest.md +27 -0
  18. data/docs/Card.md +51 -0
  19. data/docs/CardHolderAccount.md +31 -0
  20. data/docs/CardHolderAccountApi.md +515 -0
  21. data/docs/CardStatus.md +19 -0
  22. data/docs/ChargeRequest.md +41 -0
  23. data/docs/ContactDetails.md +41 -0
  24. data/docs/Decision.md +21 -0
  25. data/docs/Error.md +23 -0
  26. data/docs/ExternalMPI.md +25 -0
  27. data/docs/ListMerchantsResponse.md +21 -0
  28. data/docs/MCC6012.md +23 -0
  29. data/docs/Merchant.md +25 -0
  30. data/docs/OperationalApi.md +118 -0
  31. data/docs/PaResAuthRequest.md +19 -0
  32. data/docs/PaymentProcessingApi.md +338 -0
  33. data/docs/Ping.md +17 -0
  34. data/docs/RegisterCard.md +23 -0
  35. data/docs/RequestChallenged.md +25 -0
  36. data/docs/RetrieveRequest.md +21 -0
  37. data/docs/ThreeDSecure.md +25 -0
  38. data/docs/VoidRequest.md +23 -0
  39. data/git_push.sh +58 -0
  40. data/lib/citypay_api_client.rb +72 -0
  41. data/lib/citypay_api_client/api/card_holder_account_api.rb +628 -0
  42. data/lib/citypay_api_client/api/operational_api.rb +148 -0
  43. data/lib/citypay_api_client/api/payment_processing_api.rb +406 -0
  44. data/lib/citypay_api_client/api_client.rb +388 -0
  45. data/lib/citypay_api_client/api_error.rb +57 -0
  46. data/lib/citypay_api_client/configuration.rb +252 -0
  47. data/lib/citypay_api_client/models/account_create.rb +249 -0
  48. data/lib/citypay_api_client/models/account_status.rb +207 -0
  49. data/lib/citypay_api_client/models/acknowledgement.rb +285 -0
  50. data/lib/citypay_api_client/models/airline_advice.rb +551 -0
  51. data/lib/citypay_api_client/models/airline_segment.rb +408 -0
  52. data/lib/citypay_api_client/models/api_key.rb +53 -0
  53. data/lib/citypay_api_client/models/auth_reference.rb +400 -0
  54. data/lib/citypay_api_client/models/auth_references.rb +208 -0
  55. data/lib/citypay_api_client/models/auth_request.rb +631 -0
  56. data/lib/citypay_api_client/models/auth_response.rb +563 -0
  57. data/lib/citypay_api_client/models/authen_required.rb +227 -0
  58. data/lib/citypay_api_client/models/c_res_auth_request.rb +207 -0
  59. data/lib/citypay_api_client/models/capture_request.rb +285 -0
  60. data/lib/citypay_api_client/models/card.rb +425 -0
  61. data/lib/citypay_api_client/models/card_holder_account.rb +315 -0
  62. data/lib/citypay_api_client/models/card_status.rb +217 -0
  63. data/lib/citypay_api_client/models/charge_request.rb +453 -0
  64. data/lib/citypay_api_client/models/contact_details.rb +456 -0
  65. data/lib/citypay_api_client/models/decision.rb +224 -0
  66. data/lib/citypay_api_client/models/error.rb +285 -0
  67. data/lib/citypay_api_client/models/external_mpi.rb +307 -0
  68. data/lib/citypay_api_client/models/list_merchants_response.rb +252 -0
  69. data/lib/citypay_api_client/models/mcc6012.rb +237 -0
  70. data/lib/citypay_api_client/models/merchant.rb +247 -0
  71. data/lib/citypay_api_client/models/pa_res_auth_request.rb +227 -0
  72. data/lib/citypay_api_client/models/ping.rb +231 -0
  73. data/lib/citypay_api_client/models/register_card.rb +336 -0
  74. data/lib/citypay_api_client/models/request_challenged.rb +247 -0
  75. data/lib/citypay_api_client/models/retrieve_request.rb +256 -0
  76. data/lib/citypay_api_client/models/three_d_secure.rb +247 -0
  77. data/lib/citypay_api_client/models/void_request.rb +266 -0
  78. data/lib/citypay_api_client/version.rb +15 -0
  79. data/spec/api/card_holder_account_api_spec.rb +149 -0
  80. data/spec/api/operational_api_spec.rb +59 -0
  81. data/spec/api/payment_processing_api_spec.rb +107 -0
  82. data/spec/api_client_spec.rb +226 -0
  83. data/spec/configuration_spec.rb +42 -0
  84. data/spec/models/account_create_spec.rb +47 -0
  85. data/spec/models/account_status_spec.rb +41 -0
  86. data/spec/models/acknowledgement_spec.rb +59 -0
  87. data/spec/models/airline_advice_spec.rb +131 -0
  88. data/spec/models/airline_segment_spec.rb +83 -0
  89. data/spec/models/auth_reference_spec.rb +119 -0
  90. data/spec/models/auth_references_spec.rb +41 -0
  91. data/spec/models/auth_request_spec.rb +167 -0
  92. data/spec/models/auth_response_spec.rb +197 -0
  93. data/spec/models/authen_required_spec.rb +53 -0
  94. data/spec/models/c_res_auth_request_spec.rb +41 -0
  95. data/spec/models/capture_request_spec.rb +71 -0
  96. data/spec/models/card_holder_account_spec.rb +83 -0
  97. data/spec/models/card_spec.rb +143 -0
  98. data/spec/models/card_status_spec.rb +47 -0
  99. data/spec/models/charge_request_spec.rb +113 -0
  100. data/spec/models/contact_details_spec.rb +113 -0
  101. data/spec/models/decision_spec.rb +53 -0
  102. data/spec/models/error_spec.rb +59 -0
  103. data/spec/models/external_mpi_spec.rb +65 -0
  104. data/spec/models/list_merchants_response_spec.rb +53 -0
  105. data/spec/models/mcc6012_spec.rb +59 -0
  106. data/spec/models/merchant_spec.rb +65 -0
  107. data/spec/models/pa_res_auth_request_spec.rb +47 -0
  108. data/spec/models/ping_spec.rb +41 -0
  109. data/spec/models/register_card_spec.rb +59 -0
  110. data/spec/models/request_challenged_spec.rb +65 -0
  111. data/spec/models/retrieve_request_spec.rb +53 -0
  112. data/spec/models/three_d_secure_spec.rb +65 -0
  113. data/spec/models/void_request_spec.rb +59 -0
  114. data/spec/spec_helper.rb +111 -0
  115. metadata +252 -0
@@ -0,0 +1,237 @@
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 MCC6012
17
+ # The account number of the recipient.
18
+ attr_accessor :recipient_account
19
+
20
+ # The date of birth of the recipient.
21
+ attr_accessor :recipient_dob
22
+
23
+ # The lastname of ther recepient.
24
+ attr_accessor :recipient_lastname
25
+
26
+ # The postcode of the recipient.
27
+ attr_accessor :recipient_postcode
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'recipient_account' => :'recipient_account',
33
+ :'recipient_dob' => :'recipient_dob',
34
+ :'recipient_lastname' => :'recipient_lastname',
35
+ :'recipient_postcode' => :'recipient_postcode'
36
+ }
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'recipient_account' => :'String',
43
+ :'recipient_dob' => :'String',
44
+ :'recipient_lastname' => :'String',
45
+ :'recipient_postcode' => :'String'
46
+ }
47
+ end
48
+
49
+ # List of attributes with nullable: true
50
+ def self.openapi_nullable
51
+ Set.new([
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::MCC6012` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::MCC6012`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'recipient_account')
71
+ self.recipient_account = attributes[:'recipient_account']
72
+ end
73
+
74
+ if attributes.key?(:'recipient_dob')
75
+ self.recipient_dob = attributes[:'recipient_dob']
76
+ end
77
+
78
+ if attributes.key?(:'recipient_lastname')
79
+ self.recipient_lastname = attributes[:'recipient_lastname']
80
+ end
81
+
82
+ if attributes.key?(:'recipient_postcode')
83
+ self.recipient_postcode = attributes[:'recipient_postcode']
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ recipient_account == o.recipient_account &&
106
+ recipient_dob == o.recipient_dob &&
107
+ recipient_lastname == o.recipient_lastname &&
108
+ recipient_postcode == o.recipient_postcode
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [recipient_account, recipient_dob, recipient_lastname, recipient_postcode].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ new.build_from_hash(attributes)
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.openapi_types.each_pair do |key, type|
136
+ if type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
145
+ end
146
+
147
+ self
148
+ end
149
+
150
+ # Deserializes the data based on type
151
+ # @param string type Data type
152
+ # @param string value Value to be deserialized
153
+ # @return [Object] Deserialized data
154
+ def _deserialize(type, value)
155
+ case type.to_sym
156
+ when :DateTime
157
+ DateTime.parse(value)
158
+ when :Date
159
+ Date.parse(value)
160
+ when :String
161
+ value.to_s
162
+ when :Integer
163
+ value.to_i
164
+ when :Float
165
+ value.to_f
166
+ when :Boolean
167
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
+ true
169
+ else
170
+ false
171
+ end
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ else # model
187
+ CityPayApiClient.const_get(type).build_from_hash(value)
188
+ end
189
+ end
190
+
191
+ # Returns the string representation of the object
192
+ # @return [String] String presentation of the object
193
+ def to_s
194
+ to_hash.to_s
195
+ end
196
+
197
+ # to_body is an alias to to_hash (backward compatibility)
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_body
200
+ to_hash
201
+ end
202
+
203
+ # Returns the object in the form of hash
204
+ # @return [Hash] Returns the object in the form of hash
205
+ def to_hash
206
+ hash = {}
207
+ self.class.attribute_map.each_pair do |attr, param|
208
+ value = self.send(attr)
209
+ if value.nil?
210
+ is_nullable = self.class.openapi_nullable.include?(attr)
211
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
212
+ end
213
+
214
+ hash[param] = _to_hash(value)
215
+ end
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.compact.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to? :to_hash
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+ end
237
+ end
@@ -0,0 +1,247 @@
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 Merchant
17
+ # The currency of the merchant.
18
+ attr_accessor :currency
19
+
20
+ # The merchant id which uniquely identifies the merchant account.
21
+ attr_accessor :merchantid
22
+
23
+ # The name of the merchant.
24
+ attr_accessor :name
25
+
26
+ # The status of the account.
27
+ attr_accessor :status
28
+
29
+ # The status label of the account.
30
+ attr_accessor :status_label
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'currency' => :'currency',
36
+ :'merchantid' => :'merchantid',
37
+ :'name' => :'name',
38
+ :'status' => :'status',
39
+ :'status_label' => :'status_label'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'currency' => :'String',
47
+ :'merchantid' => :'Integer',
48
+ :'name' => :'String',
49
+ :'status' => :'String',
50
+ :'status_label' => :'String'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::Merchant` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::Merchant`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'currency')
76
+ self.currency = attributes[:'currency']
77
+ end
78
+
79
+ if attributes.key?(:'merchantid')
80
+ self.merchantid = attributes[:'merchantid']
81
+ end
82
+
83
+ if attributes.key?(:'name')
84
+ self.name = attributes[:'name']
85
+ end
86
+
87
+ if attributes.key?(:'status')
88
+ self.status = attributes[:'status']
89
+ end
90
+
91
+ if attributes.key?(:'status_label')
92
+ self.status_label = attributes[:'status_label']
93
+ end
94
+ end
95
+
96
+ # Show invalid properties with the reasons. Usually used together with valid?
97
+ # @return Array for valid properties with the reasons
98
+ def list_invalid_properties
99
+ invalid_properties = Array.new
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ true
107
+ end
108
+
109
+ # Checks equality by comparing each attribute.
110
+ # @param [Object] Object to be compared
111
+ def ==(o)
112
+ return true if self.equal?(o)
113
+ self.class == o.class &&
114
+ currency == o.currency &&
115
+ merchantid == o.merchantid &&
116
+ name == o.name &&
117
+ status == o.status &&
118
+ status_label == o.status_label
119
+ end
120
+
121
+ # @see the `==` method
122
+ # @param [Object] Object to be compared
123
+ def eql?(o)
124
+ self == o
125
+ end
126
+
127
+ # Calculates hash code according to all attributes.
128
+ # @return [Integer] Hash code
129
+ def hash
130
+ [currency, merchantid, name, status, status_label].hash
131
+ end
132
+
133
+ # Builds the object from hash
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ # @return [Object] Returns the model itself
136
+ def self.build_from_hash(attributes)
137
+ new.build_from_hash(attributes)
138
+ end
139
+
140
+ # Builds the object from hash
141
+ # @param [Hash] attributes Model attributes in the form of hash
142
+ # @return [Object] Returns the model itself
143
+ def build_from_hash(attributes)
144
+ return nil unless attributes.is_a?(Hash)
145
+ self.class.openapi_types.each_pair do |key, type|
146
+ if type =~ /\AArray<(.*)>/i
147
+ # check to ensure the input is an array given that the attribute
148
+ # is documented as an array but the input is not
149
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
150
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
151
+ end
152
+ elsif !attributes[self.class.attribute_map[key]].nil?
153
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
154
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
155
+ end
156
+
157
+ self
158
+ end
159
+
160
+ # Deserializes the data based on type
161
+ # @param string type Data type
162
+ # @param string value Value to be deserialized
163
+ # @return [Object] Deserialized data
164
+ def _deserialize(type, value)
165
+ case type.to_sym
166
+ when :DateTime
167
+ DateTime.parse(value)
168
+ when :Date
169
+ Date.parse(value)
170
+ when :String
171
+ value.to_s
172
+ when :Integer
173
+ value.to_i
174
+ when :Float
175
+ value.to_f
176
+ when :Boolean
177
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
178
+ true
179
+ else
180
+ false
181
+ end
182
+ when :Object
183
+ # generic object (usually a Hash), return directly
184
+ value
185
+ when /\AArray<(?<inner_type>.+)>\z/
186
+ inner_type = Regexp.last_match[:inner_type]
187
+ value.map { |v| _deserialize(inner_type, v) }
188
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
189
+ k_type = Regexp.last_match[:k_type]
190
+ v_type = Regexp.last_match[:v_type]
191
+ {}.tap do |hash|
192
+ value.each do |k, v|
193
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
194
+ end
195
+ end
196
+ else # model
197
+ CityPayApiClient.const_get(type).build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+ end
247
+ end