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,408 @@
|
|
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 AirlineSegment
|
17
|
+
# A standard airline routing code (airport code or location identifier) applicable to the arrival portion of this segment.
|
18
|
+
attr_accessor :arrival_location_code
|
19
|
+
|
20
|
+
# This field contains the two character airline designator code (air carrier code or airline code) that corresponds to the airline carrier applicable for up to four flight segments of this trip itinerary.
|
21
|
+
attr_accessor :carrier_code
|
22
|
+
|
23
|
+
# This field contains a code that corresponds to the fare class (A, B, C, D, Premium, Discounted, etc.) within the overall class of service (e.g., First Class, Business, Economy) applicable to this travel segment, as specified in the IATA Standard Code allocation table.
|
24
|
+
attr_accessor :class_service_code
|
25
|
+
|
26
|
+
# The Departure Date for the travel segment in ISO Date Format (yyyy-MM-dd).
|
27
|
+
attr_accessor :departure_date
|
28
|
+
|
29
|
+
# A standard airline routing code (airport code or location identifier) applicable to the departure portion of this segment.
|
30
|
+
attr_accessor :departure_location_code
|
31
|
+
|
32
|
+
# This field contains the carrier-assigned Flight Number for this travel segment.
|
33
|
+
attr_accessor :flight_number
|
34
|
+
|
35
|
+
# This field contains the total Fare for this travel segment.
|
36
|
+
attr_accessor :segment_fare
|
37
|
+
|
38
|
+
# O = Stopover allowed, X = Stopover not allowed.
|
39
|
+
attr_accessor :stop_over_indicator
|
40
|
+
|
41
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
42
|
+
def self.attribute_map
|
43
|
+
{
|
44
|
+
:'arrival_location_code' => :'arrival_location_code',
|
45
|
+
:'carrier_code' => :'carrier_code',
|
46
|
+
:'class_service_code' => :'class_service_code',
|
47
|
+
:'departure_date' => :'departure_date',
|
48
|
+
:'departure_location_code' => :'departure_location_code',
|
49
|
+
:'flight_number' => :'flight_number',
|
50
|
+
:'segment_fare' => :'segment_fare',
|
51
|
+
:'stop_over_indicator' => :'stop_over_indicator'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# Attribute type mapping.
|
56
|
+
def self.openapi_types
|
57
|
+
{
|
58
|
+
:'arrival_location_code' => :'String',
|
59
|
+
:'carrier_code' => :'String',
|
60
|
+
:'class_service_code' => :'String',
|
61
|
+
:'departure_date' => :'Date',
|
62
|
+
:'departure_location_code' => :'String',
|
63
|
+
:'flight_number' => :'String',
|
64
|
+
:'segment_fare' => :'Integer',
|
65
|
+
:'stop_over_indicator' => :'String'
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
# List of attributes with nullable: true
|
70
|
+
def self.openapi_nullable
|
71
|
+
Set.new([
|
72
|
+
])
|
73
|
+
end
|
74
|
+
|
75
|
+
# Initializes the object
|
76
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
77
|
+
def initialize(attributes = {})
|
78
|
+
if (!attributes.is_a?(Hash))
|
79
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::AirlineSegment` initialize method"
|
80
|
+
end
|
81
|
+
|
82
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
83
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
84
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
85
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `CityPayApiClient::AirlineSegment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
86
|
+
end
|
87
|
+
h[k.to_sym] = v
|
88
|
+
}
|
89
|
+
|
90
|
+
if attributes.key?(:'arrival_location_code')
|
91
|
+
self.arrival_location_code = attributes[:'arrival_location_code']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'carrier_code')
|
95
|
+
self.carrier_code = attributes[:'carrier_code']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'class_service_code')
|
99
|
+
self.class_service_code = attributes[:'class_service_code']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.key?(:'departure_date')
|
103
|
+
self.departure_date = attributes[:'departure_date']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'departure_location_code')
|
107
|
+
self.departure_location_code = attributes[:'departure_location_code']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'flight_number')
|
111
|
+
self.flight_number = attributes[:'flight_number']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.key?(:'segment_fare')
|
115
|
+
self.segment_fare = attributes[:'segment_fare']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'stop_over_indicator')
|
119
|
+
self.stop_over_indicator = attributes[:'stop_over_indicator']
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
124
|
+
# @return Array for valid properties with the reasons
|
125
|
+
def list_invalid_properties
|
126
|
+
invalid_properties = Array.new
|
127
|
+
if @arrival_location_code.nil?
|
128
|
+
invalid_properties.push('invalid value for "arrival_location_code", arrival_location_code cannot be nil.')
|
129
|
+
end
|
130
|
+
|
131
|
+
if @arrival_location_code.to_s.length > 3
|
132
|
+
invalid_properties.push('invalid value for "arrival_location_code", the character length must be smaller than or equal to 3.')
|
133
|
+
end
|
134
|
+
|
135
|
+
if @carrier_code.nil?
|
136
|
+
invalid_properties.push('invalid value for "carrier_code", carrier_code cannot be nil.')
|
137
|
+
end
|
138
|
+
|
139
|
+
if @carrier_code.to_s.length > 2
|
140
|
+
invalid_properties.push('invalid value for "carrier_code", the character length must be smaller than or equal to 2.')
|
141
|
+
end
|
142
|
+
|
143
|
+
if @class_service_code.nil?
|
144
|
+
invalid_properties.push('invalid value for "class_service_code", class_service_code cannot be nil.')
|
145
|
+
end
|
146
|
+
|
147
|
+
if @class_service_code.to_s.length > 2
|
148
|
+
invalid_properties.push('invalid value for "class_service_code", the character length must be smaller than or equal to 2.')
|
149
|
+
end
|
150
|
+
|
151
|
+
if @departure_date.nil?
|
152
|
+
invalid_properties.push('invalid value for "departure_date", departure_date cannot be nil.')
|
153
|
+
end
|
154
|
+
|
155
|
+
if !@departure_location_code.nil? && @departure_location_code.to_s.length > 3
|
156
|
+
invalid_properties.push('invalid value for "departure_location_code", the character length must be smaller than or equal to 3.')
|
157
|
+
end
|
158
|
+
|
159
|
+
if @flight_number.nil?
|
160
|
+
invalid_properties.push('invalid value for "flight_number", flight_number cannot be nil.')
|
161
|
+
end
|
162
|
+
|
163
|
+
if @flight_number.to_s.length > 4
|
164
|
+
invalid_properties.push('invalid value for "flight_number", the character length must be smaller than or equal to 4.')
|
165
|
+
end
|
166
|
+
|
167
|
+
if !@stop_over_indicator.nil? && @stop_over_indicator.to_s.length > 1
|
168
|
+
invalid_properties.push('invalid value for "stop_over_indicator", the character length must be smaller than or equal to 1.')
|
169
|
+
end
|
170
|
+
|
171
|
+
invalid_properties
|
172
|
+
end
|
173
|
+
|
174
|
+
# Check to see if the all the properties in the model are valid
|
175
|
+
# @return true if the model is valid
|
176
|
+
def valid?
|
177
|
+
return false if @arrival_location_code.nil?
|
178
|
+
return false if @arrival_location_code.to_s.length > 3
|
179
|
+
return false if @carrier_code.nil?
|
180
|
+
return false if @carrier_code.to_s.length > 2
|
181
|
+
return false if @class_service_code.nil?
|
182
|
+
return false if @class_service_code.to_s.length > 2
|
183
|
+
return false if @departure_date.nil?
|
184
|
+
return false if !@departure_location_code.nil? && @departure_location_code.to_s.length > 3
|
185
|
+
return false if @flight_number.nil?
|
186
|
+
return false if @flight_number.to_s.length > 4
|
187
|
+
return false if !@stop_over_indicator.nil? && @stop_over_indicator.to_s.length > 1
|
188
|
+
true
|
189
|
+
end
|
190
|
+
|
191
|
+
# Custom attribute writer method with validation
|
192
|
+
# @param [Object] arrival_location_code Value to be assigned
|
193
|
+
def arrival_location_code=(arrival_location_code)
|
194
|
+
if arrival_location_code.nil?
|
195
|
+
fail ArgumentError, 'arrival_location_code cannot be nil'
|
196
|
+
end
|
197
|
+
|
198
|
+
if arrival_location_code.to_s.length > 3
|
199
|
+
fail ArgumentError, 'invalid value for "arrival_location_code", the character length must be smaller than or equal to 3.'
|
200
|
+
end
|
201
|
+
|
202
|
+
@arrival_location_code = arrival_location_code
|
203
|
+
end
|
204
|
+
|
205
|
+
# Custom attribute writer method with validation
|
206
|
+
# @param [Object] carrier_code Value to be assigned
|
207
|
+
def carrier_code=(carrier_code)
|
208
|
+
if carrier_code.nil?
|
209
|
+
fail ArgumentError, 'carrier_code cannot be nil'
|
210
|
+
end
|
211
|
+
|
212
|
+
if carrier_code.to_s.length > 2
|
213
|
+
fail ArgumentError, 'invalid value for "carrier_code", the character length must be smaller than or equal to 2.'
|
214
|
+
end
|
215
|
+
|
216
|
+
@carrier_code = carrier_code
|
217
|
+
end
|
218
|
+
|
219
|
+
# Custom attribute writer method with validation
|
220
|
+
# @param [Object] class_service_code Value to be assigned
|
221
|
+
def class_service_code=(class_service_code)
|
222
|
+
if class_service_code.nil?
|
223
|
+
fail ArgumentError, 'class_service_code cannot be nil'
|
224
|
+
end
|
225
|
+
|
226
|
+
if class_service_code.to_s.length > 2
|
227
|
+
fail ArgumentError, 'invalid value for "class_service_code", the character length must be smaller than or equal to 2.'
|
228
|
+
end
|
229
|
+
|
230
|
+
@class_service_code = class_service_code
|
231
|
+
end
|
232
|
+
|
233
|
+
# Custom attribute writer method with validation
|
234
|
+
# @param [Object] departure_location_code Value to be assigned
|
235
|
+
def departure_location_code=(departure_location_code)
|
236
|
+
if !departure_location_code.nil? && departure_location_code.to_s.length > 3
|
237
|
+
fail ArgumentError, 'invalid value for "departure_location_code", the character length must be smaller than or equal to 3.'
|
238
|
+
end
|
239
|
+
|
240
|
+
@departure_location_code = departure_location_code
|
241
|
+
end
|
242
|
+
|
243
|
+
# Custom attribute writer method with validation
|
244
|
+
# @param [Object] flight_number Value to be assigned
|
245
|
+
def flight_number=(flight_number)
|
246
|
+
if flight_number.nil?
|
247
|
+
fail ArgumentError, 'flight_number cannot be nil'
|
248
|
+
end
|
249
|
+
|
250
|
+
if flight_number.to_s.length > 4
|
251
|
+
fail ArgumentError, 'invalid value for "flight_number", the character length must be smaller than or equal to 4.'
|
252
|
+
end
|
253
|
+
|
254
|
+
@flight_number = flight_number
|
255
|
+
end
|
256
|
+
|
257
|
+
# Custom attribute writer method with validation
|
258
|
+
# @param [Object] stop_over_indicator Value to be assigned
|
259
|
+
def stop_over_indicator=(stop_over_indicator)
|
260
|
+
if !stop_over_indicator.nil? && stop_over_indicator.to_s.length > 1
|
261
|
+
fail ArgumentError, 'invalid value for "stop_over_indicator", the character length must be smaller than or equal to 1.'
|
262
|
+
end
|
263
|
+
|
264
|
+
@stop_over_indicator = stop_over_indicator
|
265
|
+
end
|
266
|
+
|
267
|
+
# Checks equality by comparing each attribute.
|
268
|
+
# @param [Object] Object to be compared
|
269
|
+
def ==(o)
|
270
|
+
return true if self.equal?(o)
|
271
|
+
self.class == o.class &&
|
272
|
+
arrival_location_code == o.arrival_location_code &&
|
273
|
+
carrier_code == o.carrier_code &&
|
274
|
+
class_service_code == o.class_service_code &&
|
275
|
+
departure_date == o.departure_date &&
|
276
|
+
departure_location_code == o.departure_location_code &&
|
277
|
+
flight_number == o.flight_number &&
|
278
|
+
segment_fare == o.segment_fare &&
|
279
|
+
stop_over_indicator == o.stop_over_indicator
|
280
|
+
end
|
281
|
+
|
282
|
+
# @see the `==` method
|
283
|
+
# @param [Object] Object to be compared
|
284
|
+
def eql?(o)
|
285
|
+
self == o
|
286
|
+
end
|
287
|
+
|
288
|
+
# Calculates hash code according to all attributes.
|
289
|
+
# @return [Integer] Hash code
|
290
|
+
def hash
|
291
|
+
[arrival_location_code, carrier_code, class_service_code, departure_date, departure_location_code, flight_number, segment_fare, stop_over_indicator].hash
|
292
|
+
end
|
293
|
+
|
294
|
+
# Builds the object from hash
|
295
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
296
|
+
# @return [Object] Returns the model itself
|
297
|
+
def self.build_from_hash(attributes)
|
298
|
+
new.build_from_hash(attributes)
|
299
|
+
end
|
300
|
+
|
301
|
+
# Builds the object from hash
|
302
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
303
|
+
# @return [Object] Returns the model itself
|
304
|
+
def build_from_hash(attributes)
|
305
|
+
return nil unless attributes.is_a?(Hash)
|
306
|
+
self.class.openapi_types.each_pair do |key, type|
|
307
|
+
if type =~ /\AArray<(.*)>/i
|
308
|
+
# check to ensure the input is an array given that the attribute
|
309
|
+
# is documented as an array but the input is not
|
310
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
311
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
312
|
+
end
|
313
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
314
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
315
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
316
|
+
end
|
317
|
+
|
318
|
+
self
|
319
|
+
end
|
320
|
+
|
321
|
+
# Deserializes the data based on type
|
322
|
+
# @param string type Data type
|
323
|
+
# @param string value Value to be deserialized
|
324
|
+
# @return [Object] Deserialized data
|
325
|
+
def _deserialize(type, value)
|
326
|
+
case type.to_sym
|
327
|
+
when :DateTime
|
328
|
+
DateTime.parse(value)
|
329
|
+
when :Date
|
330
|
+
Date.parse(value)
|
331
|
+
when :String
|
332
|
+
value.to_s
|
333
|
+
when :Integer
|
334
|
+
value.to_i
|
335
|
+
when :Float
|
336
|
+
value.to_f
|
337
|
+
when :Boolean
|
338
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
339
|
+
true
|
340
|
+
else
|
341
|
+
false
|
342
|
+
end
|
343
|
+
when :Object
|
344
|
+
# generic object (usually a Hash), return directly
|
345
|
+
value
|
346
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
347
|
+
inner_type = Regexp.last_match[:inner_type]
|
348
|
+
value.map { |v| _deserialize(inner_type, v) }
|
349
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
350
|
+
k_type = Regexp.last_match[:k_type]
|
351
|
+
v_type = Regexp.last_match[:v_type]
|
352
|
+
{}.tap do |hash|
|
353
|
+
value.each do |k, v|
|
354
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
355
|
+
end
|
356
|
+
end
|
357
|
+
else # model
|
358
|
+
CityPayApiClient.const_get(type).build_from_hash(value)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
# Returns the string representation of the object
|
363
|
+
# @return [String] String presentation of the object
|
364
|
+
def to_s
|
365
|
+
to_hash.to_s
|
366
|
+
end
|
367
|
+
|
368
|
+
# to_body is an alias to to_hash (backward compatibility)
|
369
|
+
# @return [Hash] Returns the object in the form of hash
|
370
|
+
def to_body
|
371
|
+
to_hash
|
372
|
+
end
|
373
|
+
|
374
|
+
# Returns the object in the form of hash
|
375
|
+
# @return [Hash] Returns the object in the form of hash
|
376
|
+
def to_hash
|
377
|
+
hash = {}
|
378
|
+
self.class.attribute_map.each_pair do |attr, param|
|
379
|
+
value = self.send(attr)
|
380
|
+
if value.nil?
|
381
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
382
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
383
|
+
end
|
384
|
+
|
385
|
+
hash[param] = _to_hash(value)
|
386
|
+
end
|
387
|
+
hash
|
388
|
+
end
|
389
|
+
|
390
|
+
# Outputs non-array value in the form of hash
|
391
|
+
# For object, use to_hash. Otherwise, just return the value
|
392
|
+
# @param [Object] value Any valid value
|
393
|
+
# @return [Hash] Returns the value in the form of hash
|
394
|
+
def _to_hash(value)
|
395
|
+
if value.is_a?(Array)
|
396
|
+
value.compact.map { |v| _to_hash(v) }
|
397
|
+
elsif value.is_a?(Hash)
|
398
|
+
{}.tap do |hash|
|
399
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
400
|
+
end
|
401
|
+
elsif value.respond_to? :to_hash
|
402
|
+
value.to_hash
|
403
|
+
else
|
404
|
+
value
|
405
|
+
end
|
406
|
+
end
|
407
|
+
end
|
408
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'openssl'
|
3
|
+
require 'Base64'
|
4
|
+
|
5
|
+
module CityPayApiClient
|
6
|
+
class AuthReference
|
7
|
+
|
8
|
+
def initialize(client_id: , licence_key: )
|
9
|
+
@client_id, @licence_key = client_id, licence_key
|
10
|
+
@nonce = []
|
11
|
+
@datetime = DateTime.now()
|
12
|
+
end
|
13
|
+
|
14
|
+
def client_id
|
15
|
+
@client_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def nonce=(nonce)
|
19
|
+
@nonce = nonce
|
20
|
+
end
|
21
|
+
|
22
|
+
def datetime=(datetime)
|
23
|
+
@datetime = datetime
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate
|
27
|
+
ds = datetime.strftime("%Y%m%d%H%M")
|
28
|
+
|
29
|
+
# ds = dt.strftime("%Y%m%d%H%M")
|
30
|
+
# message = bytearray()
|
31
|
+
# message += bytes(client_id, 'utf-8')
|
32
|
+
# message += nonce
|
33
|
+
# message += bytes.fromhex(ds)
|
34
|
+
digest = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, msg)
|
35
|
+
# digest = hmac.new(bytes(licence_key, 'utf-8'),
|
36
|
+
# msg=message,
|
37
|
+
# digestmod=hashlib.sha256).digest()
|
38
|
+
# dest = bytearray()
|
39
|
+
# dest += bytes(client_id, 'utf-8')
|
40
|
+
# dest += b'\x3A'
|
41
|
+
# dest += bytes(nonce.hex().upper(), 'utf-8')
|
42
|
+
# dest += b'\x3A'
|
43
|
+
# dest += digest
|
44
|
+
# return base64.b64encode(dest).decode('utf-8')
|
45
|
+
|
46
|
+
# dt = datetime.strptime("2020-01-01 09:23:12", "%Y-%m-%d %H:%M:%S")
|
47
|
+
# key = api_key_generate_for("PC2", "7G79TG62BAJTK669", bytearray.fromhex("acb875aef083de292299bd69fcdeb5c5"), dt)
|
48
|
+
# self.assertEqual("UEMyOkFDQjg3NUFFRjA4M0RFMjkyMjk5QkQ2OUZDREVCNUM1Ol6Q3tCMPsYvqNhFelRD2zQHYlZquBGCY/6ZpZ0AngTF",key)
|
49
|
+
"not yet"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|