citypay_api_client 1.0.3 → 1.1.2
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 +4 -4
- data/README.md +111 -39
- data/citypay_api_client.gemspec +5 -5
- data/docs/AccountCreate.md +10 -9
- data/docs/AccountStatus.md +8 -7
- data/docs/Acknowledgement.md +14 -13
- data/docs/AclCheckRequest.md +18 -0
- data/docs/AclCheckResponseModel.md +24 -0
- data/docs/AirlineAdvice.md +38 -37
- data/docs/AirlineSegment.md +22 -21
- data/docs/AuthReference.md +34 -33
- data/docs/AuthReferences.md +8 -7
- data/docs/AuthRequest.md +52 -49
- data/docs/AuthResponse.md +64 -59
- data/docs/AuthenRequired.md +12 -11
- data/docs/AuthorisationAndPaymentApi.md +850 -0
- data/docs/Batch.md +22 -0
- data/docs/BatchProcessingApi.md +218 -0
- data/docs/BatchReportRequest.md +20 -0
- data/docs/BatchReportResponseModel.md +28 -0
- data/docs/BatchTransaction.md +24 -0
- data/docs/BatchTransactionResultModel.md +44 -0
- data/docs/Bin.md +34 -0
- data/docs/BinLookup.md +18 -0
- data/docs/CResAuthRequest.md +8 -7
- data/docs/CaptureRequest.md +18 -17
- data/docs/Card.md +46 -41
- data/docs/CardHolderAccount.md +24 -21
- data/docs/CardHolderAccountApi.md +387 -111
- data/docs/CardStatus.md +10 -9
- data/docs/ChargeRequest.md +38 -31
- data/docs/CheckBatchStatus.md +20 -0
- data/docs/CheckBatchStatusResponse.md +18 -0
- data/docs/ContactDetails.md +32 -31
- data/docs/Decision.md +12 -11
- data/docs/DirectPostApi.md +389 -0
- data/docs/DirectPostRequest.md +60 -0
- data/docs/DirectTokenAuthRequest.md +24 -0
- data/docs/DomainKeyCheckRequest.md +18 -0
- data/docs/DomainKeyRequest.md +22 -0
- data/docs/DomainKeyResponse.md +26 -0
- data/docs/Error.md +16 -13
- data/docs/EventDataModel.md +26 -0
- data/docs/Exists.md +22 -0
- data/docs/ExternalMPI.md +16 -15
- data/docs/ListMerchantsResponse.md +12 -11
- data/docs/MCC6012.md +14 -13
- data/docs/Merchant.md +16 -15
- data/docs/OperationalFunctionsApi.md +375 -0
- data/docs/PaResAuthRequest.md +10 -9
- data/docs/PaylinkAddress.md +30 -0
- data/docs/PaylinkAdjustmentRequest.md +22 -0
- data/docs/PaylinkApi.md +806 -0
- data/docs/PaylinkAttachmentRequest.md +26 -0
- data/docs/PaylinkAttachmentResult.md +22 -0
- data/docs/PaylinkBillPaymentTokenRequest.md +32 -0
- data/docs/PaylinkCardHolder.md +36 -0
- data/docs/PaylinkCart.md +30 -0
- data/docs/PaylinkCartItemModel.md +32 -0
- data/docs/PaylinkConfig.md +60 -0
- data/docs/PaylinkCustomParam.md +38 -0
- data/docs/PaylinkEmailNotificationPath.md +26 -0
- data/docs/PaylinkErrorCode.md +20 -0
- data/docs/PaylinkFieldGuardModel.md +30 -0
- data/docs/PaylinkPartPayments.md +28 -0
- data/docs/PaylinkSMSNotificationPath.md +20 -0
- data/docs/PaylinkStateEvent.md +22 -0
- data/docs/PaylinkTokenCreated.md +44 -0
- data/docs/PaylinkTokenRequestModel.md +42 -0
- data/docs/PaylinkTokenStatus.md +72 -0
- data/docs/PaylinkTokenStatusChangeRequest.md +26 -0
- data/docs/PaylinkTokenStatusChangeResponse.md +20 -0
- data/docs/PaylinkUI.md +24 -0
- data/docs/Ping.md +8 -7
- data/docs/ProcessBatchRequest.md +24 -0
- data/docs/ProcessBatchResponse.md +20 -0
- data/docs/RefundRequest.md +26 -0
- data/docs/RegisterCard.md +16 -13
- data/docs/RequestChallenged.md +16 -15
- data/docs/RetrieveRequest.md +12 -11
- data/docs/ThreeDSecure.md +32 -15
- data/docs/TokenisationResponseModel.md +36 -0
- data/docs/VoidRequest.md +12 -13
- data/docs/images/3dsv1-challenge.png +0 -0
- data/docs/images/3dsv2-challenge.png +0 -0
- data/docs/images/3dsv2-frictionless.png +0 -0
- data/docs/images/3dsv2-method-challenge.png +0 -0
- data/docs/images/3dsv2-method-frictionless.png +0 -0
- data/docs/images/3dsv2-no3d.png +0 -0
- data/docs/images/citypay-logo.svg +1 -0
- data/docs/images/direct-post-flow.png +0 -0
- data/docs/images/favicon.ico +0 -0
- data/docs/images/header.png +0 -0
- data/docs/images/logo.ai +1913 -4
- data/docs/images/logo.png +0 -0
- data/docs/images/logo.svg +1 -0
- data/docs/images/merchant-BPS-workflow.png +0 -0
- data/docs/images/paylink-field-guards.png +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/citypay_api_client/api/authorisation_and_payment_api__.rb +565 -0
- data/lib/citypay_api_client/api/batch_processing_api__.rb +225 -0
- data/lib/citypay_api_client/api/{card_holder_account_api.rb → card_holder_account_api__.rb} +136 -46
- data/lib/citypay_api_client/api/direct_post_api__.rb +373 -0
- data/lib/citypay_api_client/api/operational_functions_api__.rb +356 -0
- data/lib/citypay_api_client/api/paylink_api__.rb +614 -0
- data/lib/citypay_api_client/api_client.rb +72 -70
- data/lib/citypay_api_client/api_error.rb +3 -2
- data/lib/citypay_api_client/configuration.rb +74 -17
- data/lib/citypay_api_client/models/account_create.rb +33 -23
- data/lib/citypay_api_client/models/account_status.rb +31 -23
- data/lib/citypay_api_client/models/acknowledgement.rb +43 -27
- data/lib/citypay_api_client/models/acl_check_request.rb +221 -0
- data/lib/citypay_api_client/models/acl_check_response_model.rb +244 -0
- data/lib/citypay_api_client/models/airline_advice.rb +63 -34
- data/lib/citypay_api_client/models/airline_segment.rb +51 -25
- data/lib/citypay_api_client/models/auth_reference.rb +80 -31
- data/lib/citypay_api_client/models/auth_references.rb +31 -23
- data/lib/citypay_api_client/models/auth_request.rb +137 -56
- data/lib/citypay_api_client/models/auth_response.rb +83 -123
- data/lib/citypay_api_client/models/authen_required.rb +31 -23
- data/lib/citypay_api_client/models/batch.rb +267 -0
- data/lib/citypay_api_client/models/batch_report_request.rb +278 -0
- data/lib/citypay_api_client/models/batch_report_response_model.rb +364 -0
- data/lib/citypay_api_client/models/batch_transaction.rb +324 -0
- data/lib/citypay_api_client/models/batch_transaction_result_model.rb +452 -0
- data/lib/citypay_api_client/models/bin.rb +294 -0
- data/lib/citypay_api_client/models/bin_lookup.rb +231 -0
- data/lib/citypay_api_client/models/c_res_auth_request.rb +31 -23
- data/lib/citypay_api_client/models/capture_request.rb +59 -38
- data/lib/citypay_api_client/models/card.rb +93 -29
- data/lib/citypay_api_client/models/card_holder_account.rb +49 -27
- data/lib/citypay_api_client/models/card_status.rb +31 -23
- data/lib/citypay_api_client/models/charge_request.rb +154 -47
- data/lib/citypay_api_client/models/check_batch_status.rb +260 -0
- data/lib/citypay_api_client/models/check_batch_status_response.rb +215 -0
- data/lib/citypay_api_client/models/contact_details.rb +130 -52
- data/lib/citypay_api_client/models/decision.rb +31 -23
- data/lib/citypay_api_client/models/direct_post_request.rb +707 -0
- data/lib/citypay_api_client/models/direct_token_auth_request.rb +244 -0
- data/lib/citypay_api_client/models/domain_key_check_request.rb +249 -0
- data/lib/citypay_api_client/models/domain_key_request.rb +249 -0
- data/lib/citypay_api_client/models/domain_key_response.rb +297 -0
- data/lib/citypay_api_client/models/error.rb +57 -31
- data/lib/citypay_api_client/models/event_data_model.rb +254 -0
- data/lib/citypay_api_client/models/exists.rb +241 -0
- data/lib/citypay_api_client/models/external_mpi.rb +61 -27
- data/lib/citypay_api_client/models/list_merchants_response.rb +37 -25
- data/lib/citypay_api_client/models/mcc6012.rb +31 -23
- data/lib/citypay_api_client/models/merchant.rb +31 -23
- data/lib/citypay_api_client/models/pa_res_auth_request.rb +36 -24
- data/lib/citypay_api_client/models/paylink_address.rb +425 -0
- data/lib/citypay_api_client/models/paylink_adjustment_request.rb +272 -0
- data/lib/citypay_api_client/models/paylink_attachment_request.rb +268 -0
- data/lib/citypay_api_client/models/paylink_attachment_result.rb +248 -0
- data/lib/citypay_api_client/models/paylink_bill_payment_token_request.rb +289 -0
- data/lib/citypay_api_client/models/paylink_card_holder.rb +360 -0
- data/lib/citypay_api_client/models/paylink_cart.rb +275 -0
- data/lib/citypay_api_client/models/paylink_cart_item_model.rb +284 -0
- data/lib/citypay_api_client/models/paylink_config.rb +428 -0
- data/lib/citypay_api_client/models/paylink_custom_param.rb +321 -0
- data/lib/citypay_api_client/models/paylink_email_notification_path.rb +265 -0
- data/lib/citypay_api_client/models/paylink_error_code.rb +238 -0
- data/lib/citypay_api_client/models/paylink_field_guard_model.rb +274 -0
- data/lib/citypay_api_client/models/paylink_part_payments.rb +264 -0
- data/lib/citypay_api_client/models/paylink_sms_notification_path.rb +231 -0
- data/lib/citypay_api_client/models/paylink_state_event.rb +234 -0
- data/lib/citypay_api_client/models/paylink_token_created.rb +365 -0
- data/lib/citypay_api_client/models/paylink_token_request_model.rb +427 -0
- data/lib/citypay_api_client/models/paylink_token_status.rb +485 -0
- data/lib/citypay_api_client/models/paylink_token_status_change_request.rb +269 -0
- data/lib/citypay_api_client/models/paylink_token_status_change_response.rb +232 -0
- data/lib/citypay_api_client/models/paylink_ui.rb +244 -0
- data/lib/citypay_api_client/models/ping.rb +37 -25
- data/lib/citypay_api_client/models/process_batch_request.rb +313 -0
- data/lib/citypay_api_client/models/process_batch_response.rb +231 -0
- data/lib/citypay_api_client/models/refund_request.rb +339 -0
- data/lib/citypay_api_client/models/register_card.rb +79 -27
- data/lib/citypay_api_client/models/request_challenged.rb +39 -31
- data/lib/citypay_api_client/models/retrieve_request.rb +39 -25
- data/lib/citypay_api_client/models/three_d_secure.rb +116 -28
- data/lib/citypay_api_client/models/tokenisation_response_model.rb +332 -0
- data/lib/citypay_api_client/models/void_request.rb +39 -37
- data/lib/citypay_api_client/utils/digest_utils.rb +18 -0
- data/lib/citypay_api_client/utils/direct_post_mac.rb +22 -0
- data/lib/citypay_api_client/version.rb +3 -4
- data/lib/citypay_api_client.rb +53 -6
- data/spec/.DS_Store +0 -0
- data/spec/api/authorisation_and_payment_api___spec.rb +130 -0
- data/spec/api/batch_processing_api___spec.rb +70 -0
- data/spec/api/{card_holder_account_api_spec.rb → card_holder_account_api___spec.rb} +15 -3
- data/spec/api/direct_post_api___spec.rb +98 -0
- data/spec/api/operational_functions_api___spec.rb +94 -0
- data/spec/api/paylink_api___spec.rb +131 -0
- data/spec/api_client_spec.rb +4 -4
- data/spec/configuration_spec.rb +5 -5
- data/spec/it_api_sandbox_spec.rb +117 -55
- data/spec/models/account_create_spec.rb +1 -2
- data/spec/models/account_status_spec.rb +2 -2
- data/spec/models/acknowledgement_spec.rb +7 -22
- data/spec/models/acl_check_request_spec.rb +33 -0
- data/spec/models/acl_check_response_model_spec.rb +51 -0
- data/spec/models/airline_advice_spec.rb +0 -2
- data/spec/models/airline_segment_spec.rb +0 -2
- data/spec/models/auth_references_spec.rb +7 -8
- data/spec/models/auth_request_spec.rb +0 -2
- data/spec/models/auth_response_spec.rb +77 -33
- data/spec/models/batch_report_request_spec.rb +37 -0
- data/spec/models/batch_report_response_model_spec.rb +61 -0
- data/spec/models/batch_spec.rb +43 -0
- data/spec/models/batch_transaction_result_model_spec.rb +85 -0
- data/spec/models/batch_transaction_spec.rb +49 -0
- data/spec/models/bin_lookup_spec.rb +31 -0
- data/spec/models/bin_spec.rb +81 -0
- data/spec/models/capture_request_spec.rb +0 -2
- data/spec/models/card_holder_account_spec.rb +8 -7
- data/spec/models/charge_request_spec.rb +0 -2
- data/spec/models/check_batch_status_response_spec.rb +45 -0
- data/spec/models/check_batch_status_spec.rb +39 -0
- data/spec/models/decision_spec.rb +1 -1
- data/spec/models/direct_post_request_spec.rb +151 -0
- data/spec/models/direct_token_auth_request_spec.rb +51 -0
- data/spec/models/domain_key_check_request_spec.rb +31 -0
- data/spec/models/domain_key_request_spec.rb +45 -0
- data/spec/models/domain_key_response_spec.rb +57 -0
- data/spec/models/event_data_model_spec.rb +57 -0
- data/spec/{api/operational_api_spec.rb → models/exists_spec.rb} +14 -20
- data/spec/models/list_merchants_response_spec.rb +2 -2
- data/spec/models/paylink_address_spec.rb +69 -0
- data/spec/models/paylink_adjustment_request_spec.rb +45 -0
- data/spec/models/paylink_attachment_request_spec.rb +45 -0
- data/spec/models/paylink_attachment_result_spec.rb +45 -0
- data/spec/models/paylink_bill_payment_token_request_spec.rb +63 -0
- data/spec/models/paylink_card_holder_spec.rb +87 -0
- data/spec/models/paylink_cart_item_model_spec.rb +75 -0
- data/spec/models/paylink_cart_spec.rb +69 -0
- data/spec/models/paylink_config_spec.rb +159 -0
- data/spec/models/paylink_custom_param_spec.rb +87 -0
- data/spec/models/paylink_email_notification_path_spec.rb +57 -0
- data/spec/models/paylink_error_code_spec.rb +39 -0
- data/spec/models/paylink_field_guard_model_spec.rb +45 -0
- data/spec/models/paylink_part_payments_spec.rb +63 -0
- data/spec/models/paylink_sms_notification_path_spec.rb +39 -0
- data/spec/models/paylink_state_event_spec.rb +45 -0
- data/spec/models/paylink_token_created_spec.rb +111 -0
- data/spec/models/paylink_token_request_model_spec.rb +91 -0
- data/spec/models/paylink_token_status_change_request_spec.rb +57 -0
- data/spec/models/paylink_token_status_change_response_spec.rb +39 -0
- data/spec/models/paylink_token_status_spec.rb +195 -0
- data/spec/models/paylink_ui_spec.rb +51 -0
- data/spec/models/process_batch_request_spec.rb +49 -0
- data/spec/models/process_batch_response_spec.rb +39 -0
- data/spec/models/refund_request_spec.rb +62 -0
- data/spec/models/register_card_spec.rb +0 -2
- data/spec/models/tokenisation_response_model_spec.rb +87 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/utils/direct_post_mac_spec.rb +13 -0
- metadata +230 -44
- data/Gemfile.lock +0 -70
- data/docs/OperationalApi.md +0 -112
- data/docs/PaymentProcessingApi.md +0 -320
- data/git_push.sh +0 -58
- data/lib/citypay_api_client/api/operational_api.rb +0 -147
- data/lib/citypay_api_client/api/payment_processing_api.rb +0 -405
- data/lib/citypay_api_client/test.rb +0 -20
- data/spec/api/payment_processing_api_spec.rb +0 -106
@@ -1,11 +1,11 @@
|
|
1
1
|
=begin
|
2
2
|
#CityPay Payment API
|
3
3
|
|
4
|
-
# This CityPay API is
|
4
|
+
# This CityPay API is an 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 tokenized payments using cardholder Accounts. ## Compliance and Security 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. These include * Data must be collected using TLS version 1.2 using [strong cryptography](https://citypay.github.io/api-docs/payment-api/#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 cardholder 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
5
|
|
6
6
|
Contact: support@citypay.com
|
7
7
|
Generated by: https://openapi-generator.tech
|
8
|
-
OpenAPI Generator version:
|
8
|
+
OpenAPI Generator version: 7.2.0
|
9
9
|
|
10
10
|
=end
|
11
11
|
|
@@ -13,8 +13,10 @@ require 'date'
|
|
13
13
|
require 'json'
|
14
14
|
require 'logger'
|
15
15
|
require 'tempfile'
|
16
|
+
require 'time'
|
16
17
|
require 'typhoeus'
|
17
18
|
|
19
|
+
|
18
20
|
module CityPayApiClient
|
19
21
|
class ApiClient
|
20
22
|
# The Configuration object holding settings to be used in the API client.
|
@@ -32,7 +34,8 @@ module CityPayApiClient
|
|
32
34
|
@user_agent = "OpenAPI-Ruby/#{VERSION}"
|
33
35
|
@default_headers = {
|
34
36
|
'Content-Type' => 'application/json',
|
35
|
-
'User-Agent' => @user_agent
|
37
|
+
'User-Agent' => @user_agent,
|
38
|
+
'cp-sdk' => "CP-Ruby/#{VERSION}"
|
36
39
|
}
|
37
40
|
end
|
38
41
|
|
@@ -43,9 +46,10 @@ module CityPayApiClient
|
|
43
46
|
# Call an API with given options.
|
44
47
|
#
|
45
48
|
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
46
|
-
# the data deserialized from response body (
|
49
|
+
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
|
47
50
|
def call_api(http_method, path, opts = {})
|
48
51
|
request = build_request(http_method, path, opts)
|
52
|
+
tempfile = download_file(request) if opts[:return_type] == 'File'
|
49
53
|
response = request.run
|
50
54
|
|
51
55
|
if @config.debugging
|
@@ -67,7 +71,9 @@ module CityPayApiClient
|
|
67
71
|
end
|
68
72
|
end
|
69
73
|
|
70
|
-
if opts[:return_type]
|
74
|
+
if opts[:return_type] == 'File'
|
75
|
+
data = tempfile
|
76
|
+
elsif opts[:return_type]
|
71
77
|
data = deserialize(response, opts[:return_type])
|
72
78
|
else
|
73
79
|
data = nil
|
@@ -85,12 +91,13 @@ module CityPayApiClient
|
|
85
91
|
# @option opts [Object] :body HTTP body (JSON/XML)
|
86
92
|
# @return [Typhoeus::Request] A Typhoeus Request
|
87
93
|
def build_request(http_method, path, opts = {})
|
88
|
-
url = build_request_url(path)
|
94
|
+
url = build_request_url(path, opts)
|
89
95
|
http_method = http_method.to_sym.downcase
|
90
96
|
|
91
97
|
header_params = @default_headers.merge(opts[:header_params] || {})
|
92
98
|
query_params = opts[:query_params] || {}
|
93
99
|
form_params = opts[:form_params] || {}
|
100
|
+
follow_location = opts[:follow_location] || true
|
94
101
|
|
95
102
|
update_params_for_auth! header_params, query_params, opts[:auth_names]
|
96
103
|
|
@@ -107,7 +114,8 @@ module CityPayApiClient
|
|
107
114
|
:ssl_verifyhost => _verify_ssl_host,
|
108
115
|
:sslcert => @config.cert_file,
|
109
116
|
:sslkey => @config.key_file,
|
110
|
-
:verbose => @config.debugging
|
117
|
+
:verbose => @config.debugging,
|
118
|
+
:followlocation => follow_location
|
111
119
|
}
|
112
120
|
|
113
121
|
# set custom cert, if provided
|
@@ -121,9 +129,7 @@ module CityPayApiClient
|
|
121
129
|
end
|
122
130
|
end
|
123
131
|
|
124
|
-
|
125
|
-
download_file(request) if opts[:return_type] == 'File'
|
126
|
-
request
|
132
|
+
Typhoeus::Request.new(url, req_opts)
|
127
133
|
end
|
128
134
|
|
129
135
|
# Builds the HTTP request body
|
@@ -154,6 +160,49 @@ module CityPayApiClient
|
|
154
160
|
data
|
155
161
|
end
|
156
162
|
|
163
|
+
# Save response body into a file in (the defined) temporary folder, using the filename
|
164
|
+
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
165
|
+
# The response body is written to the file in chunks in order to handle files which
|
166
|
+
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
167
|
+
# process can use.
|
168
|
+
#
|
169
|
+
# @see Configuration#temp_folder_path
|
170
|
+
#
|
171
|
+
# @return [Tempfile] the tempfile generated
|
172
|
+
def download_file(request)
|
173
|
+
tempfile = nil
|
174
|
+
encoding = nil
|
175
|
+
request.on_headers do |response|
|
176
|
+
content_disposition = response.headers['Content-Disposition']
|
177
|
+
if content_disposition && content_disposition =~ /filename=/i
|
178
|
+
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
179
|
+
prefix = sanitize_filename(filename)
|
180
|
+
else
|
181
|
+
prefix = 'download-'
|
182
|
+
end
|
183
|
+
prefix = prefix + '-' unless prefix.end_with?('-')
|
184
|
+
encoding = response.body.encoding
|
185
|
+
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
186
|
+
end
|
187
|
+
request.on_body do |chunk|
|
188
|
+
chunk.force_encoding(encoding)
|
189
|
+
tempfile.write(chunk)
|
190
|
+
end
|
191
|
+
# run the request to ensure the tempfile is created successfully before returning it
|
192
|
+
request.run
|
193
|
+
if tempfile
|
194
|
+
tempfile.close
|
195
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
196
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
197
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
198
|
+
"explicitly with `tempfile.delete`"
|
199
|
+
else
|
200
|
+
fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
|
201
|
+
end
|
202
|
+
|
203
|
+
tempfile
|
204
|
+
end
|
205
|
+
|
157
206
|
# Check if the given MIME is a JSON MIME.
|
158
207
|
# JSON MIME examples:
|
159
208
|
# application/json
|
@@ -172,15 +221,10 @@ module CityPayApiClient
|
|
172
221
|
# @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
|
173
222
|
def deserialize(response, return_type)
|
174
223
|
body = response.body
|
175
|
-
|
176
|
-
# handle file downloading - return the File instance processed in request callbacks
|
177
|
-
# note that response body is empty when the file is written in chunks in request on_body callback
|
178
|
-
return @tempfile if return_type == 'File'
|
179
|
-
|
180
224
|
return nil if body.nil? || body.empty?
|
181
225
|
|
182
226
|
# return response body directly for String return type
|
183
|
-
return body if return_type == 'String'
|
227
|
+
return body.to_s if return_type == 'String'
|
184
228
|
|
185
229
|
# ensuring a default content type
|
186
230
|
content_type = response.headers['Content-Type'] || 'application/json'
|
@@ -190,7 +234,7 @@ module CityPayApiClient
|
|
190
234
|
begin
|
191
235
|
data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
|
192
236
|
rescue JSON::ParserError => e
|
193
|
-
if %w(String Date
|
237
|
+
if %w(String Date Time).include?(return_type)
|
194
238
|
data = body
|
195
239
|
else
|
196
240
|
raise e
|
@@ -215,9 +259,9 @@ module CityPayApiClient
|
|
215
259
|
data.to_f
|
216
260
|
when 'Boolean'
|
217
261
|
data == true
|
218
|
-
when '
|
262
|
+
when 'Time'
|
219
263
|
# parse date time (expecting ISO 8601 format)
|
220
|
-
|
264
|
+
Time.parse data
|
221
265
|
when 'Date'
|
222
266
|
# parse date time (expecting ISO 8601 format)
|
223
267
|
Date.parse data
|
@@ -235,51 +279,9 @@ module CityPayApiClient
|
|
235
279
|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
236
280
|
end
|
237
281
|
else
|
238
|
-
# models
|
239
|
-
|
240
|
-
|
241
|
-
CityPayApiClient.const_get(return_type).build_from_hash(data[return_type.to_sym])
|
242
|
-
else
|
243
|
-
CityPayApiClient.const_get(return_type).build_from_hash(data)
|
244
|
-
end
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
# Save response body into a file in (the defined) temporary folder, using the filename
|
249
|
-
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
250
|
-
# The response body is written to the file in chunks in order to handle files which
|
251
|
-
# size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
|
252
|
-
# process can use.
|
253
|
-
#
|
254
|
-
# @see Configuration#temp_folder_path
|
255
|
-
def download_file(request)
|
256
|
-
tempfile = nil
|
257
|
-
encoding = nil
|
258
|
-
request.on_headers do |response|
|
259
|
-
content_disposition = response.headers['Content-Disposition']
|
260
|
-
if content_disposition && content_disposition =~ /filename=/i
|
261
|
-
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
262
|
-
prefix = sanitize_filename(filename)
|
263
|
-
else
|
264
|
-
prefix = 'download-'
|
265
|
-
end
|
266
|
-
prefix = prefix + '-' unless prefix.end_with?('-')
|
267
|
-
encoding = response.body.encoding
|
268
|
-
tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
|
269
|
-
@tempfile = tempfile
|
270
|
-
end
|
271
|
-
request.on_body do |chunk|
|
272
|
-
chunk.force_encoding(encoding)
|
273
|
-
tempfile.write(chunk)
|
274
|
-
end
|
275
|
-
request.on_complete do |response|
|
276
|
-
if tempfile
|
277
|
-
tempfile.close
|
278
|
-
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
279
|
-
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
280
|
-
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
281
|
-
"explicitly with `tempfile.delete`"
|
282
|
-
end
|
282
|
+
# models (e.g. Pet) or oneOf
|
283
|
+
klass = CityPayApiClient.const_get(return_type)
|
284
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
283
285
|
end
|
284
286
|
end
|
285
287
|
|
@@ -292,13 +294,13 @@ module CityPayApiClient
|
|
292
294
|
filename.gsub(/.*[\/\\]/, '')
|
293
295
|
end
|
294
296
|
|
295
|
-
def build_request_url(path)
|
297
|
+
def build_request_url(path, opts = {})
|
296
298
|
# Add leading and trailing slashes to path
|
297
299
|
path = "/#{path}".gsub(/\/+/, '/')
|
298
|
-
@config.base_url + path
|
300
|
+
@config.base_url(opts[:operation]) + path
|
299
301
|
end
|
300
302
|
|
301
|
-
# Update
|
303
|
+
# Update header and query params based on authentication settings.
|
302
304
|
#
|
303
305
|
# @param [Hash] header_params Header parameters
|
304
306
|
# @param [Hash] query_params Query parameters
|
@@ -310,7 +312,7 @@ module CityPayApiClient
|
|
310
312
|
case auth_setting[:in]
|
311
313
|
when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
|
312
314
|
when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
|
313
|
-
else fail ArgumentError, 'Authentication token must be in `query`
|
315
|
+
else fail ArgumentError, 'Authentication token must be in `query` or `header`'
|
314
316
|
end
|
315
317
|
end
|
316
318
|
end
|
@@ -337,8 +339,8 @@ module CityPayApiClient
|
|
337
339
|
# @param [Array] content_types array for Content-Type
|
338
340
|
# @return [String] the Content-Type header (e.g. application/json)
|
339
341
|
def select_header_content_type(content_types)
|
340
|
-
#
|
341
|
-
return
|
342
|
+
# return nil by default
|
343
|
+
return if content_types.nil? || content_types.empty?
|
342
344
|
# use JSON when present, otherwise use the first one
|
343
345
|
json_content_type = content_types.find { |s| json_mime?(s) }
|
344
346
|
json_content_type || content_types.first
|
@@ -1,11 +1,11 @@
|
|
1
1
|
=begin
|
2
2
|
#CityPay Payment API
|
3
3
|
|
4
|
-
# This CityPay API is
|
4
|
+
# This CityPay API is an 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 tokenized payments using cardholder Accounts. ## Compliance and Security 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. These include * Data must be collected using TLS version 1.2 using [strong cryptography](https://citypay.github.io/api-docs/payment-api/#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 cardholder 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
5
|
|
6
6
|
Contact: support@citypay.com
|
7
7
|
Generated by: https://openapi-generator.tech
|
8
|
-
OpenAPI Generator version:
|
8
|
+
OpenAPI Generator version: 7.2.0
|
9
9
|
|
10
10
|
=end
|
11
11
|
|
@@ -31,6 +31,7 @@ module CityPayApiClient
|
|
31
31
|
end
|
32
32
|
else
|
33
33
|
super arg
|
34
|
+
@message = arg
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
=begin
|
2
2
|
#CityPay Payment API
|
3
3
|
|
4
|
-
# This CityPay API is
|
4
|
+
# This CityPay API is an 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 tokenized payments using cardholder Accounts. ## Compliance and Security 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. These include * Data must be collected using TLS version 1.2 using [strong cryptography](https://citypay.github.io/api-docs/payment-api/#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 cardholder 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
5
|
|
6
6
|
Contact: support@citypay.com
|
7
7
|
Generated by: https://openapi-generator.tech
|
8
|
-
OpenAPI Generator version:
|
8
|
+
OpenAPI Generator version: 7.2.0
|
9
9
|
|
10
10
|
=end
|
11
11
|
|
@@ -20,6 +20,18 @@ module CityPayApiClient
|
|
20
20
|
# Defines url base path
|
21
21
|
attr_accessor :base_path
|
22
22
|
|
23
|
+
# Define server configuration index
|
24
|
+
attr_accessor :server_index
|
25
|
+
|
26
|
+
# Define server operation configuration index
|
27
|
+
attr_accessor :server_operation_index
|
28
|
+
|
29
|
+
# Default server variables
|
30
|
+
attr_accessor :server_variables
|
31
|
+
|
32
|
+
# Default server operation variables
|
33
|
+
attr_accessor :server_operation_variables
|
34
|
+
|
23
35
|
# Defines API keys used with API Key authentications.
|
24
36
|
#
|
25
37
|
# @return [Hash] key: parameter name, value: parameter value (API key)
|
@@ -49,6 +61,16 @@ module CityPayApiClient
|
|
49
61
|
# Defines the access token (Bearer) used with OAuth2.
|
50
62
|
attr_accessor :access_token
|
51
63
|
|
64
|
+
# Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
|
65
|
+
# Overrides the access_token if set
|
66
|
+
# @return [Proc]
|
67
|
+
attr_accessor :access_token_getter
|
68
|
+
|
69
|
+
# Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
|
70
|
+
# HTTP responses with return type `File` will be returned as a stream of binary data.
|
71
|
+
# Default to false.
|
72
|
+
attr_accessor :return_binary_data
|
73
|
+
|
52
74
|
# Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
|
53
75
|
# details will be logged with `logger.debug` (see the `logger` attribute).
|
54
76
|
# Default to false.
|
@@ -120,6 +142,7 @@ module CityPayApiClient
|
|
120
142
|
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
121
143
|
attr_accessor :params_encoding
|
122
144
|
|
145
|
+
|
123
146
|
attr_accessor :inject_format
|
124
147
|
|
125
148
|
attr_accessor :force_ending_format
|
@@ -127,16 +150,20 @@ module CityPayApiClient
|
|
127
150
|
def initialize
|
128
151
|
@scheme = 'https'
|
129
152
|
@host = 'api.citypay.com'
|
130
|
-
@base_path = '
|
153
|
+
@base_path = ''
|
154
|
+
@server_index = nil
|
155
|
+
@server_operation_index = {}
|
156
|
+
@server_variables = {}
|
157
|
+
@server_operation_variables = {}
|
131
158
|
@api_key = {}
|
132
159
|
@api_key_prefix = {}
|
133
|
-
@timeout = 0
|
134
160
|
@client_side_validation = true
|
135
161
|
@verify_ssl = true
|
136
162
|
@verify_ssl_host = true
|
137
|
-
@params_encoding = nil
|
138
163
|
@cert_file = nil
|
139
164
|
@key_file = nil
|
165
|
+
@timeout = 0
|
166
|
+
@params_encoding = nil
|
140
167
|
@debugging = false
|
141
168
|
@inject_format = false
|
142
169
|
@force_ending_format = false
|
@@ -170,20 +197,34 @@ module CityPayApiClient
|
|
170
197
|
@base_path = '' if @base_path == '/'
|
171
198
|
end
|
172
199
|
|
173
|
-
|
174
|
-
|
200
|
+
# Returns base URL for specified operation based on server settings
|
201
|
+
def base_url(operation = nil)
|
202
|
+
if operation_server_settings.key?(operation) then
|
203
|
+
index = server_operation_index.fetch(operation, server_index)
|
204
|
+
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
205
|
+
else
|
206
|
+
server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
|
207
|
+
end
|
175
208
|
end
|
176
209
|
|
177
210
|
# Gets API key (with prefix if set).
|
178
211
|
# @param [String] param_name the parameter name of API key auth
|
179
|
-
def api_key_with_prefix(param_name)
|
212
|
+
def api_key_with_prefix(param_name, param_alias = nil)
|
213
|
+
key = @api_key[param_name]
|
214
|
+
key = @api_key.fetch(param_alias, key) unless param_alias.nil?
|
180
215
|
if @api_key_prefix[param_name]
|
181
|
-
"#{@api_key_prefix[param_name]} #{
|
216
|
+
"#{@api_key_prefix[param_name]} #{key}"
|
182
217
|
else
|
183
|
-
|
218
|
+
key
|
184
219
|
end
|
185
220
|
end
|
186
221
|
|
222
|
+
# Gets access_token using access_token_getter or uses the static access_token
|
223
|
+
def access_token_with_refresh
|
224
|
+
return access_token if access_token_getter.nil?
|
225
|
+
access_token_getter.call
|
226
|
+
end
|
227
|
+
|
187
228
|
# Gets Basic Auth token string
|
188
229
|
def basic_auth_token
|
189
230
|
'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
|
@@ -199,6 +240,13 @@ module CityPayApiClient
|
|
199
240
|
key: 'cp-api-key',
|
200
241
|
value: api_key_with_prefix('cp-api-key')
|
201
242
|
},
|
243
|
+
'cp-domain-key' =>
|
244
|
+
{
|
245
|
+
type: 'api_key',
|
246
|
+
in: 'query',
|
247
|
+
key: 'cp-domain-key',
|
248
|
+
value: api_key_with_prefix('cp-domain-key')
|
249
|
+
},
|
202
250
|
}
|
203
251
|
end
|
204
252
|
|
@@ -206,35 +254,42 @@ module CityPayApiClient
|
|
206
254
|
def server_settings
|
207
255
|
[
|
208
256
|
{
|
209
|
-
url: "https://api.citypay.com
|
257
|
+
url: "https://api.citypay.com",
|
210
258
|
description: "Production processing endpoint",
|
211
259
|
},
|
212
260
|
{
|
213
|
-
url: "https://sandbox.citypay.com
|
261
|
+
url: "https://sandbox.citypay.com",
|
214
262
|
description: "Testing service returning test results for all transactions",
|
215
263
|
}
|
216
264
|
]
|
217
265
|
end
|
218
266
|
|
267
|
+
def operation_server_settings
|
268
|
+
{
|
269
|
+
}
|
270
|
+
end
|
271
|
+
|
219
272
|
# Returns URL based on server settings
|
220
273
|
#
|
221
274
|
# @param index array index of the server settings
|
222
275
|
# @param variables hash of variable and the corresponding value
|
223
|
-
def server_url(index, variables = {})
|
224
|
-
servers = server_settings
|
276
|
+
def server_url(index, variables = {}, servers = nil)
|
277
|
+
servers = server_settings if servers == nil
|
225
278
|
|
226
279
|
# check array index out of bound
|
227
|
-
if (index < 0 || index >= servers.size)
|
228
|
-
fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
|
280
|
+
if (index.nil? || index < 0 || index >= servers.size)
|
281
|
+
fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
|
229
282
|
end
|
230
283
|
|
231
284
|
server = servers[index]
|
232
285
|
url = server[:url]
|
233
286
|
|
287
|
+
return url unless server.key? :variables
|
288
|
+
|
234
289
|
# go through variable and assign a value
|
235
290
|
server[:variables].each do |name, variable|
|
236
291
|
if variables.key?(name)
|
237
|
-
if (server[:variables][name][:enum_values].include?
|
292
|
+
if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
|
238
293
|
url.gsub! "{" + name.to_s + "}", variables[name]
|
239
294
|
else
|
240
295
|
fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
|
@@ -247,5 +302,7 @@ module CityPayApiClient
|
|
247
302
|
|
248
303
|
url
|
249
304
|
end
|
305
|
+
|
306
|
+
|
250
307
|
end
|
251
308
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
=begin
|
2
2
|
#CityPay Payment API
|
3
3
|
|
4
|
-
# This CityPay API is
|
4
|
+
# This CityPay API is an 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 tokenized payments using cardholder Accounts. ## Compliance and Security 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. These include * Data must be collected using TLS version 1.2 using [strong cryptography](https://citypay.github.io/api-docs/payment-api/#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 cardholder 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
5
|
|
6
6
|
Contact: support@citypay.com
|
7
7
|
Generated by: https://openapi-generator.tech
|
8
|
-
OpenAPI Generator version:
|
8
|
+
OpenAPI Generator version: 7.2.0
|
9
9
|
|
10
10
|
=end
|
11
11
|
|
12
12
|
require 'date'
|
13
|
+
require 'time'
|
13
14
|
|
14
15
|
module CityPayApiClient
|
15
16
|
class AccountCreate
|
@@ -26,6 +27,11 @@ module CityPayApiClient
|
|
26
27
|
}
|
27
28
|
end
|
28
29
|
|
30
|
+
# Returns all the JSON keys this model knows about
|
31
|
+
def self.acceptable_attributes
|
32
|
+
attribute_map.values
|
33
|
+
end
|
34
|
+
|
29
35
|
# Attribute type mapping.
|
30
36
|
def self.openapi_types
|
31
37
|
{
|
@@ -57,6 +63,8 @@ module CityPayApiClient
|
|
57
63
|
|
58
64
|
if attributes.key?(:'account_id')
|
59
65
|
self.account_id = attributes[:'account_id']
|
66
|
+
else
|
67
|
+
self.account_id = nil
|
60
68
|
end
|
61
69
|
|
62
70
|
if attributes.key?(:'contact')
|
@@ -67,6 +75,7 @@ module CityPayApiClient
|
|
67
75
|
# Show invalid properties with the reasons. Usually used together with valid?
|
68
76
|
# @return Array for valid properties with the reasons
|
69
77
|
def list_invalid_properties
|
78
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
70
79
|
invalid_properties = Array.new
|
71
80
|
if @account_id.nil?
|
72
81
|
invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
|
@@ -86,6 +95,7 @@ module CityPayApiClient
|
|
86
95
|
# Check to see if the all the properties in the model are valid
|
87
96
|
# @return true if the model is valid
|
88
97
|
def valid?
|
98
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
89
99
|
return false if @account_id.nil?
|
90
100
|
return false if @account_id.to_s.length > 50
|
91
101
|
return false if @account_id.to_s.length < 5
|
@@ -135,37 +145,33 @@ module CityPayApiClient
|
|
135
145
|
# @param [Hash] attributes Model attributes in the form of hash
|
136
146
|
# @return [Object] Returns the model itself
|
137
147
|
def self.build_from_hash(attributes)
|
138
|
-
new.build_from_hash(attributes)
|
139
|
-
end
|
140
|
-
|
141
|
-
# Builds the object from hash
|
142
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
143
|
-
# @return [Object] Returns the model itself
|
144
|
-
def build_from_hash(attributes)
|
145
148
|
return nil unless attributes.is_a?(Hash)
|
146
|
-
|
147
|
-
|
149
|
+
attributes = attributes.transform_keys(&:to_sym)
|
150
|
+
transformed_hash = {}
|
151
|
+
openapi_types.each_pair do |key, type|
|
152
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
153
|
+
transformed_hash["#{key}"] = nil
|
154
|
+
elsif type =~ /\AArray<(.*)>/i
|
148
155
|
# check to ensure the input is an array given that the attribute
|
149
156
|
# is documented as an array but the input is not
|
150
|
-
if attributes[
|
151
|
-
|
157
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
158
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
152
159
|
end
|
153
|
-
elsif !attributes[
|
154
|
-
|
155
|
-
end
|
160
|
+
elsif !attributes[attribute_map[key]].nil?
|
161
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
162
|
+
end
|
156
163
|
end
|
157
|
-
|
158
|
-
self
|
164
|
+
new(transformed_hash)
|
159
165
|
end
|
160
166
|
|
161
167
|
# Deserializes the data based on type
|
162
168
|
# @param string type Data type
|
163
169
|
# @param string value Value to be deserialized
|
164
170
|
# @return [Object] Deserialized data
|
165
|
-
def _deserialize(type, value)
|
171
|
+
def self._deserialize(type, value)
|
166
172
|
case type.to_sym
|
167
|
-
when :
|
168
|
-
|
173
|
+
when :Time
|
174
|
+
Time.parse(value)
|
169
175
|
when :Date
|
170
176
|
Date.parse(value)
|
171
177
|
when :String
|
@@ -195,7 +201,9 @@ module CityPayApiClient
|
|
195
201
|
end
|
196
202
|
end
|
197
203
|
else # model
|
198
|
-
|
204
|
+
# models (e.g. Pet) or oneOf
|
205
|
+
klass = CityPayApiClient.const_get(type)
|
206
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
199
207
|
end
|
200
208
|
end
|
201
209
|
|
@@ -221,7 +229,7 @@ module CityPayApiClient
|
|
221
229
|
is_nullable = self.class.openapi_nullable.include?(attr)
|
222
230
|
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
223
231
|
end
|
224
|
-
|
232
|
+
|
225
233
|
hash[param] = _to_hash(value)
|
226
234
|
end
|
227
235
|
hash
|
@@ -244,5 +252,7 @@ module CityPayApiClient
|
|
244
252
|
value
|
245
253
|
end
|
246
254
|
end
|
255
|
+
|
247
256
|
end
|
257
|
+
|
248
258
|
end
|