diff --git a/README.md b/README.md index 9d14774..d8852b9 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ gem install PCP-server-Ruby-SDK ### General -To use this SDK you need to construct a `CommunicatorConfiguration` which encapsulate everything needed to connect to the PAYONE Commerce Platform. +To use this SDK you need to construct a `PCPServerSDK::CommunicatorConfiguration` which encapsulate everything needed to connect to the PAYONE Commerce Platform. ```rb require 'pcp-server-ruby-sdk' @@ -53,25 +53,25 @@ require 'pcp-server-ruby-sdk' api_key = ENV['API_KEY'] api_secret = ENV['API_SECRET'] -communicator_configuration = CommunicatorConfiguration.new( +communicator_configuration = PCPServerSDK::CommunicatorConfiguration.new( api_key, api_secret, 'https://api.preprod.commerce.payone.com' ) ``` -With the configuration you can create an API client for each reource you want to interact with. For example to create a commerce case you can use the `CommerceCaseApiClient`. +With the configuration you can create an API client for each reource you want to interact with. For example to create a commerce case you can use the `PCPServerSDK::Endpoints::`. ```rb require 'pcp-server-ruby-sdk' -client = CommerceCaseApiClient.new(communicator_configuration) +client = PCPServerSDK::Endpoints::.new(communicator_configuration) ``` -All payloads and reponses are availabe as ruby classes within the `pcp-server-ruby-sdk` package. The serialization and deserialization is handled by the SDK internally. For example, to create an empty commerce case you can pass a `CreateCommerceCaseRequest` instance: +All payloads and reponses are availabe as ruby classes within the `pcp-server-ruby-sdk` package. The serialization and deserialization is handled by the SDK internally. For example, to create an empty commerce case you can pass a `PCPServerSDK::Models::CreateCommerceCaseRequest` instance: ```rb -createCommerceCaseRequest = CreateCommerceCaseRequest.new +createCommerceCaseRequest = PCPServerSDK::Models::CreateCommerceCaseRequest.new createCommerceCaseResponse = client.create_commerce_case_request('merchant_id', createCommerceCaseRequest); ``` @@ -79,10 +79,10 @@ The models directly map to the API as described in [PAYONE Commerce Platform API ### Error Handling -When making a request any client may throw a `ApiException`. There two subtypes of this exception: +When making a request any client may throw a `PCPServerSDK::Errors::ApiException`. There two subtypes of this exception: -- `ApiErrorReponseException`: This exception is thrown when the API returns an well-formed error response. The given errors are deserialized into `APIError` objects which are availble via the `get_errors` method on the exception. They usually contain useful information about what is wrong in your request or the state of the resource. -- `ApiResponseRetrievalException`: This exception is a catch-all exception for any error that cannot be turned into a helpful error response. This includes malformed responses or unknown responses. +- `PCPServerSDK::Errors::ApiErrorReponseException`: This exception is thrown when the API returns an well-formed error response. The given errors are deserialized into `PCPServerSDK::Models::APIError` objects which are availble via the `get_errors` method on the exception. They usually contain useful information about what is wrong in your request or the state of the resource. +- `PCPServerSDK::Errors::ApiResponseRetrievalException`: This exception is a catch-all exception for any error that cannot be turned into a helpful error response. This includes malformed responses or unknown responses. Network errors are not wrap, you can should handle the standard `IOExeption`. diff --git a/lib/PCP-server-Ruby-SDK/communicator_configuration.rb b/lib/PCP-server-Ruby-SDK/communicator_configuration.rb index 20578a1..e1ca2ab 100644 --- a/lib/PCP-server-Ruby-SDK/communicator_configuration.rb +++ b/lib/PCP-server-Ruby-SDK/communicator_configuration.rb @@ -3,6 +3,10 @@ module PCPServerSDK class CommunicatorConfiguration attr_reader :api_key, :api_secret, :host + # The constructor + # @param [String] api_key + # @param [String] api_secret + # @param [String] host def initialize(api_key, api_secret, host) @api_key = api_key @api_secret = api_secret diff --git a/lib/PCP-server-Ruby-SDK/endpoints/base_api_client.rb b/lib/PCP-server-Ruby-SDK/endpoints/base_api_client.rb index 84c62c3..a35a8ce 100644 --- a/lib/PCP-server-Ruby-SDK/endpoints/base_api_client.rb +++ b/lib/PCP-server-Ruby-SDK/endpoints/base_api_client.rb @@ -31,14 +31,17 @@ def get_config @config end + # Make an API call + # @param [String] url + # @param [Hash] request_init def make_api_call(url, request_init) uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = uri.scheme == 'https' - headers = @request_header_generator.generate_additional_request_headers(url, request_init || {}) + modified_request = @request_header_generator.generate_additional_request_headers(url, request_init || {}) - request = build_http_request(uri, request_init, headers) + request = build_http_request(uri, modified_request) response = http.request(request) body = response.body @@ -46,14 +49,19 @@ def make_api_call(url, request_init) begin parsed = JSON.parse(body) rescue StandardError => e - raise ApiResponseRetrievalException.new(response.code.to_i, parsed, e) + raise PCPServerSDK::Errors::ApiResponseRetrievalException.new(response.code.to_i, parsed, e) end unless response.is_a?(Net::HTTPSuccess) if is_error_response(body) - raise ApiErrorResponseException.new(response.code.to_i, body, parsed['errors'] || []) + begin + parsedError = deserialize_json(parsed, PCPServerSDK::Models::ErrorResponse) + raise PCPServerSDK::Errors::ApiErrorResponseException.new(response.code.to_i, body, parsedError.errors) + rescue StandardError => e + raise PCPServerSDK::Errors::ApiResponseRetrievalException.new(response.code.to_i, parsed, e) + end else - raise ApiResponseRetrievalException.new(response.code.to_i, body) + raise PCPServerSDK::Errors::ApiResponseRetrievalException.new(response.code.to_i, body) end end @@ -67,7 +75,7 @@ def deserialize_json(json, klass) private - def build_http_request(uri, request_init, headers) + def build_http_request(uri, request_init) method = request_init[:method].to_s.upcase case method @@ -85,7 +93,7 @@ def build_http_request(uri, request_init, headers) raise ArgumentError, "Unsupported HTTP method: #{method}" end - headers[:headers].each do |key, value| + request_init[:headers].each do |key, value| req[key] = value end diff --git a/lib/PCP-server-Ruby-SDK/endpoints/checkout_api_client.rb b/lib/PCP-server-Ruby-SDK/endpoints/checkout_api_client.rb index 92eedab..7196d15 100644 --- a/lib/PCP-server-Ruby-SDK/endpoints/checkout_api_client.rb +++ b/lib/PCP-server-Ruby-SDK/endpoints/checkout_api_client.rb @@ -18,8 +18,8 @@ def initialize(config) # Create a checkout # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier - # @param payload [CreateCheckoutRequest] The checkout request - # @return [CreateCheckoutResponse] The checkout response + # @param payload [PCPServerSDK::Models::CreateCheckoutRequest] The checkout request + # @return [PCPServerSDK::Models::CreateCheckoutResponse] The checkout response def create_checkout_request(merchant_id, commerce_case_id, payload) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? raise TypeError, COMMERCE_CASE_ID_REQUIRED_ERROR if commerce_case_id.nil? || commerce_case_id.empty? @@ -33,14 +33,14 @@ def create_checkout_request(merchant_id, commerce_case_id, payload) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CreateCheckoutResponse) + deserialize_json(response, PCPServerSDK::Models::CreateCheckoutResponse) end # Get a checkout # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @return [CheckoutResponse] The checkout response + # @return [PCPServerSDK::Models::CheckoutResponse] The checkout response def get_checkout_request(merchant_id, commerce_case_id, checkout_id) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? raise TypeError, COMMERCE_CASE_ID_REQUIRED_ERROR if commerce_case_id.nil? || commerce_case_id.empty? @@ -54,13 +54,13 @@ def get_checkout_request(merchant_id, commerce_case_id, checkout_id) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CheckoutResponse) + deserialize_json(response, PCPServerSDK::Models::CheckoutResponse) end # Get checkouts # @param merchant_id [String] The merchant identifier - # @param query_params [GetCheckoutsQuery] The query parameters - # @return [CheckoutsResponse] The checkouts response + # @param query_params [PCPServerSDK::Models::GetCheckoutsQuery] The query parameters + # @return [PCPServerSDK::Models::CheckoutsResponse] The checkouts response def get_checkouts_request(merchant_id, query_params = nil) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? @@ -76,14 +76,14 @@ def get_checkouts_request(merchant_id, query_params = nil) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CheckoutsResponse) + deserialize_json(response, PCPServerSDK::Models::CheckoutsResponse) end # Update a checkout # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @param payload [UpdateCheckoutRequest] The checkout request + # @param payload [PCPServerSDK::Models::UpdateCheckoutRequest] The checkout request # @return [nil] def update_checkout_request(merchant_id, commerce_case_id, checkout_id, payload) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? diff --git a/lib/PCP-server-Ruby-SDK/endpoints/commerce_case_api_client.rb b/lib/PCP-server-Ruby-SDK/endpoints/commerce_case_api_client.rb index ee60c0a..55f54b1 100644 --- a/lib/PCP-server-Ruby-SDK/endpoints/commerce_case_api_client.rb +++ b/lib/PCP-server-Ruby-SDK/endpoints/commerce_case_api_client.rb @@ -16,8 +16,8 @@ def initialize(config) # Create a commerce case # @param merchant_id [String] The merchant identifier - # @param payload [CreateCommerceCaseRequest] The commerce case request - # @return [CreateCommerceCaseResponse] The commerce case response + # @param payload [PCPServerSDK::Models::CreateCommerceCaseRequest] The commerce case request + # @return [PCPServerSDK::Models::CreateCommerceCaseResponse] The commerce case response def create_commerce_case_request(merchant_id, payload) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? @@ -30,13 +30,13 @@ def create_commerce_case_request(merchant_id, payload) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CreateCommerceCaseResponse) + deserialize_json(response, PCPServerSDK::Models::CreateCommerceCaseResponse) end # Get a commerce case # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier - # @return [CommerceCaseResponse] The commerce case response + # @return [PCPServerSDK::Models::CommerceCaseResponse] The commerce case response def get_commerce_case_request(merchant_id, commerce_case_id) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? raise TypeError, COMMERCE_CASE_ID_REQUIRED_ERROR if commerce_case_id.nil? || commerce_case_id.empty? @@ -49,13 +49,13 @@ def get_commerce_case_request(merchant_id, commerce_case_id) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CommerceCaseResponse) + deserialize_json(response, PCPServerSDK::Models::CommerceCaseResponse) end # Get commerce cases # @param merchant_id [String] The merchant identifier - # @param query_params [GetCommerceCasesQuery] The query parameters - # @return [Array] The commerce cases + # @param query_params [PCPServerSDK::Models::GetCommerceCasesQuery] The query parameters + # @return [Array] The commerce cases def get_commerce_cases_request(merchant_id, query_params = nil) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? @@ -71,13 +71,13 @@ def get_commerce_cases_request(merchant_id, query_params = nil) } request = make_api_call(url.to_s, request_init) - request.map { |r| deserialize_json(r, CommerceCaseResponse) } + request.map { |r| deserialize_json(r, PCPServerSDK::Models::CommerceCaseResponse) } end # Update a commerce case # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier - # @param customer [Customer] The customer + # @param customer [PCPServerSDK::Models::Customer] The customer # @return [nil] def update_commerce_case_request(merchant_id, commerce_case_id, customer) raise TypeError, MERCHANT_ID_REQUIRED_ERROR if merchant_id.nil? || merchant_id.empty? diff --git a/lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb b/lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb index 6a73a46..b98d053 100644 --- a/lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb +++ b/lib/PCP-server-Ruby-SDK/endpoints/order_management_checkout_actions_api_client.rb @@ -18,8 +18,8 @@ def initialize(config) # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @param payload [OrderRequest] The order request - # @return [OrderResponse] The order response + # @param payload [PCPServerSDK::Models::OrderRequest] The order request + # @return [PCPServerSDK::Models::OrderResponse] The order response def create_order(merchant_id, commerce_case_id, checkout_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) @@ -32,15 +32,15 @@ def create_order(merchant_id, commerce_case_id, checkout_id, payload) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, OrderResponse) + deserialize_json(response, PCPServerSDK::Models::OrderResponse) end # Deliver an order # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @param payload [DeliverRequest] The deliver request - # @return [DeliverResponse] The deliver response + # @param payload [PCPServerSDK::Models::DeliverRequest] The deliver request + # @return [PCPServerSDK::Models::DeliverResponse] The deliver response def deliver_order(merchant_id, commerce_case_id, checkout_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) @@ -53,15 +53,15 @@ def deliver_order(merchant_id, commerce_case_id, checkout_id, payload) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, DeliverResponse) + deserialize_json(response, PCPServerSDK::Models::DeliverResponse) end # Return an order # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @param payload [ReturnRequest] The return request - # @return [ReturnResponse] The return response + # @param payload [PCPServerSDK::Models::ReturnRequest] The return request + # @return [PCPServerSDK::Models::ReturnResponse] The return response def return_order(merchant_id, commerce_case_id, checkout_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) @@ -74,15 +74,15 @@ def return_order(merchant_id, commerce_case_id, checkout_id, payload) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, ReturnResponse) + deserialize_json(response, PCPServerSDK::Models::ReturnResponse) end # Cancel an order # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @param payload [CancelRequest] The cancel request - # @return [CancelResponse] The cancel response + # @param payload [PCPServerSDK::Models::CancelRequest] The cancel request + # @return [PCPServerSDK::Models::CancelResponse] The cancel response def cancel_order(merchant_id, commerce_case_id, checkout_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) @@ -95,7 +95,7 @@ def cancel_order(merchant_id, commerce_case_id, checkout_id, payload) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CancelResponse) + deserialize_json(response, PCPServerSDK::Models::CancelResponse) end private diff --git a/lib/PCP-server-Ruby-SDK/endpoints/payment_execution_api_client.rb b/lib/PCP-server-Ruby-SDK/endpoints/payment_execution_api_client.rb index ecb1f69..619657a 100644 --- a/lib/PCP-server-Ruby-SDK/endpoints/payment_execution_api_client.rb +++ b/lib/PCP-server-Ruby-SDK/endpoints/payment_execution_api_client.rb @@ -21,8 +21,8 @@ def initialize(config) # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @param payload [PaymentExecutionRequest] The payment execution request - # @return [CreatePaymentResponse] The create payment response + # @param payload [PCPServerSDK::Models::PaymentExecutionRequest] The payment execution request + # @return [PCPServerSDK::Models::CreatePaymentResponse] The create payment response def create_payment(merchant_id, commerce_case_id, checkout_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) @@ -35,7 +35,7 @@ def create_payment(merchant_id, commerce_case_id, checkout_id, payload) } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CreatePaymentResponse) + deserialize_json(response, PCPServerSDK::Models::CreatePaymentResponse) end # Capture a payment @@ -43,8 +43,8 @@ def create_payment(merchant_id, commerce_case_id, checkout_id, payload) # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier # @param payment_execution_id [String] The payment execution identifier - # @param payload [CapturePaymentRequest] The capture payment request - # @return [CapturePaymentResponse] The capture payment response + # @param payload [PCPServerSDK::Models::CapturePaymentRequest] The capture payment request + # @return [PCPServerSDK::Models::CapturePaymentResponse] The capture payment response def capture_payment(merchant_id, commerce_case_id, checkout_id, payment_execution_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) raise TypeError, PAYMENT_EXECUTION_ID_REQUIRED_ERROR if payment_execution_id.nil? || payment_execution_id.empty? @@ -58,7 +58,7 @@ def capture_payment(merchant_id, commerce_case_id, checkout_id, payment_executio } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CapturePaymentResponse) + deserialize_json(response, PCPServerSDK::Models::CapturePaymentResponse) end # Cancel a payment @@ -66,8 +66,8 @@ def capture_payment(merchant_id, commerce_case_id, checkout_id, payment_executio # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier # @param payment_execution_id [String] The payment execution identifier - # @param payload [CancelPaymentRequest] The cancel payment request - # @return [CancelPaymentResponse] The cancel payment response + # @param payload [PCPServerSDK::Models::CancelPaymentRequest] The cancel payment request + # @return [PCPServerSDK::Models::CancelPaymentResponse] The cancel payment response def cancel_payment(merchant_id, commerce_case_id, checkout_id, payment_execution_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) raise TypeError, PAYMENT_EXECUTION_ID_REQUIRED_ERROR if payment_execution_id.nil? || payment_execution_id.empty? @@ -81,7 +81,7 @@ def cancel_payment(merchant_id, commerce_case_id, checkout_id, payment_execution } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CancelPaymentResponse) + deserialize_json(response, PCPServerSDK::Models::CancelPaymentResponse) end # Refund a payment @@ -89,8 +89,8 @@ def cancel_payment(merchant_id, commerce_case_id, checkout_id, payment_execution # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier # @param payment_execution_id [String] The payment execution identifier - # @param payload [RefundRequest] The refund request - # @return [RefundPaymentResponse] The refund payment response + # @param payload [PCPServerSDK::Models::RefundRequest] The refund request + # @return [PCPServerSDK::Models::RefundPaymentResponse] The refund payment response def refund_payment(merchant_id, commerce_case_id, checkout_id, payment_execution_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) raise TypeError, PAYMENT_EXECUTION_ID_REQUIRED_ERROR if payment_execution_id.nil? || payment_execution_id.empty? @@ -104,7 +104,7 @@ def refund_payment(merchant_id, commerce_case_id, checkout_id, payment_execution } response = make_api_call(url.to_s, request_init) - deserialize_json(response, RefundPaymentResponse) + deserialize_json(response, PCPServerSDK::Models::RefundPaymentResponse) end # Complete a payment @@ -112,8 +112,8 @@ def refund_payment(merchant_id, commerce_case_id, checkout_id, payment_execution # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier # @param payment_execution_id [String] The payment execution identifier - # @param payload [CompletePaymentRequest] The complete payment request - # @return [CompletePaymentResponse] The complete payment response + # @param payload [PCPServerSDK::Models::CompletePaymentRequest] The complete payment request + # @return [PCPServerSDK::Models::CompletePaymentResponse] The complete payment response def complete_payment(merchant_id, commerce_case_id, checkout_id, payment_execution_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) raise TypeError, PAYMENT_EXECUTION_ID_REQUIRED_ERROR if payment_execution_id.nil? || payment_execution_id.empty? @@ -127,7 +127,7 @@ def complete_payment(merchant_id, commerce_case_id, checkout_id, payment_executi } response = make_api_call(url.to_s, request_init) - deserialize_json(response, CompletePaymentResponse) + deserialize_json(response, PCPServerSDK::Models::CompletePaymentResponse) end private diff --git a/lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb b/lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb index fca8272..fcc23d2 100644 --- a/lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb +++ b/lib/PCP-server-Ruby-SDK/endpoints/payment_information_api_client.rb @@ -19,8 +19,8 @@ def initialize(config) # @param merchant_id [String] The merchant identifier # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier - # @param payload [PaymentInformationRequest] The payment information request - # @return [PaymentInformationResponse] The payment information response + # @param payload [PCPServerSDK::Models::PaymentInformationRequest] The payment information request + # @return [PCPServerSDK::Models::PaymentInformationResponse] The payment information response def create_payment_information(merchant_id, commerce_case_id, checkout_id, payload) validate_ids(merchant_id, commerce_case_id, checkout_id) @@ -33,7 +33,7 @@ def create_payment_information(merchant_id, commerce_case_id, checkout_id, paylo } response = make_api_call(url.to_s, request_init) - deserialize_json(response, PaymentInformationResponse) + deserialize_json(response, PCPServerSDK::Models::PaymentInformationResponse) end # Get a payment information @@ -41,7 +41,7 @@ def create_payment_information(merchant_id, commerce_case_id, checkout_id, paylo # @param commerce_case_id [String] The commerce case identifier # @param checkout_id [String] The checkout identifier # @param payment_information_id [String] The payment information identifier - # @return [PaymentInformationResponse] The payment information response + # @return [PCPServerSDK::Models::PaymentInformationResponse] The payment information response def get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_information_id) validate_ids(merchant_id, commerce_case_id, checkout_id) raise TypeError, PAYMENT_INFORMATION_ID_REQUIRED_ERROR if payment_information_id.nil? || payment_information_id.empty? @@ -54,7 +54,7 @@ def get_payment_information(merchant_id, commerce_case_id, checkout_id, payment_ } response = make_api_call(url.to_s, request_init) - deserialize_json(response, PaymentInformationResponse) + deserialize_json(response, PCPServerSDK::Models::PaymentInformationResponse) end private diff --git a/lib/PCP-server-Ruby-SDK/errors/api_error_response_exception.rb b/lib/PCP-server-Ruby-SDK/errors/api_error_response_exception.rb index bb20a76..8876ade 100644 --- a/lib/PCP-server-Ruby-SDK/errors/api_error_response_exception.rb +++ b/lib/PCP-server-Ruby-SDK/errors/api_error_response_exception.rb @@ -5,8 +5,14 @@ module PCPServerSDK module Errors class ApiErrorResponseException < ApiException + # The errors + # @return [Array] attr_reader :errors + # The constructor + # @param [Integer] status_code + # @param [String] response_body + # @param [Array] errors def initialize(status_code, response_body, errors = []) super(status_code, response_body) @errors = errors.any? ? errors : [] diff --git a/lib/PCP-server-Ruby-SDK/errors/api_exception.rb b/lib/PCP-server-Ruby-SDK/errors/api_exception.rb index 570e54c..d74f3fb 100644 --- a/lib/PCP-server-Ruby-SDK/errors/api_exception.rb +++ b/lib/PCP-server-Ruby-SDK/errors/api_exception.rb @@ -5,6 +5,10 @@ module Errors class ApiException < StandardError attr_reader :status_code, :response_body + # The constructor + # @param [Integer] status_code + # @param [String] response_body + # @param [StandardError] cause def initialize(status_code, response_body, cause = nil) super(response_body) @status_code = status_code diff --git a/lib/PCP-server-Ruby-SDK/errors/api_response_retrieval_exception.rb b/lib/PCP-server-Ruby-SDK/errors/api_response_retrieval_exception.rb index adc1d00..3d31d43 100644 --- a/lib/PCP-server-Ruby-SDK/errors/api_response_retrieval_exception.rb +++ b/lib/PCP-server-Ruby-SDK/errors/api_response_retrieval_exception.rb @@ -3,6 +3,10 @@ module PCPServerSDK module Errors class ApiResponseRetrievalException < ApiException + # The constructor + # @param [Integer] status_code + # @param [String] response_body + # @param [StandardError] cause def initialize(status_code, response_body, cause = nil) super(status_code, response_body, cause) end diff --git a/lib/PCP-server-Ruby-SDK/models/address.rb b/lib/PCP-server-Ruby-SDK/models/address.rb index b76eb49..fc75626 100644 --- a/lib/PCP-server-Ruby-SDK/models/address.rb +++ b/lib/PCP-server-Ruby-SDK/models/address.rb @@ -3,244 +3,248 @@ require 'time' # Object containing billing address details -class Address - # Second line of street or additional address information such as apartments and suits - attr_accessor :additional_info - - # City - attr_accessor :city - - # ISO 3166-1 alpha-2 country code - attr_accessor :country_code - - # House number - attr_accessor :house_number - - # State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. - attr_accessor :state - - # Street name - attr_accessor :street - - # Zip code - attr_accessor :zip - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'additional_info' => :'additionalInfo', - :'city' => :'city', - :'country_code' => :'countryCode', - :'house_number' => :'houseNumber', - :'state' => :'state', - :'street' => :'street', - :'zip' => :'zip' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'additional_info' => :'String', - :'city' => :'String', - :'country_code' => :'String', - :'house_number' => :'String', - :'state' => :'String', - :'street' => :'String', - :'zip' => :'String' - } - end +module PCPServerSDK + module Models + class Address + # Second line of street or additional address information such as apartments and suits + attr_accessor :additional_info + + # City + attr_accessor :city + + # ISO 3166-1 alpha-2 country code + attr_accessor :country_code + + # House number + attr_accessor :house_number + + # State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. + attr_accessor :state + + # Street name + attr_accessor :street + + # Zip code + attr_accessor :zip + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'additional_info' => :'additionalInfo', + :'city' => :'city', + :'country_code' => :'countryCode', + :'house_number' => :'houseNumber', + :'state' => :'state', + :'street' => :'street', + :'zip' => :'zip' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Address` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'additional_info' => :'String', + :'city' => :'String', + :'country_code' => :'String', + :'house_number' => :'String', + :'state' => :'String', + :'street' => :'String', + :'zip' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Address`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'additional_info') - self.additional_info = attributes[:'additional_info'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Address` initialize method" + end - if attributes.key?(:'city') - self.city = attributes[:'city'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Address`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'country_code') - self.country_code = attributes[:'country_code'] - end + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end - if attributes.key?(:'house_number') - self.house_number = attributes[:'house_number'] - end + if attributes.key?(:'city') + self.city = attributes[:'city'] + end - if attributes.key?(:'state') - self.state = attributes[:'state'] - end + if attributes.key?(:'country_code') + self.country_code = attributes[:'country_code'] + end - if attributes.key?(:'street') - self.street = attributes[:'street'] - end + if attributes.key?(:'house_number') + self.house_number = attributes[:'house_number'] + end - if attributes.key?(:'zip') - self.zip = attributes[:'zip'] - end - end + if attributes.key?(:'state') + self.state = attributes[:'state'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - additional_info == o.additional_info && - city == o.city && - country_code == o.country_code && - house_number == o.house_number && - state == o.state && - street == o.street && - zip == o.zip - end + if attributes.key?(:'street') + self.street = attributes[:'street'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'zip') + self.zip = attributes[:'zip'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [additional_info, city, country_code, house_number, state, street, zip].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + additional_info == o.additional_info && + city == o.city && + country_code == o.country_code && + house_number == o.house_number && + state == o.state && + street == o.street && + zip == o.zip + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [additional_info, city, country_code, house_number, state, street, zip].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/address_personal.rb b/lib/PCP-server-Ruby-SDK/models/address_personal.rb index ace30b3..d32289d 100644 --- a/lib/PCP-server-Ruby-SDK/models/address_personal.rb +++ b/lib/PCP-server-Ruby-SDK/models/address_personal.rb @@ -3,253 +3,257 @@ require 'time' # Object containing personal or shipping address information. -class AddressPersonal - # Second line of street or additional address information such as apartments and suits - attr_accessor :additional_info - - # City - attr_accessor :city - - # ISO 3166-1 alpha-2 country code - attr_accessor :country_code - - # House number - attr_accessor :house_number - - # State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. - attr_accessor :state - - # Street name - attr_accessor :street - - # Zip code - attr_accessor :zip - - attr_accessor :name - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'additional_info' => :'additionalInfo', - :'city' => :'city', - :'country_code' => :'countryCode', - :'house_number' => :'houseNumber', - :'state' => :'state', - :'street' => :'street', - :'zip' => :'zip', - :'name' => :'name' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'additional_info' => :'String', - :'city' => :'String', - :'country_code' => :'String', - :'house_number' => :'String', - :'state' => :'String', - :'street' => :'String', - :'zip' => :'String', - :'name' => :'PersonalName' - } - end +module PCPServerSDK + module Models + class AddressPersonal + # Second line of street or additional address information such as apartments and suits + attr_accessor :additional_info + + # City + attr_accessor :city + + # ISO 3166-1 alpha-2 country code + attr_accessor :country_code + + # House number + attr_accessor :house_number + + # State (ISO 3166-2 subdivisions), only if country=US, CA, CN, JP, MX, BR, AR, ID, TH, IN. + attr_accessor :state + + # Street name + attr_accessor :street + + # Zip code + attr_accessor :zip + + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'additional_info' => :'additionalInfo', + :'city' => :'city', + :'country_code' => :'countryCode', + :'house_number' => :'houseNumber', + :'state' => :'state', + :'street' => :'street', + :'zip' => :'zip', + :'name' => :'name' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `AddressPersonal` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'additional_info' => :'String', + :'city' => :'String', + :'country_code' => :'String', + :'house_number' => :'String', + :'state' => :'String', + :'street' => :'String', + :'zip' => :'String', + :'name' => :'PersonalName' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `AddressPersonal`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'additional_info') - self.additional_info = attributes[:'additional_info'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `AddressPersonal` initialize method" + end - if attributes.key?(:'city') - self.city = attributes[:'city'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `AddressPersonal`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'country_code') - self.country_code = attributes[:'country_code'] - end + if attributes.key?(:'additional_info') + self.additional_info = attributes[:'additional_info'] + end - if attributes.key?(:'house_number') - self.house_number = attributes[:'house_number'] - end + if attributes.key?(:'city') + self.city = attributes[:'city'] + end - if attributes.key?(:'state') - self.state = attributes[:'state'] - end + if attributes.key?(:'country_code') + self.country_code = attributes[:'country_code'] + end - if attributes.key?(:'street') - self.street = attributes[:'street'] - end + if attributes.key?(:'house_number') + self.house_number = attributes[:'house_number'] + end - if attributes.key?(:'zip') - self.zip = attributes[:'zip'] - end + if attributes.key?(:'state') + self.state = attributes[:'state'] + end - if attributes.key?(:'name') - self.name = attributes[:'name'] - end - end + if attributes.key?(:'street') + self.street = attributes[:'street'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - additional_info == o.additional_info && - city == o.city && - country_code == o.country_code && - house_number == o.house_number && - state == o.state && - street == o.street && - zip == o.zip && - name == o.name - end + if attributes.key?(:'zip') + self.zip = attributes[:'zip'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [additional_info, city, country_code, house_number, state, street, zip, name].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + additional_info == o.additional_info && + city == o.city && + country_code == o.country_code && + house_number == o.house_number && + state == o.state && + street == o.street && + zip == o.zip && + name == o.name + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [additional_info, city, country_code, house_number, state, street, zip, name].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/allowed_payment_actions.rb b/lib/PCP-server-Ruby-SDK/models/allowed_payment_actions.rb index 9da2ded..14cfc82 100644 --- a/lib/PCP-server-Ruby-SDK/models/allowed_payment_actions.rb +++ b/lib/PCP-server-Ruby-SDK/models/allowed_payment_actions.rb @@ -1,27 +1,30 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class AllowedPaymentActions + ORDER_MANAGEMENT = "ORDER_MANAGEMENT".freeze + PAYMENT_EXECUTION = "PAYMENT_EXECUTION".freeze -class AllowedPaymentActions - ORDER_MANAGEMENT = "ORDER_MANAGEMENT".freeze - PAYMENT_EXECUTION = "PAYMENT_EXECUTION".freeze + def self.all_vars + @all_vars ||= [ORDER_MANAGEMENT, PAYMENT_EXECUTION].freeze + end - def self.all_vars - @all_vars ||= [ORDER_MANAGEMENT, PAYMENT_EXECUTION].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if AllowedPaymentActions.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #AllowedPaymentActions" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if AllowedPaymentActions.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #AllowedPaymentActions" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/amount_of_money.rb b/lib/PCP-server-Ruby-SDK/models/amount_of_money.rb index 9f185a8..2866472 100644 --- a/lib/PCP-server-Ruby-SDK/models/amount_of_money.rb +++ b/lib/PCP-server-Ruby-SDK/models/amount_of_money.rb @@ -1,200 +1,203 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing amount and ISO currency code attributes + class AmountOfMoney + # Amount in cents and always having 2 decimals + attr_accessor :amount + + # Three-letter ISO currency code representing the currency for the amount + attr_accessor :currency_code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'currency_code' => :'currencyCode' + } + end -# Object containing amount and ISO currency code attributes -class AmountOfMoney - # Amount in cents and always having 2 decimals - attr_accessor :amount - - # Three-letter ISO currency code representing the currency for the amount - attr_accessor :currency_code - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount' => :'amount', - :'currency_code' => :'currencyCode' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Integer', + :'currency_code' => :'String' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'amount' => :'Integer', - :'currency_code' => :'String' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `AmountOfMoney` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `AmountOfMoney` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `AmountOfMoney`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `AmountOfMoney`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'currency_code') + self.currency_code = attributes[:'currency_code'] + else + self.currency_code = nil + end + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + currency_code == o.currency_code end - h[k.to_sym] = v - } - - if attributes.key?(:'amount') - self.amount = attributes[:'amount'] - else - self.amount = nil - end - - if attributes.key?(:'currency_code') - self.currency_code = attributes[:'currency_code'] - else - self.currency_code = nil - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount == o.amount && - currency_code == o.currency_code - end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount, currency_code].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, currency_code].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/api_error.rb b/lib/PCP-server-Ruby-SDK/models/api_error.rb index 33ce6fc..3b59696 100644 --- a/lib/PCP-server-Ruby-SDK/models/api_error.rb +++ b/lib/PCP-server-Ruby-SDK/models/api_error.rb @@ -1,238 +1,241 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Contains detailed information on one single error. + class APIError + # Error code + attr_accessor :error_code + + # Category the error belongs to. The category should give an indication of the type of error you are dealing with. Possible values: * DIRECT_PLATFORM_ERROR - indicating that a functional error has occurred in the platform. * PAYMENT_PLATFORM_ERROR - indicating that a functional error has occurred in the payment platform. * IO_ERROR - indicating that a technical error has occurred within the payment platform or between the payment platform and third party systems. * COMMERCE_PLATFORM_ERROR - indicating an error originating from the Commerce Platform. * COMMERCE_PORTAL_BACKEND_ERROR - indicating an error originating from the Commerce Portal Backend. + attr_accessor :category + + # HTTP status code for this error that can be used to determine the type of error + attr_accessor :http_status_code + + # ID of the error. This is a short human-readable message that briefly describes the error. + attr_accessor :id + + # Human-readable error message that is not meant to be relayed to customer as it might tip off people who are trying to commit fraud + attr_accessor :message + + # Returned only if the error relates to a value that was missing or incorrect. Contains a location path to the value as a JSonata query. Some common examples: * a.b selects the value of property b of root property a, * a[1] selects the first element of the array in root property a, * a[b='some value'] selects all elements of the array in root property a that have a property b with value 'some value'. + attr_accessor :property_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'error_code' => :'errorCode', + :'category' => :'category', + :'http_status_code' => :'httpStatusCode', + :'id' => :'id', + :'message' => :'message', + :'property_name' => :'propertyName' + } + end -# Contains detailed information on one single error. -class APIError - # Error code - attr_accessor :error_code - - # Category the error belongs to. The category should give an indication of the type of error you are dealing with. Possible values: * DIRECT_PLATFORM_ERROR - indicating that a functional error has occurred in the platform. * PAYMENT_PLATFORM_ERROR - indicating that a functional error has occurred in the payment platform. * IO_ERROR - indicating that a technical error has occurred within the payment platform or between the payment platform and third party systems. * COMMERCE_PLATFORM_ERROR - indicating an error originating from the Commerce Platform. * COMMERCE_PORTAL_BACKEND_ERROR - indicating an error originating from the Commerce Portal Backend. - attr_accessor :category - - # HTTP status code for this error that can be used to determine the type of error - attr_accessor :http_status_code + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # ID of the error. This is a short human-readable message that briefly describes the error. - attr_accessor :id + # Attribute type mapping. + def self.openapi_types + { + :'error_code' => :'String', + :'category' => :'String', + :'http_status_code' => :'Integer', + :'id' => :'String', + :'message' => :'String', + :'property_name' => :'String' + } + end - # Human-readable error message that is not meant to be relayed to customer as it might tip off people who are trying to commit fraud - attr_accessor :message + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returned only if the error relates to a value that was missing or incorrect. Contains a location path to the value as a JSonata query. Some common examples: * a.b selects the value of property b of root property a, * a[1] selects the first element of the array in root property a, * a[b='some value'] selects all elements of the array in root property a that have a property b with value 'some value'. - attr_accessor :property_name + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `APIError` initialize method" + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'error_code' => :'errorCode', - :'category' => :'category', - :'http_status_code' => :'httpStatusCode', - :'id' => :'id', - :'message' => :'message', - :'property_name' => :'propertyName' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `APIError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'error_code') + self.error_code = attributes[:'error_code'] + else + self.error_code = nil + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + if attributes.key?(:'category') + self.category = attributes[:'category'] + end - # Attribute type mapping. - def self.openapi_types - { - :'error_code' => :'String', - :'category' => :'String', - :'http_status_code' => :'Integer', - :'id' => :'String', - :'message' => :'String', - :'property_name' => :'String' - } - end + if attributes.key?(:'http_status_code') + self.http_status_code = attributes[:'http_status_code'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'id') + self.id = attributes[:'id'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `APIError` initialize method" - end + if attributes.key?(:'message') + self.message = attributes[:'message'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `APIError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'property_name') + self.property_name = attributes[:'property_name'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'error_code') - self.error_code = attributes[:'error_code'] - else - self.error_code = nil - end - - if attributes.key?(:'category') - self.category = attributes[:'category'] - end - - if attributes.key?(:'http_status_code') - self.http_status_code = attributes[:'http_status_code'] - end - - if attributes.key?(:'id') - self.id = attributes[:'id'] - end - if attributes.key?(:'message') - self.message = attributes[:'message'] - end - - if attributes.key?(:'property_name') - self.property_name = attributes[:'property_name'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - error_code == o.error_code && - category == o.category && - http_status_code == o.http_status_code && - id == o.id && - message == o.message && - property_name == o.property_name - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + error_code == o.error_code && + category == o.category && + http_status_code == o.http_status_code && + id == o.id && + message == o.message && + property_name == o.property_name + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [error_code, category, http_status_code, id, message, property_name].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [error_code, category, http_status_code, id, message, property_name].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_header_information.rb b/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_header_information.rb index 57dafe5..6fd1307 100644 --- a/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_header_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_header_information.rb @@ -1,196 +1,199 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Additional information about the Apple payment data token header. + class ApplePaymentDataTokenHeaderInformation + # A hexadecimal Transaction identifier identifier as a string. + attr_accessor :transaction_id + + # SHA–256 hash, hex encoded as a string. Hash of the applicationData property of the original PKPaymentRequest object. + attr_accessor :application_data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'transaction_id' => :'transactionId', + :'application_data' => :'applicationData' + } + end -# Additional information about the Apple payment data token header. -class ApplePaymentDataTokenHeaderInformation - # A hexadecimal Transaction identifier identifier as a string. - attr_accessor :transaction_id - - # SHA–256 hash, hex encoded as a string. Hash of the applicationData property of the original PKPaymentRequest object. - attr_accessor :application_data + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'transaction_id' => :'transactionId', - :'application_data' => :'applicationData' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'transaction_id' => :'String', + :'application_data' => :'String' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'transaction_id' => :'String', - :'application_data' => :'String' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ApplePaymentDataTokenHeaderInformation` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ApplePaymentDataTokenHeaderInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ApplePaymentDataTokenHeaderInformation` initialize method" - end + if attributes.key?(:'transaction_id') + self.transaction_id = attributes[:'transaction_id'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ApplePaymentDataTokenHeaderInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'application_data') + self.application_data = attributes[:'application_data'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'transaction_id') - self.transaction_id = attributes[:'transaction_id'] - end - if attributes.key?(:'application_data') - self.application_data = attributes[:'application_data'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - transaction_id == o.transaction_id && - application_data == o.application_data - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + transaction_id == o.transaction_id && + application_data == o.application_data + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [transaction_id, application_data].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [transaction_id, application_data].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_information.rb b/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_information.rb index bfb8409..8d82fd7 100644 --- a/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/apple_payment_data_token_information.rb @@ -1,227 +1,230 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Additional information about the Apple payment data token. This information are needed for checking the validity of the payment data token before decryption. + class ApplePaymentDataTokenInformation + # Version information about the payment token. Currently only EC_v1 for ECC-encrypted data is supported. + attr_accessor :version + + # Detached PKCS #7 signature, Base64 encoded as string. Signature of the payment and header data. The signature includes the signing certificate, its intermediate CA certificate, and information about the signing algorithm. + attr_accessor :signature + + attr_accessor :header + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end -# Additional information about the Apple payment data token. This information are needed for checking the validity of the payment data token before decryption. -class ApplePaymentDataTokenInformation - # Version information about the payment token. Currently only EC_v1 for ECC-encrypted data is supported. - attr_accessor :version - - # Detached PKCS #7 signature, Base64 encoded as string. Signature of the payment and header data. The signature includes the signing certificate, its intermediate CA certificate, and information about the signing algorithm. - attr_accessor :signature - - attr_accessor :header - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'version' => :'version', - :'signature' => :'signature', - :'header' => :'header' - } - end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'version' => :'String', - :'signature' => :'String', - :'header' => :'ApplePaymentDataTokenHeaderInformation' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'version' => :'version', + :'signature' => :'signature', + :'header' => :'header' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ApplePaymentDataTokenInformation` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'version' => :'String', + :'signature' => :'String', + :'header' => :'ApplePaymentDataTokenHeaderInformation' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ApplePaymentDataTokenInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'version') - self.version = attributes[:'version'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ApplePaymentDataTokenInformation` initialize method" + end - if attributes.key?(:'signature') - self.signature = attributes[:'signature'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ApplePaymentDataTokenInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'header') - self.header = attributes[:'header'] - end - end + if attributes.key?(:'version') + self.version = attributes[:'version'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - version == o.version && - signature == o.signature && - header == o.header - end + if attributes.key?(:'signature') + self.signature = attributes[:'signature'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'header') + self.header = attributes[:'header'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [version, signature, header].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + version == o.version && + signature == o.signature && + header == o.header + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [version, signature, header].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/authorization_mode.rb b/lib/PCP-server-Ruby-SDK/models/authorization_mode.rb index b53328d..ef11a29 100644 --- a/lib/PCP-server-Ruby-SDK/models/authorization_mode.rb +++ b/lib/PCP-server-Ruby-SDK/models/authorization_mode.rb @@ -1,27 +1,30 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class AuthorizationMode + PRE_AUTHORIZATION = "PRE_AUTHORIZATION".freeze + SALE = "SALE".freeze -class AuthorizationMode - PRE_AUTHORIZATION = "PRE_AUTHORIZATION".freeze - SALE = "SALE".freeze + def self.all_vars + @all_vars ||= [PRE_AUTHORIZATION, SALE].freeze + end - def self.all_vars - @all_vars ||= [PRE_AUTHORIZATION, SALE].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if AuthorizationMode.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #AuthorizationMode" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if AuthorizationMode.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #AuthorizationMode" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/bank_account_information.rb b/lib/PCP-server-Ruby-SDK/models/bank_account_information.rb index 273fb52..be82846 100644 --- a/lib/PCP-server-Ruby-SDK/models/bank_account_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/bank_account_information.rb @@ -1,200 +1,203 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing information about the end customer's bank account. + class BankAccountInformation + # IBAN of the end customer's bank account. The IBAN is the International Bank Account Number. It is an internationally agreed format for the BBAN and includes the ISO country code and two check digits. + attr_accessor :iban + + # Account holder of the bank account with the given IBAN. Does not necessarily have to be the end customer (e.g. joint accounts). + attr_accessor :account_holder + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'iban' => :'iban', + :'account_holder' => :'accountHolder' + } + end -# Object containing information about the end customer's bank account. -class BankAccountInformation - # IBAN of the end customer's bank account. The IBAN is the International Bank Account Number. It is an internationally agreed format for the BBAN and includes the ISO country code and two check digits. - attr_accessor :iban - - # Account holder of the bank account with the given IBAN. Does not necessarily have to be the end customer (e.g. joint accounts). - attr_accessor :account_holder - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'iban' => :'iban', - :'account_holder' => :'accountHolder' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'iban' => :'String', + :'account_holder' => :'String' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'iban' => :'String', - :'account_holder' => :'String' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `BankAccountInformation` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `BankAccountInformation` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `BankAccountInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'iban') + self.iban = attributes[:'iban'] + else + self.iban = nil + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `BankAccountInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'account_holder') + self.account_holder = attributes[:'account_holder'] + else + self.account_holder = nil + end end - h[k.to_sym] = v - } - - if attributes.key?(:'iban') - self.iban = attributes[:'iban'] - else - self.iban = nil - end - if attributes.key?(:'account_holder') - self.account_holder = attributes[:'account_holder'] - else - self.account_holder = nil - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - iban == o.iban && - account_holder == o.account_holder - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + iban == o.iban && + account_holder == o.account_holder + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [iban, account_holder].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [iban, account_holder].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cancel_item.rb b/lib/PCP-server-Ruby-SDK/models/cancel_item.rb index 5511afa..3cddd32 100644 --- a/lib/PCP-server-Ruby-SDK/models/cancel_item.rb +++ b/lib/PCP-server-Ruby-SDK/models/cancel_item.rb @@ -1,199 +1,202 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CancelItem + # Id of the item to cancel. + attr_accessor :id + + # Quantity of the units being cancelled, should be greater than zero Note: Must not be all spaces or all zeros + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'quantity' => :'quantity' + } + end -class CancelItem - # Id of the item to cancel. - attr_accessor :id - - # Quantity of the units being cancelled, should be greater than zero Note: Must not be all spaces or all zeros - attr_accessor :quantity - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'id' => :'id', - :'quantity' => :'quantity' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'quantity' => :'Integer' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'id' => :'String', - :'quantity' => :'Integer' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CancelItem` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CancelItem` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CancelItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CancelItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end end - h[k.to_sym] = v - } - - if attributes.key?(:'id') - self.id = attributes[:'id'] - else - self.id = nil - end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - else - self.quantity = nil - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - id == o.id && - quantity == o.quantity - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + quantity == o.quantity + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [id, quantity].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, quantity].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cancel_payment_request.rb b/lib/PCP-server-Ruby-SDK/models/cancel_payment_request.rb index 91ad3a4..e3b9265 100644 --- a/lib/PCP-server-Ruby-SDK/models/cancel_payment_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/cancel_payment_request.rb @@ -1,198 +1,201 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CancelPaymentRequest + attr_accessor :cancellation_reason + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end -class CancelPaymentRequest - attr_accessor :cancellation_reason - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'cancellation_reason' => :'cancellationReason' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'cancellation_reason' => :'cancellationReason' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'cancellation_reason' => :'CancellationReason' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'cancellation_reason' => :'CancellationReason' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CancelPaymentRequest` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CancelPaymentRequest` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CancelPaymentRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CancelPaymentRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'cancellation_reason') + self.cancellation_reason = attributes[:'cancellation_reason'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'cancellation_reason') - self.cancellation_reason = attributes[:'cancellation_reason'] - end - end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [cancellation_reason].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [cancellation_reason].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cancel_payment_response.rb b/lib/PCP-server-Ruby-SDK/models/cancel_payment_response.rb index 9dfbe59..ecbb55c 100644 --- a/lib/PCP-server-Ruby-SDK/models/cancel_payment_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/cancel_payment_response.rb @@ -1,184 +1,187 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CancelPaymentResponse + attr_accessor :payment + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment' => :'payment' + } + end -class CancelPaymentResponse - attr_accessor :payment - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment' => :'payment' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'payment' => :'PaymentResponse' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'payment' => :'PaymentResponse' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CancelPaymentResponse` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CancelPaymentResponse` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CancelPaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CancelPaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment') + self.payment = attributes[:'payment'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'payment') - self.payment = attributes[:'payment'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment == o.payment - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment == o.payment + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cancel_request.rb b/lib/PCP-server-Ruby-SDK/models/cancel_request.rb index d157c4c..9edf24a 100644 --- a/lib/PCP-server-Ruby-SDK/models/cancel_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/cancel_request.rb @@ -1,227 +1,230 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Request to mark items as of the respective Checkout as cancelled and to automatically reverse the associated payment. A Cancel can be created for a full or the partial ShoppingCart of the Checkout. The platform will automatically calculate the respective amount to trigger the Cancel. For a partial Cancel a list of items must be provided. The cancellationReason is mandatory for BNPL payment methods (paymentProductId 3390, 3391 and 3392). For other payment methods the cancellationReason is not mandatory but can be used for reporting and reconciliation purposes. + class CancelRequest + attr_accessor :cancel_type + + attr_accessor :cancellation_reason + + attr_accessor :cancel_items + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end -# Request to mark items as of the respective Checkout as cancelled and to automatically reverse the associated payment. A Cancel can be created for a full or the partial ShoppingCart of the Checkout. The platform will automatically calculate the respective amount to trigger the Cancel. For a partial Cancel a list of items must be provided. The cancellationReason is mandatory for BNPL payment methods (paymentProductId 3390, 3391 and 3392). For other payment methods the cancellationReason is not mandatory but can be used for reporting and reconciliation purposes. -class CancelRequest - attr_accessor :cancel_type - - attr_accessor :cancellation_reason - - attr_accessor :cancel_items - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'cancel_type' => :'cancelType', - :'cancellation_reason' => :'cancellationReason', - :'cancel_items' => :'cancelItems' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'cancel_type' => :'cancelType', + :'cancellation_reason' => :'cancellationReason', + :'cancel_items' => :'cancelItems' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'cancel_type' => :'CancelType', - :'cancellation_reason' => :'CancellationReason', - :'cancel_items' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'cancel_type' => :'CancelType', + :'cancellation_reason' => :'CancellationReason', + :'cancel_items' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CancelRequest` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CancelRequest` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CancelRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CancelRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'cancel_type') - self.cancel_type = attributes[:'cancel_type'] - end + if attributes.key?(:'cancel_type') + self.cancel_type = attributes[:'cancel_type'] + end - if attributes.key?(:'cancellation_reason') - self.cancellation_reason = attributes[:'cancellation_reason'] - end + if attributes.key?(:'cancellation_reason') + self.cancellation_reason = attributes[:'cancellation_reason'] + end - if attributes.key?(:'cancel_items') - if (value = attributes[:'cancel_items']).is_a?(Array) - self.cancel_items = value + if attributes.key?(:'cancel_items') + if (value = attributes[:'cancel_items']).is_a?(Array) + self.cancel_items = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - cancel_type == o.cancel_type && - cancellation_reason == o.cancellation_reason && - cancel_items == o.cancel_items - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + cancel_type == o.cancel_type && + cancellation_reason == o.cancellation_reason && + cancel_items == o.cancel_items + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [cancel_type, cancellation_reason, cancel_items].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [cancel_type, cancellation_reason, cancel_items].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cancel_response.rb b/lib/PCP-server-Ruby-SDK/models/cancel_response.rb index e96d3f3..9e805e8 100644 --- a/lib/PCP-server-Ruby-SDK/models/cancel_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/cancel_response.rb @@ -1,193 +1,196 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CancelResponse + attr_accessor :cancel_payment_response + + attr_accessor :shopping_cart + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'cancel_payment_response' => :'cancelPaymentResponse', + :'shopping_cart' => :'shoppingCart' + } + end -class CancelResponse - attr_accessor :cancel_payment_response - - attr_accessor :shopping_cart + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'cancel_payment_response' => :'cancelPaymentResponse', - :'shopping_cart' => :'shoppingCart' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'cancel_payment_response' => :'CancelPaymentResponse', + :'shopping_cart' => :'ShoppingCartResult' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'cancel_payment_response' => :'CancelPaymentResponse', - :'shopping_cart' => :'ShoppingCartResult' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CancelResponse` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CancelResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CancelResponse` initialize method" - end + if attributes.key?(:'cancel_payment_response') + self.cancel_payment_response = attributes[:'cancel_payment_response'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CancelResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'cancel_payment_response') - self.cancel_payment_response = attributes[:'cancel_payment_response'] - end - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - cancel_payment_response == o.cancel_payment_response && - shopping_cart == o.shopping_cart - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + cancel_payment_response == o.cancel_payment_response && + shopping_cart == o.shopping_cart + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [cancel_payment_response, shopping_cart].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [cancel_payment_response, shopping_cart].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cancel_type.rb b/lib/PCP-server-Ruby-SDK/models/cancel_type.rb index bca7222..836cc41 100644 --- a/lib/PCP-server-Ruby-SDK/models/cancel_type.rb +++ b/lib/PCP-server-Ruby-SDK/models/cancel_type.rb @@ -1,27 +1,30 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CancelType + FULL = "FULL".freeze + PARTIAL = "PARTIAL".freeze -class CancelType - FULL = "FULL".freeze - PARTIAL = "PARTIAL".freeze + def self.all_vars + @all_vars ||= [FULL, PARTIAL].freeze + end - def self.all_vars - @all_vars ||= [FULL, PARTIAL].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if CancelType.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #CancelType" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if CancelType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #CancelType" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cancellation_reason.rb b/lib/PCP-server-Ruby-SDK/models/cancellation_reason.rb index 2ee9615..8321092 100644 --- a/lib/PCP-server-Ruby-SDK/models/cancellation_reason.rb +++ b/lib/PCP-server-Ruby-SDK/models/cancellation_reason.rb @@ -1,31 +1,34 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CancellationReason + CONSUMER_REQUEST = "CONSUMER_REQUEST".freeze + UNDELIVERABLE = "UNDELIVERABLE".freeze + DUPLICATE = "DUPLICATE".freeze + FRAUDULENT = "FRAUDULENT".freeze + ORDER_SHIPPED_IN_FULL = "ORDER_SHIPPED_IN_FULL".freeze + AUTOMATED_SHIPMENT_FAILED = "AUTOMATED_SHIPMENT_FAILED".freeze -class CancellationReason - CONSUMER_REQUEST = "CONSUMER_REQUEST".freeze - UNDELIVERABLE = "UNDELIVERABLE".freeze - DUPLICATE = "DUPLICATE".freeze - FRAUDULENT = "FRAUDULENT".freeze - ORDER_SHIPPED_IN_FULL = "ORDER_SHIPPED_IN_FULL".freeze - AUTOMATED_SHIPMENT_FAILED = "AUTOMATED_SHIPMENT_FAILED".freeze + def self.all_vars + @all_vars ||= [CONSUMER_REQUEST, UNDELIVERABLE, DUPLICATE, FRAUDULENT, ORDER_SHIPPED_IN_FULL, AUTOMATED_SHIPMENT_FAILED].freeze + end - def self.all_vars - @all_vars ||= [CONSUMER_REQUEST, UNDELIVERABLE, DUPLICATE, FRAUDULENT, ORDER_SHIPPED_IN_FULL, AUTOMATED_SHIPMENT_FAILED].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if CancellationReason.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #CancellationReason" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if CancellationReason.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #CancellationReason" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/capture_output.rb b/lib/PCP-server-Ruby-SDK/models/capture_output.rb index 5d0ce39..ad4ca10 100644 --- a/lib/PCP-server-Ruby-SDK/models/capture_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/capture_output.rb @@ -1,214 +1,217 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing Capture details. + class CaptureOutput + attr_accessor :amount_of_money + + # It allows you to store additional parameters for the transaction in JSON format. This field must not contain any personal data. + attr_accessor :merchant_parameters + + attr_accessor :references + + # Payment method identifier used by our payment engine. + attr_accessor :payment_method + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'merchant_parameters' => :'merchantParameters', + :'references' => :'references', + :'payment_method' => :'paymentMethod' + } + end -# Object containing Capture details. -class CaptureOutput - attr_accessor :amount_of_money - - # It allows you to store additional parameters for the transaction in JSON format. This field must not contain any personal data. - attr_accessor :merchant_parameters + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :references + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'merchant_parameters' => :'String', + :'references' => :'PaymentReferences', + :'payment_method' => :'String' + } + end - # Payment method identifier used by our payment engine. - attr_accessor :payment_method + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'merchant_parameters' => :'merchantParameters', - :'references' => :'references', - :'payment_method' => :'paymentMethod' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CaptureOutput` initialize method" + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CaptureOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'merchant_parameters' => :'String', - :'references' => :'PaymentReferences', - :'payment_method' => :'String' - } - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'merchant_parameters') + self.merchant_parameters = attributes[:'merchant_parameters'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CaptureOutput` initialize method" - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CaptureOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_method') + self.payment_method = attributes[:'payment_method'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end - - if attributes.key?(:'merchant_parameters') - self.merchant_parameters = attributes[:'merchant_parameters'] - end - - if attributes.key?(:'references') - self.references = attributes[:'references'] - end - - if attributes.key?(:'payment_method') - self.payment_method = attributes[:'payment_method'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - merchant_parameters == o.merchant_parameters && - references == o.references && - payment_method == o.payment_method - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + merchant_parameters == o.merchant_parameters && + references == o.references && + payment_method == o.payment_method + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, merchant_parameters, references, payment_method].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, merchant_parameters, references, payment_method].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/capture_payment_request.rb b/lib/PCP-server-Ruby-SDK/models/capture_payment_request.rb index caada8c..0063384 100644 --- a/lib/PCP-server-Ruby-SDK/models/capture_payment_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/capture_payment_request.rb @@ -1,247 +1,250 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # If the shopping cart is specified, a Capture is made with the amount of the shopping cart for the items that are specified. + class CapturePaymentRequest + # Here you can specify the amount that you want to capture (specified in cents, where single digit currencies are presumed to have 2 digits). The amount can be lower than the amount that was authorized, but not higher. If left empty, the full amount will be captured and the request will be final. If the full amount is captured, the request will also be final. + attr_accessor :amount + + # This property indicates whether this will be the final operation. If the full amount should not captured but the property is set to true, the remaining amount will automatically be cancelled. + attr_accessor :is_final + + attr_accessor :cancellation_reason + + attr_accessor :references + + attr_accessor :delivery + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end -# If the shopping cart is specified, a Capture is made with the amount of the shopping cart for the items that are specified. -class CapturePaymentRequest - # Here you can specify the amount that you want to capture (specified in cents, where single digit currencies are presumed to have 2 digits). The amount can be lower than the amount that was authorized, but not higher. If left empty, the full amount will be captured and the request will be final. If the full amount is captured, the request will also be final. - attr_accessor :amount - - # This property indicates whether this will be the final operation. If the full amount should not captured but the property is set to true, the remaining amount will automatically be cancelled. - attr_accessor :is_final - - attr_accessor :cancellation_reason - - attr_accessor :references - - attr_accessor :delivery - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount' => :'amount', - :'is_final' => :'isFinal', - :'cancellation_reason' => :'cancellationReason', - :'references' => :'references', - :'delivery' => :'delivery' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'amount' => :'Integer', - :'is_final' => :'Boolean', - :'cancellation_reason' => :'CancellationReason', - :'references' => :'PaymentReferences', - :'delivery' => :'DeliveryInformation' - } - end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'is_final' => :'isFinal', + :'cancellation_reason' => :'cancellationReason', + :'references' => :'references', + :'delivery' => :'delivery' + } + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CapturePaymentRequest` initialize method" - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CapturePaymentRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Integer', + :'is_final' => :'Boolean', + :'cancellation_reason' => :'CancellationReason', + :'references' => :'PaymentReferences', + :'delivery' => :'DeliveryInformation' + } end - h[k.to_sym] = v - } - if attributes.key?(:'amount') - self.amount = attributes[:'amount'] - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - if attributes.key?(:'is_final') - self.is_final = attributes[:'is_final'] - else - self.is_final = false - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CapturePaymentRequest` initialize method" + end - if attributes.key?(:'cancellation_reason') - self.cancellation_reason = attributes[:'cancellation_reason'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CapturePaymentRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'references') - self.references = attributes[:'references'] - end + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + end - if attributes.key?(:'delivery') - self.delivery = attributes[:'delivery'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount == o.amount && - is_final == o.is_final && - cancellation_reason == o.cancellation_reason && - references == o.references && - delivery == o.delivery - end + if attributes.key?(:'is_final') + self.is_final = attributes[:'is_final'] + else + self.is_final = false + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'cancellation_reason') + self.cancellation_reason = attributes[:'cancellation_reason'] + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount, is_final, cancellation_reason, references, delivery].hash - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes.key?(:'delivery') + self.delivery = attributes[:'delivery'] end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end - end - new(transformed_hash) - end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + is_final == o.is_final && + cancellation_reason == o.cancellation_reason && + references == o.references && + delivery == o.delivery + end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, is_final, cancellation_reason, references, delivery].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/capture_payment_response.rb b/lib/PCP-server-Ruby-SDK/models/capture_payment_response.rb index 6085656..713d07a 100644 --- a/lib/PCP-server-Ruby-SDK/models/capture_payment_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/capture_payment_response.rb @@ -1,234 +1,237 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CapturePaymentResponse + attr_accessor :capture_output + + attr_accessor :status + + attr_accessor :status_output + + # Unique payment transaction identifier of the payment gateway. + attr_accessor :id + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end -class CapturePaymentResponse - attr_accessor :capture_output - - attr_accessor :status - - attr_accessor :status_output - - # Unique payment transaction identifier of the payment gateway. - attr_accessor :id - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'capture_output' => :'captureOutput', - :'status' => :'status', - :'status_output' => :'statusOutput', - :'id' => :'id' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - # Attribute type mapping. - def self.openapi_types - { - :'capture_output' => :'CaptureOutput', - :'status' => :'StatusValue', - :'status_output' => :'PaymentStatusOutput', - :'id' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'capture_output' => :'captureOutput', + :'status' => :'status', + :'status_output' => :'statusOutput', + :'id' => :'id' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CapturePaymentResponse` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'capture_output' => :'CaptureOutput', + :'status' => :'StatusValue', + :'status_output' => :'PaymentStatusOutput', + :'id' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CapturePaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'capture_output') - self.capture_output = attributes[:'capture_output'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CapturePaymentResponse` initialize method" + end - if attributes.key?(:'status') - self.status = attributes[:'status'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CapturePaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'status_output') - self.status_output = attributes[:'status_output'] - end + if attributes.key?(:'capture_output') + self.capture_output = attributes[:'capture_output'] + end - if attributes.key?(:'id') - self.id = attributes[:'id'] - end - end + if attributes.key?(:'status') + self.status = attributes[:'status'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - capture_output == o.capture_output && - status == o.status && - status_output == o.status_output && - id == o.id - end + if attributes.key?(:'status_output') + self.status_output = attributes[:'status_output'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [capture_output, status, status_output, id].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + capture_output == o.capture_output && + status == o.status && + status_output == o.status_output && + id == o.id + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [capture_output, status, status_output, id].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/card_fraud_results.rb b/lib/PCP-server-Ruby-SDK/models/card_fraud_results.rb index 7a5e678..e13b88f 100644 --- a/lib/PCP-server-Ruby-SDK/models/card_fraud_results.rb +++ b/lib/PCP-server-Ruby-SDK/models/card_fraud_results.rb @@ -1,186 +1,189 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Fraud results contained in the CardFraudResults object. + class CardFraudResults + # Result of the Address Verification Service checks. Possible values are: * A - Address (Street) matches, Zip does not * B - Street address match for international transactions—Postal code not verified due to incompatible formats * C - Street address and postal code not verified for international transaction due to incompatible formats * D - Street address and postal code match for international transaction, cardholder name is incorrect * E - AVS error * F - Address does match and five digit ZIP code does match (UK only) * G - Address information is unavailable; international transaction; non-AVS participant * H - Billing address and postal code match, cardholder name is incorrect (Amex) * I - Address information not verified for international transaction * K - Cardholder name matches (Amex) * L - Cardholder name and postal code match (Amex) * M - Cardholder name, street address, and postal code match for international transaction * N - No Match on Address (Street) or Zip * O - Cardholder name and address match (Amex) * P - Postal codes match for international transaction—Street address not verified due to incompatible formats * Q - Billing address matches, cardholder is incorrect (Amex) * R - Retry, System unavailable or Timed out * S - Service not supported by issuer * U - Address information is unavailable * W - 9 digit Zip matches, Address (Street) does not * X - Exact AVS Match * Y - Address (Street) and 5 digit Zip match * Z - 5 digit Zip matches, Address (Street) does not * 0 - No service available + attr_accessor :avs_result + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'avs_result' => :'avsResult' + } + end -# Fraud results contained in the CardFraudResults object. -class CardFraudResults - # Result of the Address Verification Service checks. Possible values are: * A - Address (Street) matches, Zip does not * B - Street address match for international transactions—Postal code not verified due to incompatible formats * C - Street address and postal code not verified for international transaction due to incompatible formats * D - Street address and postal code match for international transaction, cardholder name is incorrect * E - AVS error * F - Address does match and five digit ZIP code does match (UK only) * G - Address information is unavailable; international transaction; non-AVS participant * H - Billing address and postal code match, cardholder name is incorrect (Amex) * I - Address information not verified for international transaction * K - Cardholder name matches (Amex) * L - Cardholder name and postal code match (Amex) * M - Cardholder name, street address, and postal code match for international transaction * N - No Match on Address (Street) or Zip * O - Cardholder name and address match (Amex) * P - Postal codes match for international transaction—Street address not verified due to incompatible formats * Q - Billing address matches, cardholder is incorrect (Amex) * R - Retry, System unavailable or Timed out * S - Service not supported by issuer * U - Address information is unavailable * W - 9 digit Zip matches, Address (Street) does not * X - Exact AVS Match * Y - Address (Street) and 5 digit Zip match * Z - 5 digit Zip matches, Address (Street) does not * 0 - No service available - attr_accessor :avs_result - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'avs_result' => :'avsResult' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'avs_result' => :'String' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'avs_result' => :'String' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CardFraudResults` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CardFraudResults` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CardFraudResults`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CardFraudResults`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'avs_result') + self.avs_result = attributes[:'avs_result'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'avs_result') - self.avs_result = attributes[:'avs_result'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - avs_result == o.avs_result - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + avs_result == o.avs_result + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [avs_result].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [avs_result].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/card_info.rb b/lib/PCP-server-Ruby-SDK/models/card_info.rb index 39a0703..ebf94e5 100644 --- a/lib/PCP-server-Ruby-SDK/models/card_info.rb +++ b/lib/PCP-server-Ruby-SDK/models/card_info.rb @@ -1,186 +1,189 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing additional non PCI DSS relevant card information. used instead of card (missing fields: cardNumber, expiryDate, cvv) + class CardInfo + # The card holder's name on the card. + attr_accessor :cardholder_name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'cardholder_name' => :'cardholderName' + } + end -# Object containing additional non PCI DSS relevant card information. used instead of card (missing fields: cardNumber, expiryDate, cvv) -class CardInfo - # The card holder's name on the card. - attr_accessor :cardholder_name - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'cardholder_name' => :'cardholderName' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'cardholder_name' => :'String' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'cardholder_name' => :'String' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CardInfo` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CardInfo` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CardInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CardInfo`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'cardholder_name') + self.cardholder_name = attributes[:'cardholder_name'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'cardholder_name') - self.cardholder_name = attributes[:'cardholder_name'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - cardholder_name == o.cardholder_name - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + cardholder_name == o.cardholder_name + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [cardholder_name].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [cardholder_name].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/card_payment_details.rb b/lib/PCP-server-Ruby-SDK/models/card_payment_details.rb index 1410f54..c11f3ae 100644 --- a/lib/PCP-server-Ruby-SDK/models/card_payment_details.rb +++ b/lib/PCP-server-Ruby-SDK/models/card_payment_details.rb @@ -1,216 +1,219 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Information for card payments realized at a POS. + class CardPaymentDetails + # Reference to the card of the transaction. + attr_accessor :masked_card_number + + # ID of the token. This property is populated when the payment was done with a token. + attr_accessor :payment_processing_token + + # Token to identify the card in the reporting. + attr_accessor :reporting_token + + # Identifier for a successful authorization, reversal or refund. Usually provided by the issuer system. Only provided for card payments. + attr_accessor :card_authorization_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'masked_card_number' => :'maskedCardNumber', + :'payment_processing_token' => :'paymentProcessingToken', + :'reporting_token' => :'reportingToken', + :'card_authorization_id' => :'cardAuthorizationId' + } + end -# Information for card payments realized at a POS. -class CardPaymentDetails - # Reference to the card of the transaction. - attr_accessor :masked_card_number - - # ID of the token. This property is populated when the payment was done with a token. - attr_accessor :payment_processing_token + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Token to identify the card in the reporting. - attr_accessor :reporting_token + # Attribute type mapping. + def self.openapi_types + { + :'masked_card_number' => :'String', + :'payment_processing_token' => :'String', + :'reporting_token' => :'String', + :'card_authorization_id' => :'String' + } + end - # Identifier for a successful authorization, reversal or refund. Usually provided by the issuer system. Only provided for card payments. - attr_accessor :card_authorization_id + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'masked_card_number' => :'maskedCardNumber', - :'payment_processing_token' => :'paymentProcessingToken', - :'reporting_token' => :'reportingToken', - :'card_authorization_id' => :'cardAuthorizationId' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CardPaymentDetails` initialize method" + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CardPaymentDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Attribute type mapping. - def self.openapi_types - { - :'masked_card_number' => :'String', - :'payment_processing_token' => :'String', - :'reporting_token' => :'String', - :'card_authorization_id' => :'String' - } - end + if attributes.key?(:'masked_card_number') + self.masked_card_number = attributes[:'masked_card_number'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'payment_processing_token') + self.payment_processing_token = attributes[:'payment_processing_token'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CardPaymentDetails` initialize method" - end + if attributes.key?(:'reporting_token') + self.reporting_token = attributes[:'reporting_token'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CardPaymentDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'card_authorization_id') + self.card_authorization_id = attributes[:'card_authorization_id'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'masked_card_number') - self.masked_card_number = attributes[:'masked_card_number'] - end - - if attributes.key?(:'payment_processing_token') - self.payment_processing_token = attributes[:'payment_processing_token'] - end - - if attributes.key?(:'reporting_token') - self.reporting_token = attributes[:'reporting_token'] - end - - if attributes.key?(:'card_authorization_id') - self.card_authorization_id = attributes[:'card_authorization_id'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - masked_card_number == o.masked_card_number && - payment_processing_token == o.payment_processing_token && - reporting_token == o.reporting_token && - card_authorization_id == o.card_authorization_id - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + masked_card_number == o.masked_card_number && + payment_processing_token == o.payment_processing_token && + reporting_token == o.reporting_token && + card_authorization_id == o.card_authorization_id + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [masked_card_number, payment_processing_token, reporting_token, card_authorization_id].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [masked_card_number, payment_processing_token, reporting_token, card_authorization_id].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_input.rb index 1d48ef5..9397133 100644 --- a/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_input.rb @@ -1,312 +1,315 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing the specific input details for card payments. + class CardPaymentMethodSpecificInput + attr_accessor :authorization_mode -# Object containing the specific input details for card payments. -class CardPaymentMethodSpecificInput - attr_accessor :authorization_mode + attr_accessor :recurring - attr_accessor :recurring + # ID of the token to use to create the payment. + attr_accessor :payment_processing_token - # ID of the token to use to create the payment. - attr_accessor :payment_processing_token + # Token to identify the card in the reporting. + attr_accessor :reporting_token - # Token to identify the card in the reporting. - attr_accessor :reporting_token + attr_accessor :transaction_channel - attr_accessor :transaction_channel + attr_accessor :unscheduled_card_on_file_requestor - attr_accessor :unscheduled_card_on_file_requestor + attr_accessor :unscheduled_card_on_file_sequence_indicator - attr_accessor :unscheduled_card_on_file_sequence_indicator + # Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id - # Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id + attr_accessor :card - attr_accessor :card + # The URL that the customer is redirect to after the payment flow has finished. You can add any number of key value pairs in the query string that, for instance help you to identify the customer when they return to your site. Please note that we will also append some additional key value pairs that will also help you with this identification process. Note: The provided URL should be absolute and contain the protocol to use, e.g. http:// or https://. For use on mobile devices a custom protocol can be used in the form of protocol://. This protocol must be registered on the device first. URLs without a protocol will be rejected. + attr_accessor :return_url - # The URL that the customer is redirect to after the payment flow has finished. You can add any number of key value pairs in the query string that, for instance help you to identify the customer when they return to your site. Please note that we will also append some additional key value pairs that will also help you with this identification process. Note: The provided URL should be absolute and contain the protocol to use, e.g. http:// or https://. For use on mobile devices a custom protocol can be used in the form of protocol://. This protocol must be registered on the device first. URLs without a protocol will be rejected. - attr_accessor :return_url + # Period of payment occurrence for recurring and installment payments. Allowed values: * Yearly * Quarterly * Monthly * Weekly * Daily Supported soon + attr_accessor :card_on_file_recurring_frequency - # Period of payment occurrence for recurring and installment payments. Allowed values: * Yearly * Quarterly * Monthly * Weekly * Daily Supported soon - attr_accessor :card_on_file_recurring_frequency + # The end date of the last scheduled payment in a series of transactions. Format YYYYMMDD Supported soon + attr_accessor :card_on_file_recurring_expiration - # The end date of the last scheduled payment in a series of transactions. Format YYYYMMDD Supported soon - attr_accessor :card_on_file_recurring_expiration + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'authorization_mode' => :'authorizationMode', - :'recurring' => :'recurring', - :'payment_processing_token' => :'paymentProcessingToken', - :'reporting_token' => :'reportingToken', - :'transaction_channel' => :'transactionChannel', - :'unscheduled_card_on_file_requestor' => :'unscheduledCardOnFileRequestor', - :'unscheduled_card_on_file_sequence_indicator' => :'unscheduledCardOnFileSequenceIndicator', - :'payment_product_id' => :'paymentProductId', - :'card' => :'card', - :'return_url' => :'returnUrl', - :'card_on_file_recurring_frequency' => :'cardOnFileRecurringFrequency', - :'card_on_file_recurring_expiration' => :'cardOnFileRecurringExpiration' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'authorization_mode' => :'AuthorizationMode', - :'recurring' => :'CardRecurrenceDetails', - :'payment_processing_token' => :'String', - :'reporting_token' => :'String', - :'transaction_channel' => :'TransactionChannel', - :'unscheduled_card_on_file_requestor' => :'UnscheduledCardOnFileRequestor', - :'unscheduled_card_on_file_sequence_indicator' => :'UnscheduledCardOnFileSequenceIndicator', - :'payment_product_id' => :'Integer', - :'card' => :'CardInfo', - :'return_url' => :'String', - :'card_on_file_recurring_frequency' => :'String', - :'card_on_file_recurring_expiration' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'authorization_mode' => :'authorizationMode', + :'recurring' => :'recurring', + :'payment_processing_token' => :'paymentProcessingToken', + :'reporting_token' => :'reportingToken', + :'transaction_channel' => :'transactionChannel', + :'unscheduled_card_on_file_requestor' => :'unscheduledCardOnFileRequestor', + :'unscheduled_card_on_file_sequence_indicator' => :'unscheduledCardOnFileSequenceIndicator', + :'payment_product_id' => :'paymentProductId', + :'card' => :'card', + :'return_url' => :'returnUrl', + :'card_on_file_recurring_frequency' => :'cardOnFileRecurringFrequency', + :'card_on_file_recurring_expiration' => :'cardOnFileRecurringExpiration' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CardPaymentMethodSpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'authorization_mode' => :'AuthorizationMode', + :'recurring' => :'CardRecurrenceDetails', + :'payment_processing_token' => :'String', + :'reporting_token' => :'String', + :'transaction_channel' => :'TransactionChannel', + :'unscheduled_card_on_file_requestor' => :'UnscheduledCardOnFileRequestor', + :'unscheduled_card_on_file_sequence_indicator' => :'UnscheduledCardOnFileSequenceIndicator', + :'payment_product_id' => :'Integer', + :'card' => :'CardInfo', + :'return_url' => :'String', + :'card_on_file_recurring_frequency' => :'String', + :'card_on_file_recurring_expiration' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CardPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'authorization_mode') - self.authorization_mode = attributes[:'authorization_mode'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CardPaymentMethodSpecificInput` initialize method" + end - if attributes.key?(:'recurring') - self.recurring = attributes[:'recurring'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CardPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'payment_processing_token') - self.payment_processing_token = attributes[:'payment_processing_token'] - end + if attributes.key?(:'authorization_mode') + self.authorization_mode = attributes[:'authorization_mode'] + end - if attributes.key?(:'reporting_token') - self.reporting_token = attributes[:'reporting_token'] - end + if attributes.key?(:'recurring') + self.recurring = attributes[:'recurring'] + end - if attributes.key?(:'transaction_channel') - self.transaction_channel = attributes[:'transaction_channel'] - end + if attributes.key?(:'payment_processing_token') + self.payment_processing_token = attributes[:'payment_processing_token'] + end - if attributes.key?(:'unscheduled_card_on_file_requestor') - self.unscheduled_card_on_file_requestor = attributes[:'unscheduled_card_on_file_requestor'] - end + if attributes.key?(:'reporting_token') + self.reporting_token = attributes[:'reporting_token'] + end - if attributes.key?(:'unscheduled_card_on_file_sequence_indicator') - self.unscheduled_card_on_file_sequence_indicator = attributes[:'unscheduled_card_on_file_sequence_indicator'] - end + if attributes.key?(:'transaction_channel') + self.transaction_channel = attributes[:'transaction_channel'] + end - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end + if attributes.key?(:'unscheduled_card_on_file_requestor') + self.unscheduled_card_on_file_requestor = attributes[:'unscheduled_card_on_file_requestor'] + end - if attributes.key?(:'card') - self.card = attributes[:'card'] - end + if attributes.key?(:'unscheduled_card_on_file_sequence_indicator') + self.unscheduled_card_on_file_sequence_indicator = attributes[:'unscheduled_card_on_file_sequence_indicator'] + end - if attributes.key?(:'return_url') - self.return_url = attributes[:'return_url'] - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - if attributes.key?(:'card_on_file_recurring_frequency') - self.card_on_file_recurring_frequency = attributes[:'card_on_file_recurring_frequency'] - end + if attributes.key?(:'card') + self.card = attributes[:'card'] + end - if attributes.key?(:'card_on_file_recurring_expiration') - self.card_on_file_recurring_expiration = attributes[:'card_on_file_recurring_expiration'] - end - end + if attributes.key?(:'return_url') + self.return_url = attributes[:'return_url'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - authorization_mode == o.authorization_mode && - recurring == o.recurring && - payment_processing_token == o.payment_processing_token && - reporting_token == o.reporting_token && - transaction_channel == o.transaction_channel && - unscheduled_card_on_file_requestor == o.unscheduled_card_on_file_requestor && - unscheduled_card_on_file_sequence_indicator == o.unscheduled_card_on_file_sequence_indicator && - payment_product_id == o.payment_product_id && - card == o.card && - return_url == o.return_url && - card_on_file_recurring_frequency == o.card_on_file_recurring_frequency && - card_on_file_recurring_expiration == o.card_on_file_recurring_expiration - end + if attributes.key?(:'card_on_file_recurring_frequency') + self.card_on_file_recurring_frequency = attributes[:'card_on_file_recurring_frequency'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'card_on_file_recurring_expiration') + self.card_on_file_recurring_expiration = attributes[:'card_on_file_recurring_expiration'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [authorization_mode, recurring, payment_processing_token, reporting_token, transaction_channel, unscheduled_card_on_file_requestor, unscheduled_card_on_file_sequence_indicator, payment_product_id, card, return_url, card_on_file_recurring_frequency, card_on_file_recurring_expiration].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + authorization_mode == o.authorization_mode && + recurring == o.recurring && + payment_processing_token == o.payment_processing_token && + reporting_token == o.reporting_token && + transaction_channel == o.transaction_channel && + unscheduled_card_on_file_requestor == o.unscheduled_card_on_file_requestor && + unscheduled_card_on_file_sequence_indicator == o.unscheduled_card_on_file_sequence_indicator && + payment_product_id == o.payment_product_id && + card == o.card && + return_url == o.return_url && + card_on_file_recurring_frequency == o.card_on_file_recurring_frequency && + card_on_file_recurring_expiration == o.card_on_file_recurring_expiration + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [authorization_mode, recurring, payment_processing_token, reporting_token, transaction_channel, unscheduled_card_on_file_requestor, unscheduled_card_on_file_sequence_indicator, payment_product_id, card, return_url, card_on_file_recurring_frequency, card_on_file_recurring_expiration].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_output.rb index 97488f7..8b80834 100644 --- a/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/card_payment_method_specific_output.rb @@ -1,214 +1,217 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing the card payment method details. + class CardPaymentMethodSpecificOutput + # Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id + + # Card Authorization code as returned by the acquirer + attr_accessor :authorisation_code + + attr_accessor :fraud_results + + attr_accessor :three_d_secure_results + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'authorisation_code' => :'authorisationCode', + :'fraud_results' => :'fraudResults', + :'three_d_secure_results' => :'threeDSecureResults' + } + end -# Object containing the card payment method details. -class CardPaymentMethodSpecificOutput - # Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id - - # Card Authorization code as returned by the acquirer - attr_accessor :authorisation_code + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :fraud_results + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'authorisation_code' => :'String', + :'fraud_results' => :'CardFraudResults', + :'three_d_secure_results' => :'ThreeDSecureResults' + } + end - attr_accessor :three_d_secure_results + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'authorisation_code' => :'authorisationCode', - :'fraud_results' => :'fraudResults', - :'three_d_secure_results' => :'threeDSecureResults' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CardPaymentMethodSpecificOutput` initialize method" + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CardPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'authorisation_code' => :'String', - :'fraud_results' => :'CardFraudResults', - :'three_d_secure_results' => :'ThreeDSecureResults' - } - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'authorisation_code') + self.authorisation_code = attributes[:'authorisation_code'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CardPaymentMethodSpecificOutput` initialize method" - end + if attributes.key?(:'fraud_results') + self.fraud_results = attributes[:'fraud_results'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CardPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'three_d_secure_results') + self.three_d_secure_results = attributes[:'three_d_secure_results'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end - - if attributes.key?(:'authorisation_code') - self.authorisation_code = attributes[:'authorisation_code'] - end - - if attributes.key?(:'fraud_results') - self.fraud_results = attributes[:'fraud_results'] - end - - if attributes.key?(:'three_d_secure_results') - self.three_d_secure_results = attributes[:'three_d_secure_results'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - authorisation_code == o.authorisation_code && - fraud_results == o.fraud_results && - three_d_secure_results == o.three_d_secure_results - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + authorisation_code == o.authorisation_code && + fraud_results == o.fraud_results && + three_d_secure_results == o.three_d_secure_results + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, authorisation_code, fraud_results, three_d_secure_results].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, authorisation_code, fraud_results, three_d_secure_results].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/card_recurrence_details.rb b/lib/PCP-server-Ruby-SDK/models/card_recurrence_details.rb index 7360541..5cbfe60 100644 --- a/lib/PCP-server-Ruby-SDK/models/card_recurrence_details.rb +++ b/lib/PCP-server-Ruby-SDK/models/card_recurrence_details.rb @@ -1,186 +1,189 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing data related to recurring. + class CardRecurrenceDetails + # * first = This transaction is the first of a series of recurring transactions * recurring = This transaction is a subsequent transaction in a series of recurring transactions Note: For any first of a recurring the system will automatically create a token as you will need to use a token for any subsequent recurring transactions. In case a token already exists this is indicated in the response with a value of False for the isNewToken property in the response. + attr_accessor :recurring_payment_sequence_indicator + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'recurring_payment_sequence_indicator' => :'recurringPaymentSequenceIndicator' + } + end -# Object containing data related to recurring. -class CardRecurrenceDetails - # * first = This transaction is the first of a series of recurring transactions * recurring = This transaction is a subsequent transaction in a series of recurring transactions Note: For any first of a recurring the system will automatically create a token as you will need to use a token for any subsequent recurring transactions. In case a token already exists this is indicated in the response with a value of False for the isNewToken property in the response. - attr_accessor :recurring_payment_sequence_indicator - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'recurring_payment_sequence_indicator' => :'recurringPaymentSequenceIndicator' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'recurring_payment_sequence_indicator' => :'String' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'recurring_payment_sequence_indicator' => :'String' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CardRecurrenceDetails` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CardRecurrenceDetails` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CardRecurrenceDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CardRecurrenceDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'recurring_payment_sequence_indicator') + self.recurring_payment_sequence_indicator = attributes[:'recurring_payment_sequence_indicator'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'recurring_payment_sequence_indicator') - self.recurring_payment_sequence_indicator = attributes[:'recurring_payment_sequence_indicator'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - recurring_payment_sequence_indicator == o.recurring_payment_sequence_indicator - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + recurring_payment_sequence_indicator == o.recurring_payment_sequence_indicator + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [recurring_payment_sequence_indicator].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [recurring_payment_sequence_indicator].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cart_item_input.rb b/lib/PCP-server-Ruby-SDK/models/cart_item_input.rb index 611d8da..3b0333a 100644 --- a/lib/PCP-server-Ruby-SDK/models/cart_item_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/cart_item_input.rb @@ -1,194 +1,197 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # This object contains information of all items in the cart. If a cart item is provided, the productPrice and quantity is required. + class CartItemInput + attr_accessor :invoice_data + + attr_accessor :order_line_details + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'invoice_data' => :'invoiceData', + :'order_line_details' => :'orderLineDetails' + } + end -# This object contains information of all items in the cart. If a cart item is provided, the productPrice and quantity is required. -class CartItemInput - attr_accessor :invoice_data - - attr_accessor :order_line_details + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'invoice_data' => :'invoiceData', - :'order_line_details' => :'orderLineDetails' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'invoice_data' => :'CartItemInvoiceData', + :'order_line_details' => :'OrderLineDetailsInput' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'invoice_data' => :'CartItemInvoiceData', - :'order_line_details' => :'OrderLineDetailsInput' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemInput` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemInput` initialize method" - end + if attributes.key?(:'invoice_data') + self.invoice_data = attributes[:'invoice_data'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'order_line_details') + self.order_line_details = attributes[:'order_line_details'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'invoice_data') - self.invoice_data = attributes[:'invoice_data'] - end - if attributes.key?(:'order_line_details') - self.order_line_details = attributes[:'order_line_details'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - invoice_data == o.invoice_data && - order_line_details == o.order_line_details - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + invoice_data == o.invoice_data && + order_line_details == o.order_line_details + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [invoice_data, order_line_details].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [invoice_data, order_line_details].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cart_item_invoice_data.rb b/lib/PCP-server-Ruby-SDK/models/cart_item_invoice_data.rb index 259998e..e906705 100644 --- a/lib/PCP-server-Ruby-SDK/models/cart_item_invoice_data.rb +++ b/lib/PCP-server-Ruby-SDK/models/cart_item_invoice_data.rb @@ -1,186 +1,189 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing the line items of the invoice or shopping cart. + class CartItemInvoiceData + # Shopping cart item description. The description will also be displayed in the portal as the product name. + attr_accessor :description + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'description' => :'description' + } + end -# Object containing the line items of the invoice or shopping cart. -class CartItemInvoiceData - # Shopping cart item description. The description will also be displayed in the portal as the product name. - attr_accessor :description - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'description' => :'description' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'description' => :'String' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'description' => :'String' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemInvoiceData` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemInvoiceData` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemInvoiceData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemInvoiceData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'description') + self.description = attributes[:'description'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'description') - self.description = attributes[:'description'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - description == o.description - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + description == o.description + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [description].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [description].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cart_item_order_status.rb b/lib/PCP-server-Ruby-SDK/models/cart_item_order_status.rb index e8fef42..1da74d6 100644 --- a/lib/PCP-server-Ruby-SDK/models/cart_item_order_status.rb +++ b/lib/PCP-server-Ruby-SDK/models/cart_item_order_status.rb @@ -1,217 +1,220 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Detailed information regarding an occurred payment event. + class CartItemOrderStatus + attr_accessor :cart_item_status + + # Amount of units for which this status is applicable, should be greater than zero + attr_accessor :quantity + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end -# Detailed information regarding an occurred payment event. -class CartItemOrderStatus - attr_accessor :cart_item_status - - # Amount of units for which this status is applicable, should be greater than zero - attr_accessor :quantity - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'cart_item_status' => :'cartItemStatus', - :'quantity' => :'quantity' - } - end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'cart_item_status' => :'CartItemStatus', - :'quantity' => :'Integer' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'cart_item_status' => :'cartItemStatus', + :'quantity' => :'quantity' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemOrderStatus` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'cart_item_status' => :'CartItemStatus', + :'quantity' => :'Integer' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemOrderStatus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'cart_item_status') - self.cart_item_status = attributes[:'cart_item_status'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemOrderStatus` initialize method" + end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemOrderStatus`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - cart_item_status == o.cart_item_status && - quantity == o.quantity - end + if attributes.key?(:'cart_item_status') + self.cart_item_status = attributes[:'cart_item_status'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [cart_item_status, quantity].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + cart_item_status == o.cart_item_status && + quantity == o.quantity + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [cart_item_status, quantity].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cart_item_patch.rb b/lib/PCP-server-Ruby-SDK/models/cart_item_patch.rb index 7d6641a..468112e 100644 --- a/lib/PCP-server-Ruby-SDK/models/cart_item_patch.rb +++ b/lib/PCP-server-Ruby-SDK/models/cart_item_patch.rb @@ -1,194 +1,197 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # This object contains information of all items in the cart. If a cart item is provided, the productPrice and quantity is required. + class CartItemPatch + attr_accessor :invoice_data + + attr_accessor :order_line_details + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'invoice_data' => :'invoiceData', + :'order_line_details' => :'orderLineDetails' + } + end -# This object contains information of all items in the cart. If a cart item is provided, the productPrice and quantity is required. -class CartItemPatch - attr_accessor :invoice_data - - attr_accessor :order_line_details + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'invoice_data' => :'invoiceData', - :'order_line_details' => :'orderLineDetails' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'invoice_data' => :'CartItemInvoiceData', + :'order_line_details' => :'OrderLineDetailsPatch' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'invoice_data' => :'CartItemInvoiceData', - :'order_line_details' => :'OrderLineDetailsPatch' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemPatch` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemPatch` initialize method" - end + if attributes.key?(:'invoice_data') + self.invoice_data = attributes[:'invoice_data'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'order_line_details') + self.order_line_details = attributes[:'order_line_details'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'invoice_data') - self.invoice_data = attributes[:'invoice_data'] - end - if attributes.key?(:'order_line_details') - self.order_line_details = attributes[:'order_line_details'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - invoice_data == o.invoice_data && - order_line_details == o.order_line_details - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + invoice_data == o.invoice_data && + order_line_details == o.order_line_details + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [invoice_data, order_line_details].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [invoice_data, order_line_details].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cart_item_result.rb b/lib/PCP-server-Ruby-SDK/models/cart_item_result.rb index 6091cae..48263bb 100644 --- a/lib/PCP-server-Ruby-SDK/models/cart_item_result.rb +++ b/lib/PCP-server-Ruby-SDK/models/cart_item_result.rb @@ -1,194 +1,197 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # This object contains information of all items in the cart. If a cart item is provided, the productPrice and quantity is required. + class CartItemResult + attr_accessor :invoice_data + + attr_accessor :order_line_details + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'invoice_data' => :'invoiceData', + :'order_line_details' => :'orderLineDetails' + } + end -# This object contains information of all items in the cart. If a cart item is provided, the productPrice and quantity is required. -class CartItemResult - attr_accessor :invoice_data - - attr_accessor :order_line_details + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'invoice_data' => :'invoiceData', - :'order_line_details' => :'orderLineDetails' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'invoice_data' => :'CartItemInvoiceData', + :'order_line_details' => :'OrderLineDetailsResult' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'invoice_data' => :'CartItemInvoiceData', - :'order_line_details' => :'OrderLineDetailsResult' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemResult` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CartItemResult` initialize method" - end + if attributes.key?(:'invoice_data') + self.invoice_data = attributes[:'invoice_data'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CartItemResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'order_line_details') + self.order_line_details = attributes[:'order_line_details'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'invoice_data') - self.invoice_data = attributes[:'invoice_data'] - end - if attributes.key?(:'order_line_details') - self.order_line_details = attributes[:'order_line_details'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - invoice_data == o.invoice_data && - order_line_details == o.order_line_details - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + invoice_data == o.invoice_data && + order_line_details == o.order_line_details + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [invoice_data, order_line_details].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [invoice_data, order_line_details].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/cart_item_status.rb b/lib/PCP-server-Ruby-SDK/models/cart_item_status.rb index 4d9729c..95603d0 100644 --- a/lib/PCP-server-Ruby-SDK/models/cart_item_status.rb +++ b/lib/PCP-server-Ruby-SDK/models/cart_item_status.rb @@ -1,30 +1,33 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CartItemStatus + ORDERED = "ORDERED".freeze + DELIVERED = "DELIVERED".freeze + CANCELLED = "CANCELLED".freeze + RETURNED = "RETURNED".freeze + WAITING_FOR_PAYMENT = "WAITING_FOR_PAYMENT".freeze -class CartItemStatus - ORDERED = "ORDERED".freeze - DELIVERED = "DELIVERED".freeze - CANCELLED = "CANCELLED".freeze - RETURNED = "RETURNED".freeze - WAITING_FOR_PAYMENT = "WAITING_FOR_PAYMENT".freeze + def self.all_vars + @all_vars ||= [ORDERED, DELIVERED, CANCELLED, RETURNED, WAITING_FOR_PAYMENT].freeze + end - def self.all_vars - @all_vars ||= [ORDERED, DELIVERED, CANCELLED, RETURNED, WAITING_FOR_PAYMENT].freeze - end - - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if CartItemStatus.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #CartItemStatus" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if CartItemStatus.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #CartItemStatus" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/checkout_references.rb b/lib/PCP-server-Ruby-SDK/models/checkout_references.rb index 8b8fe04..d90ad95 100644 --- a/lib/PCP-server-Ruby-SDK/models/checkout_references.rb +++ b/lib/PCP-server-Ruby-SDK/models/checkout_references.rb @@ -3,194 +3,198 @@ require 'time' # Object containing all details that are linked to the Checkout. -class CheckoutReferences - # Unique reference of the Checkout that is also returned for reporting and reconciliation purposes. - attr_accessor :merchant_reference - - # Optional parameter to define the shop or touchpoint where a sale has been realized (e.g. different stores). - attr_accessor :merchant_shop_reference - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'merchant_reference' => :'merchantReference', - :'merchant_shop_reference' => :'merchantShopReference' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'merchant_reference' => :'String', - :'merchant_shop_reference' => :'String' - } - end +module PCPServerSDK + module Models + class CheckoutReferences + # Unique reference of the Checkout that is also returned for reporting and reconciliation purposes. + attr_accessor :merchant_reference + + # Optional parameter to define the shop or touchpoint where a sale has been realized (e.g. different stores). + attr_accessor :merchant_shop_reference + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'merchant_reference' => :'merchantReference', + :'merchant_shop_reference' => :'merchantShopReference' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CheckoutReferences` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'merchant_reference' => :'String', + :'merchant_shop_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CheckoutReferences`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CheckoutReferences` initialize method" + end - if attributes.key?(:'merchant_shop_reference') - self.merchant_shop_reference = attributes[:'merchant_shop_reference'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CheckoutReferences`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - merchant_reference == o.merchant_reference && - merchant_shop_reference == o.merchant_shop_reference - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'merchant_shop_reference') + self.merchant_shop_reference = attributes[:'merchant_shop_reference'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [merchant_reference, merchant_shop_reference].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + merchant_reference == o.merchant_reference && + merchant_shop_reference == o.merchant_shop_reference + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [merchant_reference, merchant_shop_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/checkout_response.rb b/lib/PCP-server-Ruby-SDK/models/checkout_response.rb index 6d0216f..7ae5380 100644 --- a/lib/PCP-server-Ruby-SDK/models/checkout_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/checkout_response.rb @@ -1,325 +1,328 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # The Checkout corresponds to the order of the WL API. We do not take additionalInput from the WL API. We have no shipping and use deliveryAddress instead of address. + class CheckoutResponse + # reference to the Commerce Case. + attr_accessor :commerce_case_id -# The Checkout corresponds to the order of the WL API. We do not take additionalInput from the WL API. We have no shipping and use deliveryAddress instead of address. -class CheckoutResponse - # reference to the Commerce Case. - attr_accessor :commerce_case_id + # reference to the Checkout. + attr_accessor :checkout_id - # reference to the Checkout. - attr_accessor :checkout_id + # Unique identifier for the customer. + attr_accessor :merchant_customer_id - # Unique identifier for the customer. - attr_accessor :merchant_customer_id + attr_accessor :amount_of_money - attr_accessor :amount_of_money + attr_accessor :references - attr_accessor :references + attr_accessor :shipping - attr_accessor :shipping + attr_accessor :shopping_cart - attr_accessor :shopping_cart + attr_accessor :payment_executions - attr_accessor :payment_executions + attr_accessor :checkout_status - attr_accessor :checkout_status + attr_accessor :status_output - attr_accessor :status_output + attr_accessor :payment_information - attr_accessor :payment_information + # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. + attr_accessor :creation_date_time - # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. - attr_accessor :creation_date_time + attr_accessor :allowed_payment_actions - attr_accessor :allowed_payment_actions + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'commerce_case_id' => :'commerceCaseId', + :'checkout_id' => :'checkoutId', + :'merchant_customer_id' => :'merchantCustomerId', + :'amount_of_money' => :'amountOfMoney', + :'references' => :'references', + :'shipping' => :'shipping', + :'shopping_cart' => :'shoppingCart', + :'payment_executions' => :'paymentExecutions', + :'checkout_status' => :'checkoutStatus', + :'status_output' => :'statusOutput', + :'payment_information' => :'paymentInformation', + :'creation_date_time' => :'creationDateTime', + :'allowed_payment_actions' => :'allowedPaymentActions' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'commerce_case_id' => :'commerceCaseId', - :'checkout_id' => :'checkoutId', - :'merchant_customer_id' => :'merchantCustomerId', - :'amount_of_money' => :'amountOfMoney', - :'references' => :'references', - :'shipping' => :'shipping', - :'shopping_cart' => :'shoppingCart', - :'payment_executions' => :'paymentExecutions', - :'checkout_status' => :'checkoutStatus', - :'status_output' => :'statusOutput', - :'payment_information' => :'paymentInformation', - :'creation_date_time' => :'creationDateTime', - :'allowed_payment_actions' => :'allowedPaymentActions' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'commerce_case_id' => :'String', + :'checkout_id' => :'String', + :'merchant_customer_id' => :'String', + :'amount_of_money' => :'AmountOfMoney', + :'references' => :'CheckoutReferences', + :'shipping' => :'Shipping', + :'shopping_cart' => :'ShoppingCartResult', + :'payment_executions' => :'Array', + :'checkout_status' => :'StatusCheckout', + :'status_output' => :'StatusOutput', + :'payment_information' => :'Array', + :'creation_date_time' => :'Time', + :'allowed_payment_actions' => :'Array' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'commerce_case_id' => :'String', - :'checkout_id' => :'String', - :'merchant_customer_id' => :'String', - :'amount_of_money' => :'AmountOfMoney', - :'references' => :'CheckoutReferences', - :'shipping' => :'Shipping', - :'shopping_cart' => :'ShoppingCartResult', - :'payment_executions' => :'Array', - :'checkout_status' => :'StatusCheckout', - :'status_output' => :'StatusOutput', - :'payment_information' => :'Array', - :'creation_date_time' => :'Time', - :'allowed_payment_actions' => :'Array' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CheckoutResponse` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CheckoutResponse` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CheckoutResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CheckoutResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'commerce_case_id') - self.commerce_case_id = attributes[:'commerce_case_id'] - end + if attributes.key?(:'commerce_case_id') + self.commerce_case_id = attributes[:'commerce_case_id'] + end - if attributes.key?(:'checkout_id') - self.checkout_id = attributes[:'checkout_id'] - end + if attributes.key?(:'checkout_id') + self.checkout_id = attributes[:'checkout_id'] + end - if attributes.key?(:'merchant_customer_id') - self.merchant_customer_id = attributes[:'merchant_customer_id'] - end + if attributes.key?(:'merchant_customer_id') + self.merchant_customer_id = attributes[:'merchant_customer_id'] + end - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - if attributes.key?(:'references') - self.references = attributes[:'references'] - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - if attributes.key?(:'shipping') - self.shipping = attributes[:'shipping'] - end + if attributes.key?(:'shipping') + self.shipping = attributes[:'shipping'] + end - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end - if attributes.key?(:'payment_executions') - if (value = attributes[:'payment_executions']).is_a?(Array) - self.payment_executions = value - end - end + if attributes.key?(:'payment_executions') + if (value = attributes[:'payment_executions']).is_a?(Array) + self.payment_executions = value + end + end - if attributes.key?(:'checkout_status') - self.checkout_status = attributes[:'checkout_status'] - end + if attributes.key?(:'checkout_status') + self.checkout_status = attributes[:'checkout_status'] + end - if attributes.key?(:'status_output') - self.status_output = attributes[:'status_output'] - end + if attributes.key?(:'status_output') + self.status_output = attributes[:'status_output'] + end - if attributes.key?(:'payment_information') - if (value = attributes[:'payment_information']).is_a?(Array) - self.payment_information = value - end - end + if attributes.key?(:'payment_information') + if (value = attributes[:'payment_information']).is_a?(Array) + self.payment_information = value + end + end - if attributes.key?(:'creation_date_time') - self.creation_date_time = attributes[:'creation_date_time'] - end + if attributes.key?(:'creation_date_time') + self.creation_date_time = attributes[:'creation_date_time'] + end - if attributes.key?(:'allowed_payment_actions') - if (value = attributes[:'allowed_payment_actions']).is_a?(Array) - self.allowed_payment_actions = value + if attributes.key?(:'allowed_payment_actions') + if (value = attributes[:'allowed_payment_actions']).is_a?(Array) + self.allowed_payment_actions = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - commerce_case_id == o.commerce_case_id && - checkout_id == o.checkout_id && - merchant_customer_id == o.merchant_customer_id && - amount_of_money == o.amount_of_money && - references == o.references && - shipping == o.shipping && - shopping_cart == o.shopping_cart && - payment_executions == o.payment_executions && - checkout_status == o.checkout_status && - status_output == o.status_output && - payment_information == o.payment_information && - creation_date_time == o.creation_date_time && - allowed_payment_actions == o.allowed_payment_actions - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + commerce_case_id == o.commerce_case_id && + checkout_id == o.checkout_id && + merchant_customer_id == o.merchant_customer_id && + amount_of_money == o.amount_of_money && + references == o.references && + shipping == o.shipping && + shopping_cart == o.shopping_cart && + payment_executions == o.payment_executions && + checkout_status == o.checkout_status && + status_output == o.status_output && + payment_information == o.payment_information && + creation_date_time == o.creation_date_time && + allowed_payment_actions == o.allowed_payment_actions + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [commerce_case_id, checkout_id, merchant_customer_id, amount_of_money, references, shipping, shopping_cart, payment_executions, checkout_status, status_output, payment_information, creation_date_time, allowed_payment_actions].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [commerce_case_id, checkout_id, merchant_customer_id, amount_of_money, references, shipping, shopping_cart, payment_executions, checkout_status, status_output, payment_information, creation_date_time, allowed_payment_actions].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/checkouts_response.rb b/lib/PCP-server-Ruby-SDK/models/checkouts_response.rb index 5f8212c..b8cb067 100644 --- a/lib/PCP-server-Ruby-SDK/models/checkouts_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/checkouts_response.rb @@ -1,198 +1,201 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object that holds the number of found Checkouts and the requested page of Checkouts + class CheckoutsResponse + # Number of found Checkouts + attr_accessor :number_of_checkouts + + # List of Checkouts + attr_accessor :checkouts + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'number_of_checkouts' => :'numberOfCheckouts', + :'checkouts' => :'checkouts' + } + end -# Object that holds the number of found Checkouts and the requested page of Checkouts -class CheckoutsResponse - # Number of found Checkouts - attr_accessor :number_of_checkouts - - # List of Checkouts - attr_accessor :checkouts + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'number_of_checkouts' => :'numberOfCheckouts', - :'checkouts' => :'checkouts' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'number_of_checkouts' => :'Integer', + :'checkouts' => :'Array' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'number_of_checkouts' => :'Integer', - :'checkouts' => :'Array' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CheckoutsResponse` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CheckoutsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CheckoutsResponse` initialize method" - end + if attributes.key?(:'number_of_checkouts') + self.number_of_checkouts = attributes[:'number_of_checkouts'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CheckoutsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'checkouts') + if (value = attributes[:'checkouts']).is_a?(Array) + self.checkouts = value + end + end end - h[k.to_sym] = v - } - - if attributes.key?(:'number_of_checkouts') - self.number_of_checkouts = attributes[:'number_of_checkouts'] - end - if attributes.key?(:'checkouts') - if (value = attributes[:'checkouts']).is_a?(Array) - self.checkouts = value + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + number_of_checkouts == o.number_of_checkouts && + checkouts == o.checkouts end - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - number_of_checkouts == o.number_of_checkouts && - checkouts == o.checkouts - end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [number_of_checkouts, checkouts].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [number_of_checkouts, checkouts].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/commerce_case_response.rb b/lib/PCP-server-Ruby-SDK/models/commerce_case_response.rb index 87e4fd8..b9e54c7 100644 --- a/lib/PCP-server-Ruby-SDK/models/commerce_case_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/commerce_case_response.rb @@ -1,225 +1,228 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CommerceCaseResponse + # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. + attr_accessor :merchant_reference + + # Unique ID reference of the Commerce Case. It can be used to add additional Checkouts to the Commerce Case. + attr_accessor :commerce_case_id + + attr_accessor :customer + + attr_accessor :checkouts + + # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. + attr_accessor :creation_date_time + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'merchant_reference' => :'merchantReference', + :'commerce_case_id' => :'commerceCaseId', + :'customer' => :'customer', + :'checkouts' => :'checkouts', + :'creation_date_time' => :'creationDateTime' + } + end -class CommerceCaseResponse - # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. - attr_accessor :merchant_reference - - # Unique ID reference of the Commerce Case. It can be used to add additional Checkouts to the Commerce Case. - attr_accessor :commerce_case_id + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :customer + # Attribute type mapping. + def self.openapi_types + { + :'merchant_reference' => :'String', + :'commerce_case_id' => :'String', + :'customer' => :'Customer', + :'checkouts' => :'Array', + :'creation_date_time' => :'Time' + } + end - attr_accessor :checkouts + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. - attr_accessor :creation_date_time + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CommerceCaseResponse` initialize method" + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'merchant_reference' => :'merchantReference', - :'commerce_case_id' => :'commerceCaseId', - :'customer' => :'customer', - :'checkouts' => :'checkouts', - :'creation_date_time' => :'creationDateTime' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CommerceCaseResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + end - # Attribute type mapping. - def self.openapi_types - { - :'merchant_reference' => :'String', - :'commerce_case_id' => :'String', - :'customer' => :'Customer', - :'checkouts' => :'Array', - :'creation_date_time' => :'Time' - } - end + if attributes.key?(:'commerce_case_id') + self.commerce_case_id = attributes[:'commerce_case_id'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CommerceCaseResponse` initialize method" - end + if attributes.key?(:'checkouts') + if (value = attributes[:'checkouts']).is_a?(Array) + self.checkouts = value + end + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CommerceCaseResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'creation_date_time') + self.creation_date_time = attributes[:'creation_date_time'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - end - if attributes.key?(:'commerce_case_id') - self.commerce_case_id = attributes[:'commerce_case_id'] - end - - if attributes.key?(:'customer') - self.customer = attributes[:'customer'] - end - - if attributes.key?(:'checkouts') - if (value = attributes[:'checkouts']).is_a?(Array) - self.checkouts = value + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + merchant_reference == o.merchant_reference && + commerce_case_id == o.commerce_case_id && + customer == o.customer && + checkouts == o.checkouts && + creation_date_time == o.creation_date_time end - end - if attributes.key?(:'creation_date_time') - self.creation_date_time = attributes[:'creation_date_time'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - merchant_reference == o.merchant_reference && - commerce_case_id == o.commerce_case_id && - customer == o.customer && - checkouts == o.checkouts && - creation_date_time == o.creation_date_time - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [merchant_reference, commerce_case_id, customer, checkouts, creation_date_time].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [merchant_reference, commerce_case_id, customer, checkouts, creation_date_time].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/company_information.rb b/lib/PCP-server-Ruby-SDK/models/company_information.rb index cfba47b..2c8e66f 100644 --- a/lib/PCP-server-Ruby-SDK/models/company_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/company_information.rb @@ -1,186 +1,189 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing details of the company. + class CompanyInformation + # Name of company from a customer perspective + attr_accessor :name + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name' + } + end -# Object containing details of the company. -class CompanyInformation - # Name of company from a customer perspective - attr_accessor :name - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'name' => :'name' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'name' => :'String' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CompanyInformation` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CompanyInformation` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CompanyInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CompanyInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'name') + self.name = attributes[:'name'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'name') - self.name = attributes[:'name'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - name == o.name - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [name].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [name].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/complete_financing_payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/complete_financing_payment_method_specific_input.rb index d0f33ee..13394d7 100644 --- a/lib/PCP-server-Ruby-SDK/models/complete_financing_payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/complete_financing_payment_method_specific_input.rb @@ -1,205 +1,208 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # To complete the Payment the completeFinancingMethodSpecificInput has to be provided. At the moment it is only available for PAYONE Secured Installment (paymentProductId 3391). + class CompleteFinancingPaymentMethodSpecificInput + # Payment product identifier. Currently supported payment methods: * 3391 - PAYONE Secured Installment + attr_accessor :payment_product_id + + # * true = the payment requires approval before the funds will be captured using the Approve payment or Capture payment API * false = the payment does not require approval, and the funds will be captured automatically If the parameter is not provided in the request, the default value will be true + attr_accessor :requires_approval + + attr_accessor :payment_product3391_specific_input + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'requires_approval' => :'requiresApproval', + :'payment_product3391_specific_input' => :'paymentProduct3391SpecificInput' + } + end -# To complete the Payment the completeFinancingMethodSpecificInput has to be provided. At the moment it is only available for PAYONE Secured Installment (paymentProductId 3391). -class CompleteFinancingPaymentMethodSpecificInput - # Payment product identifier. Currently supported payment methods: * 3391 - PAYONE Secured Installment - attr_accessor :payment_product_id - - # * true = the payment requires approval before the funds will be captured using the Approve payment or Capture payment API * false = the payment does not require approval, and the funds will be captured automatically If the parameter is not provided in the request, the default value will be true - attr_accessor :requires_approval + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :payment_product3391_specific_input + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'requires_approval' => :'Boolean', + :'payment_product3391_specific_input' => :'PaymentProduct3391SpecificInput' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'requires_approval' => :'requiresApproval', - :'payment_product3391_specific_input' => :'paymentProduct3391SpecificInput' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CompleteFinancingPaymentMethodSpecificInput` initialize method" + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'requires_approval' => :'Boolean', - :'payment_product3391_specific_input' => :'PaymentProduct3391SpecificInput' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CompleteFinancingPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CompleteFinancingPaymentMethodSpecificInput` initialize method" - end + if attributes.key?(:'requires_approval') + self.requires_approval = attributes[:'requires_approval'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CompleteFinancingPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_product3391_specific_input') + self.payment_product3391_specific_input = attributes[:'payment_product3391_specific_input'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end - - if attributes.key?(:'requires_approval') - self.requires_approval = attributes[:'requires_approval'] - end - - if attributes.key?(:'payment_product3391_specific_input') - self.payment_product3391_specific_input = attributes[:'payment_product3391_specific_input'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - requires_approval == o.requires_approval && - payment_product3391_specific_input == o.payment_product3391_specific_input - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + requires_approval == o.requires_approval && + payment_product3391_specific_input == o.payment_product3391_specific_input + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, requires_approval, payment_product3391_specific_input].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, requires_approval, payment_product3391_specific_input].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/complete_payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/complete_payment_method_specific_input.rb index d7c5ebb..6746298 100644 --- a/lib/PCP-server-Ruby-SDK/models/complete_payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/complete_payment_method_specific_input.rb @@ -1,185 +1,188 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # To complete the Order the completePaymentMethodSpecificInput has to be provided, containing the selected installmentOptionId as well as the the bankAccountInformation of the customer. + class CompletePaymentMethodSpecificInput + attr_accessor :payment_product3391_specific_input + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product3391_specific_input' => :'paymentProduct3391SpecificInput' + } + end -# To complete the Order the completePaymentMethodSpecificInput has to be provided, containing the selected installmentOptionId as well as the the bankAccountInformation of the customer. -class CompletePaymentMethodSpecificInput - attr_accessor :payment_product3391_specific_input - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product3391_specific_input' => :'paymentProduct3391SpecificInput' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_product3391_specific_input' => :'PaymentProduct3391SpecificInput' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_product3391_specific_input' => :'PaymentProduct3391SpecificInput' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CompletePaymentMethodSpecificInput` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CompletePaymentMethodSpecificInput` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CompletePaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CompletePaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_product3391_specific_input') + self.payment_product3391_specific_input = attributes[:'payment_product3391_specific_input'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'payment_product3391_specific_input') - self.payment_product3391_specific_input = attributes[:'payment_product3391_specific_input'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product3391_specific_input == o.payment_product3391_specific_input - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product3391_specific_input == o.payment_product3391_specific_input + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product3391_specific_input].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product3391_specific_input].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/complete_payment_request.rb b/lib/PCP-server-Ruby-SDK/models/complete_payment_request.rb index 90c4828..8d90b0c 100644 --- a/lib/PCP-server-Ruby-SDK/models/complete_payment_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/complete_payment_request.rb @@ -1,203 +1,206 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # The Complete request is the last step to finalize the initially created Payment. It requires the completeFinancingPaymentMethodSpecificInput. The data for the order object should not differ from the previously provided information in Commerce Case, Checkout and Payment, but will not be validated nor automatically loaded from the Commerce Platform. + class CompletePaymentRequest + attr_accessor :financing_payment_method_specific_input + + attr_accessor :order + + attr_accessor :device + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'financing_payment_method_specific_input' => :'financingPaymentMethodSpecificInput', + :'order' => :'order', + :'device' => :'device' + } + end -# The Complete request is the last step to finalize the initially created Payment. It requires the completeFinancingPaymentMethodSpecificInput. The data for the order object should not differ from the previously provided information in Commerce Case, Checkout and Payment, but will not be validated nor automatically loaded from the Commerce Platform. -class CompletePaymentRequest - attr_accessor :financing_payment_method_specific_input - - attr_accessor :order + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :device + # Attribute type mapping. + def self.openapi_types + { + :'financing_payment_method_specific_input' => :'CompleteFinancingPaymentMethodSpecificInput', + :'order' => :'Order', + :'device' => :'CustomerDevice' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'financing_payment_method_specific_input' => :'financingPaymentMethodSpecificInput', - :'order' => :'order', - :'device' => :'device' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CompletePaymentRequest` initialize method" + end - # Attribute type mapping. - def self.openapi_types - { - :'financing_payment_method_specific_input' => :'CompleteFinancingPaymentMethodSpecificInput', - :'order' => :'Order', - :'device' => :'CustomerDevice' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CompletePaymentRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'financing_payment_method_specific_input') + self.financing_payment_method_specific_input = attributes[:'financing_payment_method_specific_input'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CompletePaymentRequest` initialize method" - end + if attributes.key?(:'order') + self.order = attributes[:'order'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CompletePaymentRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'device') + self.device = attributes[:'device'] + end + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + financing_payment_method_specific_input == o.financing_payment_method_specific_input && + order == o.order && + device == o.device end - h[k.to_sym] = v - } - - if attributes.key?(:'financing_payment_method_specific_input') - self.financing_payment_method_specific_input = attributes[:'financing_payment_method_specific_input'] - end - - if attributes.key?(:'order') - self.order = attributes[:'order'] - end - - if attributes.key?(:'device') - self.device = attributes[:'device'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - financing_payment_method_specific_input == o.financing_payment_method_specific_input && - order == o.order && - device == o.device - end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [financing_payment_method_specific_input, order, device].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [financing_payment_method_specific_input, order, device].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/complete_payment_response.rb b/lib/PCP-server-Ruby-SDK/models/complete_payment_response.rb index 6304c58..a451a81 100644 --- a/lib/PCP-server-Ruby-SDK/models/complete_payment_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/complete_payment_response.rb @@ -1,202 +1,205 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CompletePaymentResponse + attr_accessor :creation_output + + attr_accessor :merchant_action + + attr_accessor :payment + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'creation_output' => :'creationOutput', + :'merchant_action' => :'merchantAction', + :'payment' => :'payment' + } + end -class CompletePaymentResponse - attr_accessor :creation_output - - attr_accessor :merchant_action + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :payment + # Attribute type mapping. + def self.openapi_types + { + :'creation_output' => :'PaymentCreationOutput', + :'merchant_action' => :'MerchantAction', + :'payment' => :'PaymentResponse' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'creation_output' => :'creationOutput', - :'merchant_action' => :'merchantAction', - :'payment' => :'payment' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CompletePaymentResponse` initialize method" + end - # Attribute type mapping. - def self.openapi_types - { - :'creation_output' => :'PaymentCreationOutput', - :'merchant_action' => :'MerchantAction', - :'payment' => :'PaymentResponse' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CompletePaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'creation_output') + self.creation_output = attributes[:'creation_output'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CompletePaymentResponse` initialize method" - end + if attributes.key?(:'merchant_action') + self.merchant_action = attributes[:'merchant_action'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CompletePaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment') + self.payment = attributes[:'payment'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'creation_output') - self.creation_output = attributes[:'creation_output'] - end - - if attributes.key?(:'merchant_action') - self.merchant_action = attributes[:'merchant_action'] - end - - if attributes.key?(:'payment') - self.payment = attributes[:'payment'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - creation_output == o.creation_output && - merchant_action == o.merchant_action && - payment == o.payment - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + creation_output == o.creation_output && + merchant_action == o.merchant_action && + payment == o.payment + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [creation_output, merchant_action, payment].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [creation_output, merchant_action, payment].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/contact_details.rb b/lib/PCP-server-Ruby-SDK/models/contact_details.rb index 76b73af..0e1b63e 100644 --- a/lib/PCP-server-Ruby-SDK/models/contact_details.rb +++ b/lib/PCP-server-Ruby-SDK/models/contact_details.rb @@ -1,196 +1,199 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing contact details like email address and phone number. + class ContactDetails + # Email address of the customer + attr_accessor :email_address + + # Phone number of the customer + attr_accessor :phone_number + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'email_address' => :'emailAddress', + :'phone_number' => :'phoneNumber' + } + end -# Object containing contact details like email address and phone number. -class ContactDetails - # Email address of the customer - attr_accessor :email_address - - # Phone number of the customer - attr_accessor :phone_number + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'email_address' => :'emailAddress', - :'phone_number' => :'phoneNumber' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'email_address' => :'String', + :'phone_number' => :'String' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'email_address' => :'String', - :'phone_number' => :'String' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ContactDetails` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ContactDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ContactDetails` initialize method" - end + if attributes.key?(:'email_address') + self.email_address = attributes[:'email_address'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ContactDetails`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'email_address') - self.email_address = attributes[:'email_address'] - end - if attributes.key?(:'phone_number') - self.phone_number = attributes[:'phone_number'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - email_address == o.email_address && - phone_number == o.phone_number - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + email_address == o.email_address && + phone_number == o.phone_number + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [email_address, phone_number].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [email_address, phone_number].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/create_checkout_request.rb b/lib/PCP-server-Ruby-SDK/models/create_checkout_request.rb index 29bfa1b..f4594e4 100644 --- a/lib/PCP-server-Ruby-SDK/models/create_checkout_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/create_checkout_request.rb @@ -1,244 +1,246 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Request to create a Checkout for a Commerce Case. The payment for the Checkout can be directly executed if autoExecuteOrder = true. In this case, the paymentMethodSpecificInput must be provided and only a full order is possible. If no amountOfMoney is provided, the platform will calculate the respective Checkout amount based on the cartItem productPrice and quantity. In case of a payment error, the payment can be retried by providing the respective commerceCaseId and checkoutId to the the Order or Payment Execution endpoint. + class CreateCheckoutRequest + attr_accessor :amount_of_money + attr_accessor :references -# Request to create a Checkout for a Commerce Case. The payment for the Checkout can be directly executed if autoExecuteOrder = true. In this case, the paymentMethodSpecificInput must be provided and only a full order is possible. If no amountOfMoney is provided, the platform will calculate the respective Checkout amount based on the cartItem productPrice and quantity. In case of a payment error, the payment can be retried by providing the respective commerceCaseId and checkoutId to the the Order or Payment Execution endpoint. -class CreateCheckoutRequest - attr_accessor :amount_of_money + attr_accessor :shipping - attr_accessor :references + attr_accessor :shopping_cart - attr_accessor :shipping + attr_accessor :order_request - attr_accessor :shopping_cart + # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. + attr_accessor :creation_date_time - attr_accessor :order_request + # Set this flag to directly execute a payment when creating a Commerce Case or Checkout. If the value for autoExecuteOrder is set to true, the paymentMethodSpecificInput for the order is mandatory and has to be provided. The autoExecuteOrder can only be used for orderType = full. If no shoppingCart information has been provided, a Payment Execution will be created instead of an Order. As a consequence, only Payment Execution endpoints can be used. + attr_accessor :auto_execute_order - # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. - attr_accessor :creation_date_time - - # Set this flag to directly execute a payment when creating a Commerce Case or Checkout. If the value for autoExecuteOrder is set to true, the paymentMethodSpecificInput for the order is mandatory and has to be provided. The autoExecuteOrder can only be used for orderType = full. If no shoppingCart information has been provided, a Payment Execution will be created instead of an Order. As a consequence, only Payment Execution endpoints can be used. - attr_accessor :auto_execute_order - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'references' => :'references', - :'shipping' => :'shipping', - :'shopping_cart' => :'shoppingCart', - :'order_request' => :'orderRequest', - :'creation_date_time' => :'creationDateTime', - :'auto_execute_order' => :'autoExecuteOrder' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'references' => :'CheckoutReferences', - :'shipping' => :'Shipping', - :'shopping_cart' => :'ShoppingCartInput', - :'order_request' => :'OrderRequest', - :'creation_date_time' => :'Time', - :'auto_execute_order' => :'Boolean' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'references' => :'references', + :'shipping' => :'shipping', + :'shopping_cart' => :'shoppingCart', + :'order_request' => :'orderRequest', + :'creation_date_time' => :'creationDateTime', + :'auto_execute_order' => :'autoExecuteOrder' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCheckoutRequest` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'references' => :'CheckoutReferences', + :'shipping' => :'Shipping', + :'shopping_cart' => :'ShoppingCartInput', + :'order_request' => :'OrderRequest', + :'creation_date_time' => :'Time', + :'auto_execute_order' => :'Boolean' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCheckoutRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCheckoutRequest` initialize method" + end - if attributes.key?(:'references') - self.references = attributes[:'references'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCheckoutRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'shipping') - self.shipping = attributes[:'shipping'] - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - if attributes.key?(:'order_request') - self.order_request = attributes[:'order_request'] - end + if attributes.key?(:'shipping') + self.shipping = attributes[:'shipping'] + end - if attributes.key?(:'creation_date_time') - self.creation_date_time = attributes[:'creation_date_time'] - end + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end - if attributes.key?(:'auto_execute_order') - self.auto_execute_order = attributes[:'auto_execute_order'] - else - self.auto_execute_order = false - end - end + if attributes.key?(:'order_request') + self.order_request = attributes[:'order_request'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - references == o.references && - shipping == o.shipping && - shopping_cart == o.shopping_cart && - order_request == o.order_request && - creation_date_time == o.creation_date_time && - auto_execute_order == o.auto_execute_order - end + if attributes.key?(:'creation_date_time') + self.creation_date_time = attributes[:'creation_date_time'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'auto_execute_order') + self.auto_execute_order = attributes[:'auto_execute_order'] + else + self.auto_execute_order = false + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, references, shipping, shopping_cart, order_request, creation_date_time, auto_execute_order].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + references == o.references && + shipping == o.shipping && + shopping_cart == o.shopping_cart && + order_request == o.order_request && + creation_date_time == o.creation_date_time && + auto_execute_order == o.auto_execute_order + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, references, shipping, shopping_cart, order_request, creation_date_time, auto_execute_order].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/create_checkout_response.rb b/lib/PCP-server-Ruby-SDK/models/create_checkout_response.rb index 80ff161..0d3f5cb 100644 --- a/lib/PCP-server-Ruby-SDK/models/create_checkout_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/create_checkout_response.rb @@ -1,310 +1,313 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing the reference of the Checkout for following requests. + class CreateCheckoutResponse + # Reference to the Checkout. Can be used for following requests to get and update the Checkout and execute the payment. + attr_accessor :checkout_id -# Object containing the reference of the Checkout for following requests. -class CreateCheckoutResponse - # Reference to the Checkout. Can be used for following requests to get and update the Checkout and execute the payment. - attr_accessor :checkout_id + attr_accessor :shopping_cart - attr_accessor :shopping_cart + attr_accessor :payment_response - attr_accessor :payment_response + attr_accessor :error_response - attr_accessor :error_response + attr_accessor :amount_of_money - attr_accessor :amount_of_money + attr_accessor :references - attr_accessor :references + attr_accessor :shipping - attr_accessor :shipping + attr_accessor :payment_execution - attr_accessor :payment_execution + attr_accessor :checkout_status - attr_accessor :checkout_status + attr_accessor :status_output - attr_accessor :status_output + # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. + attr_accessor :creation_date_time - # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. - attr_accessor :creation_date_time + attr_accessor :allowed_payment_actions - attr_accessor :allowed_payment_actions + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'checkout_id' => :'checkoutId', - :'shopping_cart' => :'shoppingCart', - :'payment_response' => :'paymentResponse', - :'error_response' => :'errorResponse', - :'amount_of_money' => :'amountOfMoney', - :'references' => :'references', - :'shipping' => :'shipping', - :'payment_execution' => :'paymentExecution', - :'checkout_status' => :'checkoutStatus', - :'status_output' => :'statusOutput', - :'creation_date_time' => :'creationDateTime', - :'allowed_payment_actions' => :'allowedPaymentActions' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'checkout_id' => :'checkoutId', + :'shopping_cart' => :'shoppingCart', + :'payment_response' => :'paymentResponse', + :'error_response' => :'errorResponse', + :'amount_of_money' => :'amountOfMoney', + :'references' => :'references', + :'shipping' => :'shipping', + :'payment_execution' => :'paymentExecution', + :'checkout_status' => :'checkoutStatus', + :'status_output' => :'statusOutput', + :'creation_date_time' => :'creationDateTime', + :'allowed_payment_actions' => :'allowedPaymentActions' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'checkout_id' => :'String', - :'shopping_cart' => :'ShoppingCartResult', - :'payment_response' => :'CreatePaymentResponse', - :'error_response' => :'ErrorResponse', - :'amount_of_money' => :'AmountOfMoney', - :'references' => :'CheckoutReferences', - :'shipping' => :'Shipping', - :'payment_execution' => :'PaymentExecution', - :'checkout_status' => :'StatusCheckout', - :'status_output' => :'StatusOutput', - :'creation_date_time' => :'Time', - :'allowed_payment_actions' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'checkout_id' => :'String', + :'shopping_cart' => :'ShoppingCartResult', + :'payment_response' => :'CreatePaymentResponse', + :'error_response' => :'ErrorResponse', + :'amount_of_money' => :'AmountOfMoney', + :'references' => :'CheckoutReferences', + :'shipping' => :'Shipping', + :'payment_execution' => :'PaymentExecution', + :'checkout_status' => :'StatusCheckout', + :'status_output' => :'StatusOutput', + :'creation_date_time' => :'Time', + :'allowed_payment_actions' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCheckoutResponse` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCheckoutResponse` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCheckoutResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCheckoutResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'checkout_id') - self.checkout_id = attributes[:'checkout_id'] - end + if attributes.key?(:'checkout_id') + self.checkout_id = attributes[:'checkout_id'] + end - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end - if attributes.key?(:'payment_response') - self.payment_response = attributes[:'payment_response'] - end + if attributes.key?(:'payment_response') + self.payment_response = attributes[:'payment_response'] + end - if attributes.key?(:'error_response') - self.error_response = attributes[:'error_response'] - end + if attributes.key?(:'error_response') + self.error_response = attributes[:'error_response'] + end - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - if attributes.key?(:'references') - self.references = attributes[:'references'] - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - if attributes.key?(:'shipping') - self.shipping = attributes[:'shipping'] - end + if attributes.key?(:'shipping') + self.shipping = attributes[:'shipping'] + end - if attributes.key?(:'payment_execution') - self.payment_execution = attributes[:'payment_execution'] - end + if attributes.key?(:'payment_execution') + self.payment_execution = attributes[:'payment_execution'] + end - if attributes.key?(:'checkout_status') - self.checkout_status = attributes[:'checkout_status'] - end + if attributes.key?(:'checkout_status') + self.checkout_status = attributes[:'checkout_status'] + end - if attributes.key?(:'status_output') - self.status_output = attributes[:'status_output'] - end + if attributes.key?(:'status_output') + self.status_output = attributes[:'status_output'] + end - if attributes.key?(:'creation_date_time') - self.creation_date_time = attributes[:'creation_date_time'] - end + if attributes.key?(:'creation_date_time') + self.creation_date_time = attributes[:'creation_date_time'] + end - if attributes.key?(:'allowed_payment_actions') - if (value = attributes[:'allowed_payment_actions']).is_a?(Array) - self.allowed_payment_actions = value + if attributes.key?(:'allowed_payment_actions') + if (value = attributes[:'allowed_payment_actions']).is_a?(Array) + self.allowed_payment_actions = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - checkout_id == o.checkout_id && - shopping_cart == o.shopping_cart && - payment_response == o.payment_response && - error_response == o.error_response && - amount_of_money == o.amount_of_money && - references == o.references && - shipping == o.shipping && - payment_execution == o.payment_execution && - checkout_status == o.checkout_status && - status_output == o.status_output && - creation_date_time == o.creation_date_time && - allowed_payment_actions == o.allowed_payment_actions - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + checkout_id == o.checkout_id && + shopping_cart == o.shopping_cart && + payment_response == o.payment_response && + error_response == o.error_response && + amount_of_money == o.amount_of_money && + references == o.references && + shipping == o.shipping && + payment_execution == o.payment_execution && + checkout_status == o.checkout_status && + status_output == o.status_output && + creation_date_time == o.creation_date_time && + allowed_payment_actions == o.allowed_payment_actions + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [checkout_id, shopping_cart, payment_response, error_response, amount_of_money, references, shipping, payment_execution, checkout_status, status_output, creation_date_time, allowed_payment_actions].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [checkout_id, shopping_cart, payment_response, error_response, amount_of_money, references, shipping, payment_execution, checkout_status, status_output, creation_date_time, allowed_payment_actions].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/create_commerce_case_request.rb b/lib/PCP-server-Ruby-SDK/models/create_commerce_case_request.rb index 1e65d58..0f26680 100644 --- a/lib/PCP-server-Ruby-SDK/models/create_commerce_case_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/create_commerce_case_request.rb @@ -1,213 +1,216 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class CreateCommerceCaseRequest + # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. + attr_accessor :merchant_reference + + attr_accessor :customer + + # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. + attr_accessor :creation_date_time + + attr_accessor :checkout + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'merchant_reference' => :'merchantReference', + :'customer' => :'customer', + :'creation_date_time' => :'creationDateTime', + :'checkout' => :'checkout' + } + end -class CreateCommerceCaseRequest - # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. - attr_accessor :merchant_reference - - attr_accessor :customer + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. - attr_accessor :creation_date_time + # Attribute type mapping. + def self.openapi_types + { + :'merchant_reference' => :'String', + :'customer' => :'Customer', + :'creation_date_time' => :'Time', + :'checkout' => :'CreateCheckoutRequest' + } + end - attr_accessor :checkout + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'merchant_reference' => :'merchantReference', - :'customer' => :'customer', - :'creation_date_time' => :'creationDateTime', - :'checkout' => :'checkout' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCommerceCaseRequest` initialize method" + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCommerceCaseRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Attribute type mapping. - def self.openapi_types - { - :'merchant_reference' => :'String', - :'customer' => :'Customer', - :'creation_date_time' => :'Time', - :'checkout' => :'CreateCheckoutRequest' - } - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCommerceCaseRequest` initialize method" - end + if attributes.key?(:'creation_date_time') + self.creation_date_time = attributes[:'creation_date_time'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCommerceCaseRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'checkout') + self.checkout = attributes[:'checkout'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - end - - if attributes.key?(:'customer') - self.customer = attributes[:'customer'] - end - - if attributes.key?(:'creation_date_time') - self.creation_date_time = attributes[:'creation_date_time'] - end - - if attributes.key?(:'checkout') - self.checkout = attributes[:'checkout'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - merchant_reference == o.merchant_reference && - customer == o.customer && - creation_date_time == o.creation_date_time && - checkout == o.checkout - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + merchant_reference == o.merchant_reference && + customer == o.customer && + creation_date_time == o.creation_date_time && + checkout == o.checkout + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [merchant_reference, customer, creation_date_time, checkout].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [merchant_reference, customer, creation_date_time, checkout].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/create_commerce_case_response.rb b/lib/PCP-server-Ruby-SDK/models/create_commerce_case_response.rb index 10e4dc5..901430f 100644 --- a/lib/PCP-server-Ruby-SDK/models/create_commerce_case_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/create_commerce_case_response.rb @@ -1,224 +1,227 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # The response contains references to the created Commerce case and the Checkout. It also contains the payment response if the flag 'autoExecuteOrder' was set to true. + class CreateCommerceCaseResponse + # Unique ID of the Commerce Case. It can used to add additional Checkouts to the Commerce Case. + attr_accessor :commerce_case_id + + # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. + attr_accessor :merchant_reference + + attr_accessor :customer + + attr_accessor :checkout + + # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. + attr_accessor :creation_date_time + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'commerce_case_id' => :'commerceCaseId', + :'merchant_reference' => :'merchantReference', + :'customer' => :'customer', + :'checkout' => :'checkout', + :'creation_date_time' => :'creationDateTime' + } + end -# The response contains references to the created Commerce case and the Checkout. It also contains the payment response if the flag 'autoExecuteOrder' was set to true. -class CreateCommerceCaseResponse - # Unique ID of the Commerce Case. It can used to add additional Checkouts to the Commerce Case. - attr_accessor :commerce_case_id - - # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. - attr_accessor :merchant_reference + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :customer + # Attribute type mapping. + def self.openapi_types + { + :'commerce_case_id' => :'String', + :'merchant_reference' => :'String', + :'customer' => :'Customer', + :'checkout' => :'CreateCheckoutResponse', + :'creation_date_time' => :'Time' + } + end - attr_accessor :checkout + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Creation date and time of the Checkout in RFC3339 format. It can either be provided in the request or otherwise will be automatically set to the time when the request CreateCommerceCase was received. Response values will always be in UTC time, but when providing this field in the requests, the time offset can have different formats. Accepted formats are: * YYYY-MM-DD'T'HH:mm:ss'Z' * YYYY-MM-DD'T'HH:mm:ss+XX:XX * YYYY-MM-DD'T'HH:mm:ss-XX:XX * YYYY-MM-DD'T'HH:mm'Z' * YYYY-MM-DD'T'HH:mm+XX:XX * YYYY-MM-DD'T'HH:mm-XX:XX All other formats may be ignored by the system. - attr_accessor :creation_date_time + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCommerceCaseResponse` initialize method" + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'commerce_case_id' => :'commerceCaseId', - :'merchant_reference' => :'merchantReference', - :'customer' => :'customer', - :'checkout' => :'checkout', - :'creation_date_time' => :'creationDateTime' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCommerceCaseResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + if attributes.key?(:'commerce_case_id') + self.commerce_case_id = attributes[:'commerce_case_id'] + end - # Attribute type mapping. - def self.openapi_types - { - :'commerce_case_id' => :'String', - :'merchant_reference' => :'String', - :'customer' => :'Customer', - :'checkout' => :'CreateCheckoutResponse', - :'creation_date_time' => :'Time' - } - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CreateCommerceCaseResponse` initialize method" - end + if attributes.key?(:'checkout') + self.checkout = attributes[:'checkout'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CreateCommerceCaseResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'creation_date_time') + self.creation_date_time = attributes[:'creation_date_time'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'commerce_case_id') - self.commerce_case_id = attributes[:'commerce_case_id'] - end - - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - end - - if attributes.key?(:'customer') - self.customer = attributes[:'customer'] - end - - if attributes.key?(:'checkout') - self.checkout = attributes[:'checkout'] - end - if attributes.key?(:'creation_date_time') - self.creation_date_time = attributes[:'creation_date_time'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - commerce_case_id == o.commerce_case_id && - merchant_reference == o.merchant_reference && - customer == o.customer && - checkout == o.checkout && - creation_date_time == o.creation_date_time - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + commerce_case_id == o.commerce_case_id && + merchant_reference == o.merchant_reference && + customer == o.customer && + checkout == o.checkout && + creation_date_time == o.creation_date_time + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [commerce_case_id, merchant_reference, customer, checkout, creation_date_time].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [commerce_case_id, merchant_reference, customer, checkout, creation_date_time].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/create_payment_response.rb b/lib/PCP-server-Ruby-SDK/models/create_payment_response.rb index e2704f5..5283709 100644 --- a/lib/PCP-server-Ruby-SDK/models/create_payment_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/create_payment_response.rb @@ -1,213 +1,216 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing details on the created payment it has directly be executed. + class CreatePaymentResponse + attr_accessor :creation_output + + attr_accessor :merchant_action + + attr_accessor :payment + + # reference to the paymentExecution. + attr_accessor :payment_execution_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'creation_output' => :'creationOutput', + :'merchant_action' => :'merchantAction', + :'payment' => :'payment', + :'payment_execution_id' => :'paymentExecutionId' + } + end -# Object containing details on the created payment it has directly be executed. -class CreatePaymentResponse - attr_accessor :creation_output - - attr_accessor :merchant_action + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :payment + # Attribute type mapping. + def self.openapi_types + { + :'creation_output' => :'PaymentCreationOutput', + :'merchant_action' => :'MerchantAction', + :'payment' => :'PaymentResponse', + :'payment_execution_id' => :'String' + } + end - # reference to the paymentExecution. - attr_accessor :payment_execution_id + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'creation_output' => :'creationOutput', - :'merchant_action' => :'merchantAction', - :'payment' => :'payment', - :'payment_execution_id' => :'paymentExecutionId' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CreatePaymentResponse` initialize method" + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CreatePaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Attribute type mapping. - def self.openapi_types - { - :'creation_output' => :'PaymentCreationOutput', - :'merchant_action' => :'MerchantAction', - :'payment' => :'PaymentResponse', - :'payment_execution_id' => :'String' - } - end + if attributes.key?(:'creation_output') + self.creation_output = attributes[:'creation_output'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'merchant_action') + self.merchant_action = attributes[:'merchant_action'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CreatePaymentResponse` initialize method" - end + if attributes.key?(:'payment') + self.payment = attributes[:'payment'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CreatePaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_execution_id') + self.payment_execution_id = attributes[:'payment_execution_id'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'creation_output') - self.creation_output = attributes[:'creation_output'] - end - - if attributes.key?(:'merchant_action') - self.merchant_action = attributes[:'merchant_action'] - end - - if attributes.key?(:'payment') - self.payment = attributes[:'payment'] - end - - if attributes.key?(:'payment_execution_id') - self.payment_execution_id = attributes[:'payment_execution_id'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - creation_output == o.creation_output && - merchant_action == o.merchant_action && - payment == o.payment && - payment_execution_id == o.payment_execution_id - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + creation_output == o.creation_output && + merchant_action == o.merchant_action && + payment == o.payment && + payment_execution_id == o.payment_execution_id + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [creation_output, merchant_action, payment, payment_execution_id].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [creation_output, merchant_action, payment, payment_execution_id].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/customer.rb b/lib/PCP-server-Ruby-SDK/models/customer.rb index e9e4b40..5786ffa 100644 --- a/lib/PCP-server-Ruby-SDK/models/customer.rb +++ b/lib/PCP-server-Ruby-SDK/models/customer.rb @@ -1,252 +1,255 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing the details of a customer. + class Customer + attr_accessor :company_information + + # Unique identifier for the customer. + attr_accessor :merchant_customer_id + + attr_accessor :billing_address + + attr_accessor :contact_details + + # Fiscal registration number of the customer or the tax registration number of the company for a business customer. Please find below specifics per country: * Brazil - Consumer (CPF) with a length of 11 digits * Brazil - Company (CNPJ) with a length of 14 digits * Denmark - Consumer (CPR-nummer or personnummer) with a length of 10 digits * Finland - Consumer (Finnish: henkilötunnus (abbreviated as HETU), Swedish: personbeteckning) with a length of 11 characters * Norway - Consumer (fødselsnummer) with a length of 11 digits * Sweden - Consumer (personnummer) with a length of 10 or 12 digits + attr_accessor :fiscal_number + + # Business relation to the customer. Possible values: * B2C - Indicates business to consumer * B2B - Indicates business to business Mandatory for the the following payment methods: * 3390 - PAYONE Secured Invoice * 3391 - PAYONE Secured Installment * 3392 - PAYONE Secured Direct Debit + attr_accessor :business_relation + + # The locale that the customer should be addressed in (for 3rd parties). Note: Only the language code is supported. + attr_accessor :locale + + attr_accessor :personal_information + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'company_information' => :'companyInformation', + :'merchant_customer_id' => :'merchantCustomerId', + :'billing_address' => :'billingAddress', + :'contact_details' => :'contactDetails', + :'fiscal_number' => :'fiscalNumber', + :'business_relation' => :'businessRelation', + :'locale' => :'locale', + :'personal_information' => :'personalInformation' + } + end -# Object containing the details of a customer. -class Customer - attr_accessor :company_information - - # Unique identifier for the customer. - attr_accessor :merchant_customer_id + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :billing_address + # Attribute type mapping. + def self.openapi_types + { + :'company_information' => :'CompanyInformation', + :'merchant_customer_id' => :'String', + :'billing_address' => :'Address', + :'contact_details' => :'ContactDetails', + :'fiscal_number' => :'String', + :'business_relation' => :'String', + :'locale' => :'String', + :'personal_information' => :'PersonalInformation' + } + end - attr_accessor :contact_details + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Fiscal registration number of the customer or the tax registration number of the company for a business customer. Please find below specifics per country: * Brazil - Consumer (CPF) with a length of 11 digits * Brazil - Company (CNPJ) with a length of 14 digits * Denmark - Consumer (CPR-nummer or personnummer) with a length of 10 digits * Finland - Consumer (Finnish: henkilötunnus (abbreviated as HETU), Swedish: personbeteckning) with a length of 11 characters * Norway - Consumer (fødselsnummer) with a length of 11 digits * Sweden - Consumer (personnummer) with a length of 10 or 12 digits - attr_accessor :fiscal_number + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Customer` initialize method" + end - # Business relation to the customer. Possible values: * B2C - Indicates business to consumer * B2B - Indicates business to business Mandatory for the the following payment methods: * 3390 - PAYONE Secured Invoice * 3391 - PAYONE Secured Installment * 3392 - PAYONE Secured Direct Debit - attr_accessor :business_relation + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Customer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # The locale that the customer should be addressed in (for 3rd parties). Note: Only the language code is supported. - attr_accessor :locale + if attributes.key?(:'company_information') + self.company_information = attributes[:'company_information'] + end - attr_accessor :personal_information + if attributes.key?(:'merchant_customer_id') + self.merchant_customer_id = attributes[:'merchant_customer_id'] + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'company_information' => :'companyInformation', - :'merchant_customer_id' => :'merchantCustomerId', - :'billing_address' => :'billingAddress', - :'contact_details' => :'contactDetails', - :'fiscal_number' => :'fiscalNumber', - :'business_relation' => :'businessRelation', - :'locale' => :'locale', - :'personal_information' => :'personalInformation' - } - end + if attributes.key?(:'billing_address') + self.billing_address = attributes[:'billing_address'] + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + if attributes.key?(:'contact_details') + self.contact_details = attributes[:'contact_details'] + end - # Attribute type mapping. - def self.openapi_types - { - :'company_information' => :'CompanyInformation', - :'merchant_customer_id' => :'String', - :'billing_address' => :'Address', - :'contact_details' => :'ContactDetails', - :'fiscal_number' => :'String', - :'business_relation' => :'String', - :'locale' => :'String', - :'personal_information' => :'PersonalInformation' - } - end + if attributes.key?(:'fiscal_number') + self.fiscal_number = attributes[:'fiscal_number'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'business_relation') + self.business_relation = attributes[:'business_relation'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Customer` initialize method" - end + if attributes.key?(:'locale') + self.locale = attributes[:'locale'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Customer`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'personal_information') + self.personal_information = attributes[:'personal_information'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'company_information') - self.company_information = attributes[:'company_information'] - end - - if attributes.key?(:'merchant_customer_id') - self.merchant_customer_id = attributes[:'merchant_customer_id'] - end - - if attributes.key?(:'billing_address') - self.billing_address = attributes[:'billing_address'] - end - - if attributes.key?(:'contact_details') - self.contact_details = attributes[:'contact_details'] - end - - if attributes.key?(:'fiscal_number') - self.fiscal_number = attributes[:'fiscal_number'] - end - - if attributes.key?(:'business_relation') - self.business_relation = attributes[:'business_relation'] - end - - if attributes.key?(:'locale') - self.locale = attributes[:'locale'] - end - - if attributes.key?(:'personal_information') - self.personal_information = attributes[:'personal_information'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - company_information == o.company_information && - merchant_customer_id == o.merchant_customer_id && - billing_address == o.billing_address && - contact_details == o.contact_details && - fiscal_number == o.fiscal_number && - business_relation == o.business_relation && - locale == o.locale && - personal_information == o.personal_information - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + company_information == o.company_information && + merchant_customer_id == o.merchant_customer_id && + billing_address == o.billing_address && + contact_details == o.contact_details && + fiscal_number == o.fiscal_number && + business_relation == o.business_relation && + locale == o.locale && + personal_information == o.personal_information + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [company_information, merchant_customer_id, billing_address, contact_details, fiscal_number, business_relation, locale, personal_information].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [company_information, merchant_customer_id, billing_address, contact_details, fiscal_number, business_relation, locale, personal_information].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/customer_device.rb b/lib/PCP-server-Ruby-SDK/models/customer_device.rb index 57bc75a..a2b111e 100644 --- a/lib/PCP-server-Ruby-SDK/models/customer_device.rb +++ b/lib/PCP-server-Ruby-SDK/models/customer_device.rb @@ -1,196 +1,199 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Object containing information about the device of the end customer. + class CustomerDevice + # The IP address of the customer client from the HTTP Headers. + attr_accessor :ip_address + + # Tokenized representation of the end customers device. For example used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :device_token + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'ip_address' => :'ipAddress', + :'device_token' => :'deviceToken' + } + end -# Object containing information about the device of the end customer. -class CustomerDevice - # The IP address of the customer client from the HTTP Headers. - attr_accessor :ip_address - - # Tokenized representation of the end customers device. For example used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :device_token + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'ip_address' => :'ipAddress', - :'device_token' => :'deviceToken' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'ip_address' => :'String', + :'device_token' => :'String' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'ip_address' => :'String', - :'device_token' => :'String' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `CustomerDevice` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `CustomerDevice`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `CustomerDevice` initialize method" - end + if attributes.key?(:'ip_address') + self.ip_address = attributes[:'ip_address'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `CustomerDevice`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'device_token') + self.device_token = attributes[:'device_token'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'ip_address') - self.ip_address = attributes[:'ip_address'] - end - if attributes.key?(:'device_token') - self.device_token = attributes[:'device_token'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - ip_address == o.ip_address && - device_token == o.device_token - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + ip_address == o.ip_address && + device_token == o.device_token + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [ip_address, device_token].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [ip_address, device_token].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/deliver_item.rb b/lib/PCP-server-Ruby-SDK/models/deliver_item.rb index 88f12a2..8c84326 100644 --- a/lib/PCP-server-Ruby-SDK/models/deliver_item.rb +++ b/lib/PCP-server-Ruby-SDK/models/deliver_item.rb @@ -1,199 +1,202 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class DeliverItem + # Id of the item to deliver. + attr_accessor :id + + # Quantity of the units being delivered, should be greater than zero Note: Must not be all spaces or all zeros + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'quantity' => :'quantity' + } + end -class DeliverItem - # Id of the item to deliver. - attr_accessor :id - - # Quantity of the units being delivered, should be greater than zero Note: Must not be all spaces or all zeros - attr_accessor :quantity - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'id' => :'id', - :'quantity' => :'quantity' - } - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'quantity' => :'Integer' + } + end - # Attribute type mapping. - def self.openapi_types - { - :'id' => :'String', - :'quantity' => :'Integer' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DeliverItem` initialize method" + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `DeliverItem` initialize method" - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DeliverItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `DeliverItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end end - h[k.to_sym] = v - } - - if attributes.key?(:'id') - self.id = attributes[:'id'] - else - self.id = nil - end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - else - self.quantity = nil - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - id == o.id && - quantity == o.quantity - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + quantity == o.quantity + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [id, quantity].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, quantity].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/deliver_request.rb b/lib/PCP-server-Ruby-SDK/models/deliver_request.rb index a35d8f4..48ef19b 100644 --- a/lib/PCP-server-Ruby-SDK/models/deliver_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/deliver_request.rb @@ -3,237 +3,242 @@ require 'time' # Request to mark items of the respective Checkout as delivered and to automatically execute a Capture. A Deliver can be created for a full or the partial ShoppingCart of the Checkout. The platform will automatically calculate the respective amount to trigger the Capture. For a partial Deliver a list of items must be provided. The item details for the Capture will be automatically loaded from the Checkout. The cancellationReason must be provided if deliverType is set to PARTIAL and isFinal is set to true for BNPL payment methods (paymentProductId 3390, 3391 and 3392). For other payment methods the cancellationReason is not mandatory in this case but can be used for reporting and reconciliation purposes. -class DeliverRequest - attr_accessor :deliver_type - - # This property indicates whether this will be the final operation. For deliverType FULL, it is always the final operation. If deliverType PARTIAL is provided and the property is set to true, the remaining amount of the items will be cancelled and the items are marked as CANCELLED. - attr_accessor :is_final - - attr_accessor :cancellation_reason - - attr_accessor :deliver_items - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values +module PCPServerSDK + module Models + class DeliverRequest + attr_accessor :deliver_type + + # This property indicates whether this will be the final operation. For deliverType FULL, it is always the final operation. If deliverType PARTIAL is provided and the property is set to true, the remaining amount of the items will be cancelled and the items are marked as CANCELLED. + attr_accessor :is_final + + attr_accessor :cancellation_reason + + attr_accessor :deliver_items + + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'deliver_type' => :'deliverType', - :'is_final' => :'isFinal', - :'cancellation_reason' => :'cancellationReason', - :'deliver_items' => :'deliverItems' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'deliver_type' => :'deliverType', + :'is_final' => :'isFinal', + :'cancellation_reason' => :'cancellationReason', + :'deliver_items' => :'deliverItems' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'deliver_type' => :'DeliverType', - :'is_final' => :'Boolean', - :'cancellation_reason' => :'CancellationReason', - :'deliver_items' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'deliver_type' => :'DeliverType', + :'is_final' => :'Boolean', + :'cancellation_reason' => :'CancellationReason', + :'deliver_items' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `DeliverRequest` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DeliverRequest` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `DeliverRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DeliverRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'deliver_type') - self.deliver_type = attributes[:'deliver_type'] - end + if attributes.key?(:'deliver_type') + self.deliver_type = attributes[:'deliver_type'] + end - if attributes.key?(:'is_final') - self.is_final = attributes[:'is_final'] - else - self.is_final = false - end + if attributes.key?(:'is_final') + self.is_final = attributes[:'is_final'] + else + self.is_final = false + end - if attributes.key?(:'cancellation_reason') - self.cancellation_reason = attributes[:'cancellation_reason'] - end + if attributes.key?(:'cancellation_reason') + self.cancellation_reason = attributes[:'cancellation_reason'] + end - if attributes.key?(:'deliver_items') - if (value = attributes[:'deliver_items']).is_a?(Array) - self.deliver_items = value + if attributes.key?(:'deliver_items') + if (value = attributes[:'deliver_items']).is_a?(Array) + self.deliver_items = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - deliver_type == o.deliver_type && - is_final == o.is_final && - cancellation_reason == o.cancellation_reason && - deliver_items == o.deliver_items - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + deliver_type == o.deliver_type && + is_final == o.is_final && + cancellation_reason == o.cancellation_reason && + deliver_items == o.deliver_items + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [deliver_type, is_final, cancellation_reason, deliver_items].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [deliver_type, is_final, cancellation_reason, deliver_items].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/deliver_response.rb b/lib/PCP-server-Ruby-SDK/models/deliver_response.rb index 1344eb5..1dec8b0 100644 --- a/lib/PCP-server-Ruby-SDK/models/deliver_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/deliver_response.rb @@ -2,192 +2,196 @@ require 'date' require 'time' -class DeliverResponse - attr_accessor :capture_payment_response +module PCPServerSDK + module Models + class DeliverResponse + attr_accessor :capture_payment_response + + attr_accessor :shopping_cart + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'capture_payment_response' => :'capturePaymentResponse', + :'shopping_cart' => :'shoppingCart' + } + end - attr_accessor :shopping_cart + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'capture_payment_response' => :'capturePaymentResponse', - :'shopping_cart' => :'shoppingCart' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'capture_payment_response' => :'CapturePaymentResponse', + :'shopping_cart' => :'ShoppingCartResult' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'capture_payment_response' => :'CapturePaymentResponse', - :'shopping_cart' => :'ShoppingCartResult' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DeliverResponse` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DeliverResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `DeliverResponse` initialize method" - end + if attributes.key?(:'capture_payment_response') + self.capture_payment_response = attributes[:'capture_payment_response'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `DeliverResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'capture_payment_response') - self.capture_payment_response = attributes[:'capture_payment_response'] - end - - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - capture_payment_response == o.capture_payment_response && - shopping_cart == o.shopping_cart - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + capture_payment_response == o.capture_payment_response && + shopping_cart == o.shopping_cart + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [capture_payment_response, shopping_cart].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [capture_payment_response, shopping_cart].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/deliver_type.rb b/lib/PCP-server-Ruby-SDK/models/deliver_type.rb index fcfa58b..db830f0 100644 --- a/lib/PCP-server-Ruby-SDK/models/deliver_type.rb +++ b/lib/PCP-server-Ruby-SDK/models/deliver_type.rb @@ -3,26 +3,30 @@ require 'time' -class DeliverType - FULL = "FULL".freeze - PARTIAL = "PARTIAL".freeze +module PCPServerSDK + module Models + class DeliverType + FULL = "FULL".freeze + PARTIAL = "PARTIAL".freeze - def self.all_vars - @all_vars ||= [FULL, PARTIAL].freeze - end + def self.all_vars + @all_vars ||= [FULL, PARTIAL].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if DeliverType.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #DeliverType" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if DeliverType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #DeliverType" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/delivery_information.rb b/lib/PCP-server-Ruby-SDK/models/delivery_information.rb index ba8e028..5df6236 100644 --- a/lib/PCP-server-Ruby-SDK/models/delivery_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/delivery_information.rb @@ -3,186 +3,190 @@ require 'time' # Delivery object contains additional information about the delivery/shipment, which is the basis for the Capture. The amountOfMoney in the cartItem will not be used in the request. -class DeliveryInformation - # Items delivered. - attr_accessor :items - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'items' => :'items' - } - end +module PCPServerSDK + module Models + class DeliveryInformation + # Items delivered. + attr_accessor :items + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'items' => :'items' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'items' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'items' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `DeliveryInformation` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DeliveryInformation` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `DeliveryInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DeliveryInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end end - h[k.to_sym] = v - } - if attributes.key?(:'items') - if (value = attributes[:'items']).is_a?(Array) - self.items = value + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + items == o.items end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - items == o.items - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [items].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [items].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/error_response.rb b/lib/PCP-server-Ruby-SDK/models/error_response.rb index e2ab0d5..7d76839 100644 --- a/lib/PCP-server-Ruby-SDK/models/error_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/error_response.rb @@ -2,195 +2,199 @@ require 'date' require 'time' -class ErrorResponse - # Unique reference of this error response for debugging purposes - attr_accessor :error_id - - attr_accessor :errors - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'error_id' => :'errorId', - :'errors' => :'errors' - } - end +module PCPServerSDK + module Models + class ErrorResponse + # Unique reference of this error response for debugging purposes + attr_accessor :error_id + + attr_accessor :errors + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'error_id' => :'errorId', + :'errors' => :'errors' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'error_id' => :'String', - :'errors' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'error_id' => :'String', + :'errors' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ErrorResponse` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ErrorResponse` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'error_id') - self.error_id = attributes[:'error_id'] - end + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end - if attributes.key?(:'errors') - if (value = attributes[:'errors']).is_a?(Array) - self.errors = value + if attributes.key?(:'errors') + if (value = attributes[:'errors']).is_a?(Array) + self.errors = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - error_id == o.error_id && - errors == o.errors - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + error_id == o.error_id && + errors == o.errors + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [error_id, errors].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [error_id, errors].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/extended_checkout_status.rb b/lib/PCP-server-Ruby-SDK/models/extended_checkout_status.rb index 6f6d1fb..42d7737 100644 --- a/lib/PCP-server-Ruby-SDK/models/extended_checkout_status.rb +++ b/lib/PCP-server-Ruby-SDK/models/extended_checkout_status.rb @@ -2,33 +2,37 @@ require 'date' require 'time' -class ExtendedCheckoutStatus - OPEN = "OPEN".freeze - DELETED = "DELETED".freeze - PENDING_COMPLETION = "PENDING_COMPLETION".freeze - COMPLETED = "COMPLETED".freeze - PARTIALLY_BILLED = "PARTIALLY_BILLED".freeze - BILLED = "BILLED".freeze - CHARGEBACKED = "CHARGEBACKED".freeze - PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED".freeze - REFUNDED = "REFUNDED".freeze +module PCPServerSDK + module Models + class ExtendedCheckoutStatus + OPEN = "OPEN".freeze + DELETED = "DELETED".freeze + PENDING_COMPLETION = "PENDING_COMPLETION".freeze + COMPLETED = "COMPLETED".freeze + PARTIALLY_BILLED = "PARTIALLY_BILLED".freeze + BILLED = "BILLED".freeze + CHARGEBACKED = "CHARGEBACKED".freeze + PARTIALLY_REFUNDED = "PARTIALLY_REFUNDED".freeze + REFUNDED = "REFUNDED".freeze - def self.all_vars - @all_vars ||= [OPEN, DELETED, PENDING_COMPLETION, COMPLETED, PARTIALLY_BILLED, BILLED, CHARGEBACKED, PARTIALLY_REFUNDED, REFUNDED].freeze - end + def self.all_vars + @all_vars ||= [OPEN, DELETED, PENDING_COMPLETION, COMPLETED, PARTIALLY_BILLED, BILLED, CHARGEBACKED, PARTIALLY_REFUNDED, REFUNDED].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if ExtendedCheckoutStatus.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #ExtendedCheckoutStatus" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ExtendedCheckoutStatus.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ExtendedCheckoutStatus" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_input.rb index 7c601d4..b983d14 100644 --- a/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_input.rb @@ -3,203 +3,207 @@ require 'time' # Object containing the specific input details for financing payment methods (Buy Now Pay Later) -class FinancingPaymentMethodSpecificInput - # Payment product identifier - please check product documentation for a full overview of possible values. Currently supported payment methods * 3390 - PAYONE Secured Invoice * 3391 - PAYONE Secured Installment * 3392 - PAYONE Secured Direct Debit - attr_accessor :payment_product_id - - # * true = the payment requires approval before the funds will be captured using the Approve payment or Capture payment API * false = the payment does not require approval, and the funds will be captured automatically If the parameter is not provided in the request, the default value will be true - attr_accessor :requires_approval - - attr_accessor :payment_product3392_specific_input - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'requires_approval' => :'requiresApproval', - :'payment_product3392_specific_input' => :'paymentProduct3392SpecificInput' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'requires_approval' => :'Boolean', - :'payment_product3392_specific_input' => :'PaymentProduct3392SpecificInput' - } - end +module PCPServerSDK + module Models + class FinancingPaymentMethodSpecificInput + # Payment product identifier - please check product documentation for a full overview of possible values. Currently supported payment methods * 3390 - PAYONE Secured Invoice * 3391 - PAYONE Secured Installment * 3392 - PAYONE Secured Direct Debit + attr_accessor :payment_product_id + + # * true = the payment requires approval before the funds will be captured using the Approve payment or Capture payment API * false = the payment does not require approval, and the funds will be captured automatically If the parameter is not provided in the request, the default value will be true + attr_accessor :requires_approval + + attr_accessor :payment_product3392_specific_input + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'requires_approval' => :'requiresApproval', + :'payment_product3392_specific_input' => :'paymentProduct3392SpecificInput' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `FinancingPaymentMethodSpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'requires_approval' => :'Boolean', + :'payment_product3392_specific_input' => :'PaymentProduct3392SpecificInput' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `FinancingPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `FinancingPaymentMethodSpecificInput` initialize method" + end - if attributes.key?(:'requires_approval') - self.requires_approval = attributes[:'requires_approval'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `FinancingPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'payment_product3392_specific_input') - self.payment_product3392_specific_input = attributes[:'payment_product3392_specific_input'] - end - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - requires_approval == o.requires_approval && - payment_product3392_specific_input == o.payment_product3392_specific_input - end + if attributes.key?(:'requires_approval') + self.requires_approval = attributes[:'requires_approval'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_product3392_specific_input') + self.payment_product3392_specific_input = attributes[:'payment_product3392_specific_input'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, requires_approval, payment_product3392_specific_input].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + requires_approval == o.requires_approval && + payment_product3392_specific_input == o.payment_product3392_specific_input + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, requires_approval, payment_product3392_specific_input].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_output.rb index 8176821..a67749d 100644 --- a/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/financing_payment_method_specific_output.rb @@ -3,193 +3,197 @@ require 'time' # Object containing the specific output details for financing payment methods (Buy Now Pay Later) -class FinancingPaymentMethodSpecificOutput - # Payment product identifier - please check product documentation for a full overview of possible values. Currently supported payment methods * 3390 - PAYONE Secured Invoice * 3391 - PAYONE Secured Installment * 3392 - PAYONE Secured Direct Debit - attr_accessor :payment_product_id - - attr_accessor :payment_product3391_specific_output - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'payment_product3391_specific_output' => :'paymentProduct3391SpecificOutput' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'payment_product3391_specific_output' => :'PaymentProduct3391SpecificOutput' - } - end +module PCPServerSDK + module Models + class FinancingPaymentMethodSpecificOutput + # Payment product identifier - please check product documentation for a full overview of possible values. Currently supported payment methods * 3390 - PAYONE Secured Invoice * 3391 - PAYONE Secured Installment * 3392 - PAYONE Secured Direct Debit + attr_accessor :payment_product_id + + attr_accessor :payment_product3391_specific_output + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'payment_product3391_specific_output' => :'paymentProduct3391SpecificOutput' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `FinancingPaymentMethodSpecificOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'payment_product3391_specific_output' => :'PaymentProduct3391SpecificOutput' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `FinancingPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `FinancingPaymentMethodSpecificOutput` initialize method" + end - if attributes.key?(:'payment_product3391_specific_output') - self.payment_product3391_specific_output = attributes[:'payment_product3391_specific_output'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `FinancingPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - payment_product3391_specific_output == o.payment_product3391_specific_output - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_product3391_specific_output') + self.payment_product3391_specific_output = attributes[:'payment_product3391_specific_output'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, payment_product3391_specific_output].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + payment_product3391_specific_output == o.payment_product3391_specific_output + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, payment_product3391_specific_output].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/installment_option.rb b/lib/PCP-server-Ruby-SDK/models/installment_option.rb index fc75117..5823117 100644 --- a/lib/PCP-server-Ruby-SDK/models/installment_option.rb +++ b/lib/PCP-server-Ruby-SDK/models/installment_option.rb @@ -2,282 +2,286 @@ require 'date' require 'time' -class InstallmentOption - # Installment option Identifier. Use this in the Complete Payment for the selected installment option. - attr_accessor :installment_option_id - - # The number of monthly payments for this installment. - attr_accessor :number_of_payments - - # Monthly rate amount. - attr_accessor :monthly_amount - - # Last rate amount. - attr_accessor :last_rate_amount - - # Effective interest amount in percent with two decimals. - attr_accessor :effective_interest_rate - - # Nominal interest amount in percent with two decimals. - attr_accessor :nominal_interest_rate - - # Total rate amount. - attr_accessor :total_amount - - # Due date of first rate. Format: YYYYMMDD - attr_accessor :first_rate_date - - # Link with credit information. - attr_accessor :credit_information - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'installment_option_id' => :'installmentOptionId', - :'number_of_payments' => :'numberOfPayments', - :'monthly_amount' => :'monthlyAmount', - :'last_rate_amount' => :'lastRateAmount', - :'effective_interest_rate' => :'effectiveInterestRate', - :'nominal_interest_rate' => :'nominalInterestRate', - :'total_amount' => :'totalAmount', - :'first_rate_date' => :'firstRateDate', - :'credit_information' => :'creditInformation' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'installment_option_id' => :'String', - :'number_of_payments' => :'Integer', - :'monthly_amount' => :'AmountOfMoney', - :'last_rate_amount' => :'AmountOfMoney', - :'effective_interest_rate' => :'Integer', - :'nominal_interest_rate' => :'Integer', - :'total_amount' => :'AmountOfMoney', - :'first_rate_date' => :'String', - :'credit_information' => :'LinkInformation' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end +module PCPServerSDK + module Models + class InstallmentOption + # Installment option Identifier. Use this in the Complete Payment for the selected installment option. + attr_accessor :installment_option_id + + # The number of monthly payments for this installment. + attr_accessor :number_of_payments + + # Monthly rate amount. + attr_accessor :monthly_amount + + # Last rate amount. + attr_accessor :last_rate_amount + + # Effective interest amount in percent with two decimals. + attr_accessor :effective_interest_rate + + # Nominal interest amount in percent with two decimals. + attr_accessor :nominal_interest_rate + + # Total rate amount. + attr_accessor :total_amount + + # Due date of first rate. Format: YYYYMMDD + attr_accessor :first_rate_date + + # Link with credit information. + attr_accessor :credit_information + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'installment_option_id' => :'installmentOptionId', + :'number_of_payments' => :'numberOfPayments', + :'monthly_amount' => :'monthlyAmount', + :'last_rate_amount' => :'lastRateAmount', + :'effective_interest_rate' => :'effectiveInterestRate', + :'nominal_interest_rate' => :'nominalInterestRate', + :'total_amount' => :'totalAmount', + :'first_rate_date' => :'firstRateDate', + :'credit_information' => :'creditInformation' + } + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `InstallmentOption` initialize method" - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `InstallmentOption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # Attribute type mapping. + def self.openapi_types + { + :'installment_option_id' => :'String', + :'number_of_payments' => :'Integer', + :'monthly_amount' => :'AmountOfMoney', + :'last_rate_amount' => :'AmountOfMoney', + :'effective_interest_rate' => :'Integer', + :'nominal_interest_rate' => :'Integer', + :'total_amount' => :'AmountOfMoney', + :'first_rate_date' => :'String', + :'credit_information' => :'LinkInformation' + } end - h[k.to_sym] = v - } - if attributes.key?(:'installment_option_id') - self.installment_option_id = attributes[:'installment_option_id'] - else - self.installment_option_id = nil - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - if attributes.key?(:'number_of_payments') - self.number_of_payments = attributes[:'number_of_payments'] - else - self.number_of_payments = nil - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `InstallmentOption` initialize method" + end - if attributes.key?(:'monthly_amount') - self.monthly_amount = attributes[:'monthly_amount'] - else - self.monthly_amount = nil - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `InstallmentOption`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'installment_option_id') + self.installment_option_id = attributes[:'installment_option_id'] + else + self.installment_option_id = nil + end - if attributes.key?(:'last_rate_amount') - self.last_rate_amount = attributes[:'last_rate_amount'] - else - self.last_rate_amount = nil - end + if attributes.key?(:'number_of_payments') + self.number_of_payments = attributes[:'number_of_payments'] + else + self.number_of_payments = nil + end - if attributes.key?(:'effective_interest_rate') - self.effective_interest_rate = attributes[:'effective_interest_rate'] - else - self.effective_interest_rate = nil - end + if attributes.key?(:'monthly_amount') + self.monthly_amount = attributes[:'monthly_amount'] + else + self.monthly_amount = nil + end - if attributes.key?(:'nominal_interest_rate') - self.nominal_interest_rate = attributes[:'nominal_interest_rate'] - else - self.nominal_interest_rate = nil - end + if attributes.key?(:'last_rate_amount') + self.last_rate_amount = attributes[:'last_rate_amount'] + else + self.last_rate_amount = nil + end - if attributes.key?(:'total_amount') - self.total_amount = attributes[:'total_amount'] - else - self.total_amount = nil - end + if attributes.key?(:'effective_interest_rate') + self.effective_interest_rate = attributes[:'effective_interest_rate'] + else + self.effective_interest_rate = nil + end - if attributes.key?(:'first_rate_date') - self.first_rate_date = attributes[:'first_rate_date'] - else - self.first_rate_date = nil - end + if attributes.key?(:'nominal_interest_rate') + self.nominal_interest_rate = attributes[:'nominal_interest_rate'] + else + self.nominal_interest_rate = nil + end - if attributes.key?(:'credit_information') - self.credit_information = attributes[:'credit_information'] - else - self.credit_information = nil - end - end + if attributes.key?(:'total_amount') + self.total_amount = attributes[:'total_amount'] + else + self.total_amount = nil + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - installment_option_id == o.installment_option_id && - number_of_payments == o.number_of_payments && - monthly_amount == o.monthly_amount && - last_rate_amount == o.last_rate_amount && - effective_interest_rate == o.effective_interest_rate && - nominal_interest_rate == o.nominal_interest_rate && - total_amount == o.total_amount && - first_rate_date == o.first_rate_date && - credit_information == o.credit_information - end + if attributes.key?(:'first_rate_date') + self.first_rate_date = attributes[:'first_rate_date'] + else + self.first_rate_date = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'credit_information') + self.credit_information = attributes[:'credit_information'] + else + self.credit_information = nil + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [installment_option_id, number_of_payments, monthly_amount, last_rate_amount, effective_interest_rate, nominal_interest_rate, total_amount, first_rate_date, credit_information].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + installment_option_id == o.installment_option_id && + number_of_payments == o.number_of_payments && + monthly_amount == o.monthly_amount && + last_rate_amount == o.last_rate_amount && + effective_interest_rate == o.effective_interest_rate && + nominal_interest_rate == o.nominal_interest_rate && + total_amount == o.total_amount && + first_rate_date == o.first_rate_date && + credit_information == o.credit_information + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [installment_option_id, number_of_payments, monthly_amount, last_rate_amount, effective_interest_rate, nominal_interest_rate, total_amount, first_rate_date, credit_information].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/link_information.rb b/lib/PCP-server-Ruby-SDK/models/link_information.rb index 8d469f2..641518f 100644 --- a/lib/PCP-server-Ruby-SDK/models/link_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/link_information.rb @@ -3,198 +3,202 @@ require 'time' # URL and content type information for an web resource. -class LinkInformation - # URL of link. - attr_accessor :href - - # Content type of linked data. - attr_accessor :type - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'href' => :'href', - :'type' => :'type' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'href' => :'String', - :'type' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end +module PCPServerSDK + module Models + class LinkInformation + # URL of link. + attr_accessor :href + + # Content type of linked data. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'href' => :'href', + :'type' => :'type' + } + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `LinkInformation` initialize method" - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `LinkInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # Attribute type mapping. + def self.openapi_types + { + :'href' => :'String', + :'type' => :'String' + } end - h[k.to_sym] = v - } - if attributes.key?(:'href') - self.href = attributes[:'href'] - else - self.href = nil - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - if attributes.key?(:'type') - self.type = attributes[:'type'] - else - self.type = nil - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `LinkInformation` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - href == o.href && - type == o.type - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `LinkInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'href') + self.href = attributes[:'href'] + else + self.href = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [href, type].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + href == o.href && + type == o.type + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [href, type].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/mandate_recurrence_type.rb b/lib/PCP-server-Ruby-SDK/models/mandate_recurrence_type.rb index 953d73c..0ce76a0 100644 --- a/lib/PCP-server-Ruby-SDK/models/mandate_recurrence_type.rb +++ b/lib/PCP-server-Ruby-SDK/models/mandate_recurrence_type.rb @@ -2,26 +2,30 @@ require 'date' require 'time' -class MandateRecurrenceType - UNIQUE = "UNIQUE".freeze - RECURRING = "RECURRING".freeze +module PCPServerSDK + module Models + class MandateRecurrenceType + UNIQUE = "UNIQUE".freeze + RECURRING = "RECURRING".freeze - def self.all_vars - @all_vars ||= [UNIQUE, RECURRING].freeze - end + def self.all_vars + @all_vars ||= [UNIQUE, RECURRING].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if MandateRecurrenceType.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #MandateRecurrenceType" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if MandateRecurrenceType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #MandateRecurrenceType" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/merchant_action.rb b/lib/PCP-server-Ruby-SDK/models/merchant_action.rb index 1b2ef67..deccb1c 100644 --- a/lib/PCP-server-Ruby-SDK/models/merchant_action.rb +++ b/lib/PCP-server-Ruby-SDK/models/merchant_action.rb @@ -3,193 +3,197 @@ require 'time' # Object that contains the action, including the needed data, that you should perform next, like showing instructions, showing the transaction results or redirect to a third party to complete the payment -class MerchantAction - # Action merchants needs to take in the online payment process. Possible values are: * REDIRECT - The customer needs to be redirected using the details found in redirectData * SHOW_FORM - The customer needs to be shown a form with the fields found in formFields. You can submit the data entered by the user in a Complete payment request. * SHOW_INSTRUCTIONS - The customer needs to be shown payment instruction using the details found in showData. Alternatively the instructions can be rendered by us using the instructionsRenderingData * SHOW_TRANSACTION_RESULTS - The customer needs to be shown the transaction results using the details found in showData. Alternatively the instructions can be rendered by us using the instructionsRenderingData * MOBILE_THREEDS_CHALLENGE - The customer needs to complete a challenge as part of the 3D Secure authentication inside your mobile app. The details contained in mobileThreeDSecureChallengeParameters need to be provided to the EMVco certified Mobile SDK as a challengeParameters object. * CALL_THIRD_PARTY - The merchant needs to call a third party using the data found in thirdPartyData - attr_accessor :action_type - - attr_accessor :redirect_data - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'action_type' => :'actionType', - :'redirect_data' => :'redirectData' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'action_type' => :'String', - :'redirect_data' => :'RedirectData' - } - end +module PCPServerSDK + module Models + class MerchantAction + # Action merchants needs to take in the online payment process. Possible values are: * REDIRECT - The customer needs to be redirected using the details found in redirectData * SHOW_FORM - The customer needs to be shown a form with the fields found in formFields. You can submit the data entered by the user in a Complete payment request. * SHOW_INSTRUCTIONS - The customer needs to be shown payment instruction using the details found in showData. Alternatively the instructions can be rendered by us using the instructionsRenderingData * SHOW_TRANSACTION_RESULTS - The customer needs to be shown the transaction results using the details found in showData. Alternatively the instructions can be rendered by us using the instructionsRenderingData * MOBILE_THREEDS_CHALLENGE - The customer needs to complete a challenge as part of the 3D Secure authentication inside your mobile app. The details contained in mobileThreeDSecureChallengeParameters need to be provided to the EMVco certified Mobile SDK as a challengeParameters object. * CALL_THIRD_PARTY - The merchant needs to call a third party using the data found in thirdPartyData + attr_accessor :action_type + + attr_accessor :redirect_data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'action_type' => :'actionType', + :'redirect_data' => :'redirectData' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `MerchantAction` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'action_type' => :'String', + :'redirect_data' => :'RedirectData' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `MerchantAction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'action_type') - self.action_type = attributes[:'action_type'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `MerchantAction` initialize method" + end - if attributes.key?(:'redirect_data') - self.redirect_data = attributes[:'redirect_data'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `MerchantAction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - action_type == o.action_type && - redirect_data == o.redirect_data - end + if attributes.key?(:'action_type') + self.action_type = attributes[:'action_type'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'redirect_data') + self.redirect_data = attributes[:'redirect_data'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [action_type, redirect_data].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + action_type == o.action_type && + redirect_data == o.redirect_data + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [action_type, redirect_data].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_input.rb index b645d32..b578f36 100644 --- a/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_input.rb @@ -3,254 +3,260 @@ require 'time' # Object containing the specific input details for mobile payments. -class MobilePaymentMethodSpecificInput - # Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id +module PCPServerSDK + module Models + class MobilePaymentMethodSpecificInput + # Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id - attr_accessor :authorization_mode + attr_accessor :authorization_mode - # The payment data if we will do the decryption of the encrypted payment data. Typically you'd use encryptedCustomerInput in the root of the create payment request to provide the encrypted payment data instead. - attr_accessor :encrypted_payment_data + # The payment data if we will do the decryption of the encrypted payment data. Typically you'd use encryptedCustomerInput in the root of the create payment request to provide the encrypted payment data instead. + attr_accessor :encrypted_payment_data - # Public Key Hash A unique identifier to retrieve key used by Apple to encrypt information. - attr_accessor :public_key_hash + # Public Key Hash A unique identifier to retrieve key used by Apple to encrypt information. + attr_accessor :public_key_hash - # Ephemeral Key A unique generated key used by Apple to encrypt data. - attr_accessor :ephemeral_key + # Ephemeral Key A unique generated key used by Apple to encrypt data. + attr_accessor :ephemeral_key - attr_accessor :payment_product302_specific_input + attr_accessor :payment_product302_specific_input - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'authorization_mode' => :'authorizationMode', - :'encrypted_payment_data' => :'encryptedPaymentData', - :'public_key_hash' => :'publicKeyHash', - :'ephemeral_key' => :'ephemeralKey', - :'payment_product302_specific_input' => :'paymentProduct302SpecificInput' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'authorization_mode' => :'AuthorizationMode', - :'encrypted_payment_data' => :'String', - :'public_key_hash' => :'String', - :'ephemeral_key' => :'String', - :'payment_product302_specific_input' => :'PaymentProduct320SpecificInput' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'authorization_mode' => :'authorizationMode', + :'encrypted_payment_data' => :'encryptedPaymentData', + :'public_key_hash' => :'publicKeyHash', + :'ephemeral_key' => :'ephemeralKey', + :'payment_product302_specific_input' => :'paymentProduct302SpecificInput' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `MobilePaymentMethodSpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'authorization_mode' => :'AuthorizationMode', + :'encrypted_payment_data' => :'String', + :'public_key_hash' => :'String', + :'ephemeral_key' => :'String', + :'payment_product302_specific_input' => :'PaymentProduct320SpecificInput' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `MobilePaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `MobilePaymentMethodSpecificInput` initialize method" + end - if attributes.key?(:'authorization_mode') - self.authorization_mode = attributes[:'authorization_mode'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `MobilePaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'encrypted_payment_data') - self.encrypted_payment_data = attributes[:'encrypted_payment_data'] - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - if attributes.key?(:'public_key_hash') - self.public_key_hash = attributes[:'public_key_hash'] - end + if attributes.key?(:'authorization_mode') + self.authorization_mode = attributes[:'authorization_mode'] + end - if attributes.key?(:'ephemeral_key') - self.ephemeral_key = attributes[:'ephemeral_key'] - end + if attributes.key?(:'encrypted_payment_data') + self.encrypted_payment_data = attributes[:'encrypted_payment_data'] + end - if attributes.key?(:'payment_product302_specific_input') - self.payment_product302_specific_input = attributes[:'payment_product302_specific_input'] - end - end + if attributes.key?(:'public_key_hash') + self.public_key_hash = attributes[:'public_key_hash'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - authorization_mode == o.authorization_mode && - encrypted_payment_data == o.encrypted_payment_data && - public_key_hash == o.public_key_hash && - ephemeral_key == o.ephemeral_key && - payment_product302_specific_input == o.payment_product302_specific_input - end + if attributes.key?(:'ephemeral_key') + self.ephemeral_key = attributes[:'ephemeral_key'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_product302_specific_input') + self.payment_product302_specific_input = attributes[:'payment_product302_specific_input'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, authorization_mode, encrypted_payment_data, public_key_hash, ephemeral_key, payment_product302_specific_input].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + authorization_mode == o.authorization_mode && + encrypted_payment_data == o.encrypted_payment_data && + public_key_hash == o.public_key_hash && + ephemeral_key == o.ephemeral_key && + payment_product302_specific_input == o.payment_product302_specific_input + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, authorization_mode, encrypted_payment_data, public_key_hash, ephemeral_key, payment_product302_specific_input].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_output.rb index 43d413e..7cb9841 100644 --- a/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/mobile_payment_method_specific_output.rb @@ -3,222 +3,226 @@ require 'time' # Object containing the mobile payment method details. -class MobilePaymentMethodSpecificOutput - # Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id +module PCPServerSDK + module Models + class MobilePaymentMethodSpecificOutput + # Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id + + # Card Authorization code as returned by the acquirer + attr_accessor :authorisation_code + + attr_accessor :fraud_results + + attr_accessor :three_d_secure_results + + # The card network that was used for a mobile payment method operation + attr_accessor :network + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'authorisation_code' => :'authorisationCode', + :'fraud_results' => :'fraudResults', + :'three_d_secure_results' => :'threeDSecureResults', + :'network' => :'network' + } + end - # Card Authorization code as returned by the acquirer - attr_accessor :authorisation_code + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :fraud_results + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'authorisation_code' => :'String', + :'fraud_results' => :'CardFraudResults', + :'three_d_secure_results' => :'ThreeDSecureResults', + :'network' => :'String' + } + end - attr_accessor :three_d_secure_results + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # The card network that was used for a mobile payment method operation - attr_accessor :network + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `MobilePaymentMethodSpecificOutput` initialize method" + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'authorisation_code' => :'authorisationCode', - :'fraud_results' => :'fraudResults', - :'three_d_secure_results' => :'threeDSecureResults', - :'network' => :'network' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `MobilePaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'authorisation_code' => :'String', - :'fraud_results' => :'CardFraudResults', - :'three_d_secure_results' => :'ThreeDSecureResults', - :'network' => :'String' - } - end + if attributes.key?(:'authorisation_code') + self.authorisation_code = attributes[:'authorisation_code'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'fraud_results') + self.fraud_results = attributes[:'fraud_results'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `MobilePaymentMethodSpecificOutput` initialize method" - end + if attributes.key?(:'three_d_secure_results') + self.three_d_secure_results = attributes[:'three_d_secure_results'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `MobilePaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'network') + self.network = attributes[:'network'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end - - if attributes.key?(:'authorisation_code') - self.authorisation_code = attributes[:'authorisation_code'] - end - - if attributes.key?(:'fraud_results') - self.fraud_results = attributes[:'fraud_results'] - end - - if attributes.key?(:'three_d_secure_results') - self.three_d_secure_results = attributes[:'three_d_secure_results'] - end - if attributes.key?(:'network') - self.network = attributes[:'network'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - authorisation_code == o.authorisation_code && - fraud_results == o.fraud_results && - three_d_secure_results == o.three_d_secure_results && - network == o.network - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + authorisation_code == o.authorisation_code && + fraud_results == o.fraud_results && + three_d_secure_results == o.three_d_secure_results && + network == o.network + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, authorisation_code, fraud_results, three_d_secure_results, network].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, authorisation_code, fraud_results, three_d_secure_results, network].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order.rb b/lib/PCP-server-Ruby-SDK/models/order.rb index cbe5022..1d9d0ab 100644 --- a/lib/PCP-server-Ruby-SDK/models/order.rb +++ b/lib/PCP-server-Ruby-SDK/models/order.rb @@ -3,221 +3,225 @@ require 'time' # Order object containing order related data Please note that this object is required to be able to submit the amount. -class Order - attr_accessor :amount_of_money +module PCPServerSDK + module Models + class Order + attr_accessor :amount_of_money - attr_accessor :customer + attr_accessor :customer - attr_accessor :references + attr_accessor :references - attr_accessor :shipping + attr_accessor :shipping - attr_accessor :shopping_cart + attr_accessor :shopping_cart - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'customer' => :'customer', - :'references' => :'references', - :'shipping' => :'shipping', - :'shopping_cart' => :'shoppingCart' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'customer' => :'Customer', - :'references' => :'References', - :'shipping' => :'Shipping', - :'shopping_cart' => :'ShoppingCartInput' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'customer' => :'customer', + :'references' => :'references', + :'shipping' => :'shipping', + :'shopping_cart' => :'shoppingCart' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Order` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'customer' => :'Customer', + :'references' => :'References', + :'shipping' => :'Shipping', + :'shopping_cart' => :'ShoppingCartInput' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Order`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Order` initialize method" + end - if attributes.key?(:'customer') - self.customer = attributes[:'customer'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Order`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'references') - self.references = attributes[:'references'] - else - self.references = nil - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - if attributes.key?(:'shipping') - self.shipping = attributes[:'shipping'] - end + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + else + self.references = nil + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - customer == o.customer && - references == o.references && - shipping == o.shipping && - shopping_cart == o.shopping_cart - end + if attributes.key?(:'shipping') + self.shipping = attributes[:'shipping'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, customer, references, shipping, shopping_cart].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + customer == o.customer && + references == o.references && + shipping == o.shipping && + shopping_cart == o.shopping_cart + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, customer, references, shipping, shopping_cart].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order_item.rb b/lib/PCP-server-Ruby-SDK/models/order_item.rb index efbe789..ca66dbf 100644 --- a/lib/PCP-server-Ruby-SDK/models/order_item.rb +++ b/lib/PCP-server-Ruby-SDK/models/order_item.rb @@ -3,198 +3,202 @@ require 'time' # Items should only be provided for orderType = PARTIAL -class OrderItem - # Id of the item from the ShoppingCart. The id will be returned in the response from create Checkout request. - attr_accessor :id - - # Quantity of the specific item. Must be greater than zero. Note: Must not be all spaces or all zeros - attr_accessor :quantity - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'id' => :'id', - :'quantity' => :'quantity' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'id' => :'String', - :'quantity' => :'Integer' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end +module PCPServerSDK + module Models + class OrderItem + # Id of the item from the ShoppingCart. The id will be returned in the response from create Checkout request. + attr_accessor :id + + # Quantity of the specific item. Must be greater than zero. Note: Must not be all spaces or all zeros + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'quantity' => :'quantity' + } + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `OrderItem` initialize method" - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `OrderItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'quantity' => :'Integer' + } end - h[k.to_sym] = v - } - if attributes.key?(:'id') - self.id = attributes[:'id'] - else - self.id = nil - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - else - self.quantity = nil - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OrderItem` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - id == o.id && - quantity == o.quantity - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OrderItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [id, quantity].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + quantity == o.quantity + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, quantity].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order_line_details_input.rb b/lib/PCP-server-Ruby-SDK/models/order_line_details_input.rb index 2d9d80d..dd08287 100644 --- a/lib/PCP-server-Ruby-SDK/models/order_line_details_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/order_line_details_input.rb @@ -3,289 +3,295 @@ require 'time' # Object containing additional information that when supplied can have a beneficial effect on the discountrates. -class OrderLineDetailsInput - # Product or UPC Code - attr_accessor :product_code +module PCPServerSDK + module Models + class OrderLineDetailsInput + # Product or UPC Code + attr_accessor :product_code - # The price of one unit of the product, the value should be zero or greater. - attr_accessor :product_price + # The price of one unit of the product, the value should be zero or greater. + attr_accessor :product_price - attr_accessor :product_type + attr_accessor :product_type - # Quantity of the units being purchased, should be greater than zero Note: Must not be all spaces or all zeros - attr_accessor :quantity + # Quantity of the units being purchased, should be greater than zero Note: Must not be all spaces or all zeros + attr_accessor :quantity - # Tax on the line item, with the last two digits implied as decimal places - attr_accessor :tax_amount + # Tax on the line item, with the last two digits implied as decimal places + attr_accessor :tax_amount - # URL of the product in shop. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_url + # URL of the product in shop. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_url - # URL of a product image. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_image_url + # URL of a product image. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_image_url - # Category path of the item. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_category_path + # Category path of the item. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_category_path - # Optional parameter to define the delivery shop or touchpoint where an item has been collected (e.g. for Click & Collect or Click & Reserve). - attr_accessor :merchant_shop_delivery_reference + # Optional parameter to define the delivery shop or touchpoint where an item has been collected (e.g. for Click & Collect or Click & Reserve). + attr_accessor :merchant_shop_delivery_reference - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'product_code' => :'productCode', - :'product_price' => :'productPrice', - :'product_type' => :'productType', - :'quantity' => :'quantity', - :'tax_amount' => :'taxAmount', - :'product_url' => :'productUrl', - :'product_image_url' => :'productImageUrl', - :'product_category_path' => :'productCategoryPath', - :'merchant_shop_delivery_reference' => :'merchantShopDeliveryReference' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'product_code' => :'String', - :'product_price' => :'Integer', - :'product_type' => :'ProductType', - :'quantity' => :'Integer', - :'tax_amount' => :'Integer', - :'product_url' => :'String', - :'product_image_url' => :'String', - :'product_category_path' => :'String', - :'merchant_shop_delivery_reference' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'product_code' => :'productCode', + :'product_price' => :'productPrice', + :'product_type' => :'productType', + :'quantity' => :'quantity', + :'tax_amount' => :'taxAmount', + :'product_url' => :'productUrl', + :'product_image_url' => :'productImageUrl', + :'product_category_path' => :'productCategoryPath', + :'merchant_shop_delivery_reference' => :'merchantShopDeliveryReference' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `OrderLineDetailsInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'product_code' => :'String', + :'product_price' => :'Integer', + :'product_type' => :'ProductType', + :'quantity' => :'Integer', + :'tax_amount' => :'Integer', + :'product_url' => :'String', + :'product_image_url' => :'String', + :'product_category_path' => :'String', + :'merchant_shop_delivery_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `OrderLineDetailsInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'product_code') - self.product_code = attributes[:'product_code'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OrderLineDetailsInput` initialize method" + end - if attributes.key?(:'product_price') - self.product_price = attributes[:'product_price'] - else - self.product_price = nil - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OrderLineDetailsInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'product_type') - self.product_type = attributes[:'product_type'] - end + if attributes.key?(:'product_code') + self.product_code = attributes[:'product_code'] + end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - else - self.quantity = nil - end + if attributes.key?(:'product_price') + self.product_price = attributes[:'product_price'] + else + self.product_price = nil + end - if attributes.key?(:'tax_amount') - self.tax_amount = attributes[:'tax_amount'] - end + if attributes.key?(:'product_type') + self.product_type = attributes[:'product_type'] + end - if attributes.key?(:'product_url') - self.product_url = attributes[:'product_url'] - end + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end - if attributes.key?(:'product_image_url') - self.product_image_url = attributes[:'product_image_url'] - end + if attributes.key?(:'tax_amount') + self.tax_amount = attributes[:'tax_amount'] + end - if attributes.key?(:'product_category_path') - self.product_category_path = attributes[:'product_category_path'] - end + if attributes.key?(:'product_url') + self.product_url = attributes[:'product_url'] + end - if attributes.key?(:'merchant_shop_delivery_reference') - self.merchant_shop_delivery_reference = attributes[:'merchant_shop_delivery_reference'] - end - end + if attributes.key?(:'product_image_url') + self.product_image_url = attributes[:'product_image_url'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - product_code == o.product_code && - product_price == o.product_price && - product_type == o.product_type && - quantity == o.quantity && - tax_amount == o.tax_amount && - product_url == o.product_url && - product_image_url == o.product_image_url && - product_category_path == o.product_category_path && - merchant_shop_delivery_reference == o.merchant_shop_delivery_reference - end + if attributes.key?(:'product_category_path') + self.product_category_path = attributes[:'product_category_path'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'merchant_shop_delivery_reference') + self.merchant_shop_delivery_reference = attributes[:'merchant_shop_delivery_reference'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [product_code, product_price, product_type, quantity, tax_amount, product_url, product_image_url, product_category_path, merchant_shop_delivery_reference].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + product_code == o.product_code && + product_price == o.product_price && + product_type == o.product_type && + quantity == o.quantity && + tax_amount == o.tax_amount && + product_url == o.product_url && + product_image_url == o.product_image_url && + product_category_path == o.product_category_path && + merchant_shop_delivery_reference == o.merchant_shop_delivery_reference + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [product_code, product_price, product_type, quantity, tax_amount, product_url, product_image_url, product_category_path, merchant_shop_delivery_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order_line_details_patch.rb b/lib/PCP-server-Ruby-SDK/models/order_line_details_patch.rb index 8fecfac..a9e5c62 100644 --- a/lib/PCP-server-Ruby-SDK/models/order_line_details_patch.rb +++ b/lib/PCP-server-Ruby-SDK/models/order_line_details_patch.rb @@ -3,317 +3,324 @@ require 'time' # Object containing additional information that when supplied can have a beneficial effect on the discountrates. -class OrderLineDetailsPatch - # Unique identifier of a cart item - attr_accessor :id +module PCPServerSDK + module Models + class OrderLineDetailsPatch + # Unique identifier of a cart item + attr_accessor :id - attr_accessor :status + attr_accessor :status - # Product or UPC Code - attr_accessor :product_code + # Product or UPC Code + attr_accessor :product_code - # The price of one unit of the product, the value should be zero or greater. - attr_accessor :product_price + # The price of one unit of the product, the value should be zero or greater. + attr_accessor :product_price - attr_accessor :product_type + attr_accessor :product_type - # Quantity of the units being purchased, should be greater than zero Note: Must not be all spaces or all zeros - attr_accessor :quantity + # Quantity of the units being purchased, should be greater than zero Note: Must not be all spaces or all zeros + attr_accessor :quantity - # Tax on the line item, with the last two digits implied as decimal places - attr_accessor :tax_amount + # Tax on the line item, with the last two digits implied as decimal places + attr_accessor :tax_amount - # URL of the product in shop. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_url + # URL of the product in shop. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_url - # URL of a product image. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_image_url + # URL of a product image. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_image_url - # Category path of the item. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_category_path + # Category path of the item. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_category_path - # Optional parameter to define the delivery shop or touchpoint where an item has been collected (e.g. for Click & Collect or Click & Reserve). - attr_accessor :merchant_shop_delivery_reference + # Optional parameter to define the delivery shop or touchpoint where an item has been collected (e.g. for Click & Collect or Click & Reserve). + attr_accessor :merchant_shop_delivery_reference - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'id' => :'id', - :'status' => :'status', - :'product_code' => :'productCode', - :'product_price' => :'productPrice', - :'product_type' => :'productType', - :'quantity' => :'quantity', - :'tax_amount' => :'taxAmount', - :'product_url' => :'productUrl', - :'product_image_url' => :'productImageUrl', - :'product_category_path' => :'productCategoryPath', - :'merchant_shop_delivery_reference' => :'merchantShopDeliveryReference' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Attribute type mapping. - def self.openapi_types - { - :'id' => :'String', - :'status' => :'Array', - :'product_code' => :'String', - :'product_price' => :'Integer', - :'product_type' => :'ProductType', - :'quantity' => :'Integer', - :'tax_amount' => :'Integer', - :'product_url' => :'String', - :'product_image_url' => :'String', - :'product_category_path' => :'String', - :'merchant_shop_delivery_reference' => :'String' - } - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'status' => :'status', + :'product_code' => :'productCode', + :'product_price' => :'productPrice', + :'product_type' => :'productType', + :'quantity' => :'quantity', + :'tax_amount' => :'taxAmount', + :'product_url' => :'productUrl', + :'product_image_url' => :'productImageUrl', + :'product_category_path' => :'productCategoryPath', + :'merchant_shop_delivery_reference' => :'merchantShopDeliveryReference' + } + end - # List of class defined in allOf (OpenAPI v3) - def self.openapi_all_of - [ - :'OrderLineDetailsInput' - ] - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `OrderLineDetailsPatch` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'status' => :'Array', + :'product_code' => :'String', + :'product_price' => :'Integer', + :'product_type' => :'ProductType', + :'quantity' => :'Integer', + :'tax_amount' => :'Integer', + :'product_url' => :'String', + :'product_image_url' => :'String', + :'product_category_path' => :'String', + :'merchant_shop_delivery_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `OrderLineDetailsPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'id') - self.id = attributes[:'id'] - end + # List of module PCPServerSDK - if attributes.key?(:'status') - if (value = attributes[:'status']).is_a?(Array) - self.status = value + def self.openapi_all_of + [ + :'OrderLineDetailsInput' + ] end - end - if attributes.key?(:'product_code') - self.product_code = attributes[:'product_code'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OrderLineDetailsPatch` initialize method" + end - if attributes.key?(:'product_price') - self.product_price = attributes[:'product_price'] - else - self.product_price = nil - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OrderLineDetailsPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'product_type') - self.product_type = attributes[:'product_type'] - end + if attributes.key?(:'id') + self.id = attributes[:'id'] + end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - else - self.quantity = nil - end + if attributes.key?(:'status') + if (value = attributes[:'status']).is_a?(Array) + self.status = value + end + end - if attributes.key?(:'tax_amount') - self.tax_amount = attributes[:'tax_amount'] - end + if attributes.key?(:'product_code') + self.product_code = attributes[:'product_code'] + end - if attributes.key?(:'product_url') - self.product_url = attributes[:'product_url'] - end + if attributes.key?(:'product_price') + self.product_price = attributes[:'product_price'] + else + self.product_price = nil + end - if attributes.key?(:'product_image_url') - self.product_image_url = attributes[:'product_image_url'] - end + if attributes.key?(:'product_type') + self.product_type = attributes[:'product_type'] + end - if attributes.key?(:'product_category_path') - self.product_category_path = attributes[:'product_category_path'] - end + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end - if attributes.key?(:'merchant_shop_delivery_reference') - self.merchant_shop_delivery_reference = attributes[:'merchant_shop_delivery_reference'] - end - end + if attributes.key?(:'tax_amount') + self.tax_amount = attributes[:'tax_amount'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - id == o.id && - status == o.status && - product_code == o.product_code && - product_price == o.product_price && - product_type == o.product_type && - quantity == o.quantity && - tax_amount == o.tax_amount && - product_url == o.product_url && - product_image_url == o.product_image_url && - product_category_path == o.product_category_path && - merchant_shop_delivery_reference == o.merchant_shop_delivery_reference - end + if attributes.key?(:'product_url') + self.product_url = attributes[:'product_url'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'product_image_url') + self.product_image_url = attributes[:'product_image_url'] + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [id, status, product_code, product_price, product_type, quantity, tax_amount, product_url, product_image_url, product_category_path, merchant_shop_delivery_reference].hash - end + if attributes.key?(:'product_category_path') + self.product_category_path = attributes[:'product_category_path'] + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes.key?(:'merchant_shop_delivery_reference') + self.merchant_shop_delivery_reference = attributes[:'merchant_shop_delivery_reference'] end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + status == o.status && + product_code == o.product_code && + product_price == o.product_price && + product_type == o.product_type && + quantity == o.quantity && + tax_amount == o.tax_amount && + product_url == o.product_url && + product_image_url == o.product_image_url && + product_category_path == o.product_category_path && + merchant_shop_delivery_reference == o.merchant_shop_delivery_reference + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, status, product_code, product_price, product_type, quantity, tax_amount, product_url, product_image_url, product_category_path, merchant_shop_delivery_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order_line_details_result.rb b/lib/PCP-server-Ruby-SDK/models/order_line_details_result.rb index a2c1021..90ca943 100644 --- a/lib/PCP-server-Ruby-SDK/models/order_line_details_result.rb +++ b/lib/PCP-server-Ruby-SDK/models/order_line_details_result.rb @@ -3,317 +3,324 @@ require 'time' # Object containing additional information that when supplied can have a beneficial effect on the discountrates. -class OrderLineDetailsResult - # Unique identifier of a cart item - attr_accessor :id +module PCPServerSDK + module Models + class OrderLineDetailsResult + # Unique identifier of a cart item + attr_accessor :id - attr_accessor :status + attr_accessor :status - # Product or UPC Code - attr_accessor :product_code + # Product or UPC Code + attr_accessor :product_code - # The price of one unit of the product, the value should be zero or greater. - attr_accessor :product_price + # The price of one unit of the product, the value should be zero or greater. + attr_accessor :product_price - attr_accessor :product_type + attr_accessor :product_type - # Quantity of the units being purchased, should be greater than zero Note: Must not be all spaces or all zeros - attr_accessor :quantity + # Quantity of the units being purchased, should be greater than zero Note: Must not be all spaces or all zeros + attr_accessor :quantity - # Tax on the line item, with the last two digits implied as decimal places - attr_accessor :tax_amount + # Tax on the line item, with the last two digits implied as decimal places + attr_accessor :tax_amount - # URL of the product in shop. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_url + # URL of the product in shop. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_url - # URL of a product image. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_image_url + # URL of a product image. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_image_url - # Category path of the item. Used for PAYONE Buy Now, Pay Later (BNPL). - attr_accessor :product_category_path + # Category path of the item. Used for PAYONE Buy Now, Pay Later (BNPL). + attr_accessor :product_category_path - # Optional parameter to define the delivery shop or touchpoint where an item has been collected (e.g. for Click & Collect or Click & Reserve). - attr_accessor :merchant_shop_delivery_reference + # Optional parameter to define the delivery shop or touchpoint where an item has been collected (e.g. for Click & Collect or Click & Reserve). + attr_accessor :merchant_shop_delivery_reference - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'id' => :'id', - :'status' => :'status', - :'product_code' => :'productCode', - :'product_price' => :'productPrice', - :'product_type' => :'productType', - :'quantity' => :'quantity', - :'tax_amount' => :'taxAmount', - :'product_url' => :'productUrl', - :'product_image_url' => :'productImageUrl', - :'product_category_path' => :'productCategoryPath', - :'merchant_shop_delivery_reference' => :'merchantShopDeliveryReference' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Attribute type mapping. - def self.openapi_types - { - :'id' => :'String', - :'status' => :'Array', - :'product_code' => :'String', - :'product_price' => :'Integer', - :'product_type' => :'ProductType', - :'quantity' => :'Integer', - :'tax_amount' => :'Integer', - :'product_url' => :'String', - :'product_image_url' => :'String', - :'product_category_path' => :'String', - :'merchant_shop_delivery_reference' => :'String' - } - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'status' => :'status', + :'product_code' => :'productCode', + :'product_price' => :'productPrice', + :'product_type' => :'productType', + :'quantity' => :'quantity', + :'tax_amount' => :'taxAmount', + :'product_url' => :'productUrl', + :'product_image_url' => :'productImageUrl', + :'product_category_path' => :'productCategoryPath', + :'merchant_shop_delivery_reference' => :'merchantShopDeliveryReference' + } + end - # List of class defined in allOf (OpenAPI v3) - def self.openapi_all_of - [ - :'OrderLineDetailsInput' - ] - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `OrderLineDetailsResult` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'status' => :'Array', + :'product_code' => :'String', + :'product_price' => :'Integer', + :'product_type' => :'ProductType', + :'quantity' => :'Integer', + :'tax_amount' => :'Integer', + :'product_url' => :'String', + :'product_image_url' => :'String', + :'product_category_path' => :'String', + :'merchant_shop_delivery_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `OrderLineDetailsResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'id') - self.id = attributes[:'id'] - end + # List of module PCPServerSDK - if attributes.key?(:'status') - if (value = attributes[:'status']).is_a?(Array) - self.status = value + def self.openapi_all_of + [ + :'OrderLineDetailsInput' + ] end - end - if attributes.key?(:'product_code') - self.product_code = attributes[:'product_code'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OrderLineDetailsResult` initialize method" + end - if attributes.key?(:'product_price') - self.product_price = attributes[:'product_price'] - else - self.product_price = nil - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OrderLineDetailsResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'product_type') - self.product_type = attributes[:'product_type'] - end + if attributes.key?(:'id') + self.id = attributes[:'id'] + end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - else - self.quantity = nil - end + if attributes.key?(:'status') + if (value = attributes[:'status']).is_a?(Array) + self.status = value + end + end - if attributes.key?(:'tax_amount') - self.tax_amount = attributes[:'tax_amount'] - end + if attributes.key?(:'product_code') + self.product_code = attributes[:'product_code'] + end - if attributes.key?(:'product_url') - self.product_url = attributes[:'product_url'] - end + if attributes.key?(:'product_price') + self.product_price = attributes[:'product_price'] + else + self.product_price = nil + end - if attributes.key?(:'product_image_url') - self.product_image_url = attributes[:'product_image_url'] - end + if attributes.key?(:'product_type') + self.product_type = attributes[:'product_type'] + end - if attributes.key?(:'product_category_path') - self.product_category_path = attributes[:'product_category_path'] - end + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end - if attributes.key?(:'merchant_shop_delivery_reference') - self.merchant_shop_delivery_reference = attributes[:'merchant_shop_delivery_reference'] - end - end + if attributes.key?(:'tax_amount') + self.tax_amount = attributes[:'tax_amount'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - id == o.id && - status == o.status && - product_code == o.product_code && - product_price == o.product_price && - product_type == o.product_type && - quantity == o.quantity && - tax_amount == o.tax_amount && - product_url == o.product_url && - product_image_url == o.product_image_url && - product_category_path == o.product_category_path && - merchant_shop_delivery_reference == o.merchant_shop_delivery_reference - end + if attributes.key?(:'product_url') + self.product_url = attributes[:'product_url'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'product_image_url') + self.product_image_url = attributes[:'product_image_url'] + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [id, status, product_code, product_price, product_type, quantity, tax_amount, product_url, product_image_url, product_category_path, merchant_shop_delivery_reference].hash - end + if attributes.key?(:'product_category_path') + self.product_category_path = attributes[:'product_category_path'] + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + if attributes.key?(:'merchant_shop_delivery_reference') + self.merchant_shop_delivery_reference = attributes[:'merchant_shop_delivery_reference'] end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + status == o.status && + product_code == o.product_code && + product_price == o.product_price && + product_type == o.product_type && + quantity == o.quantity && + tax_amount == o.tax_amount && + product_url == o.product_url && + product_image_url == o.product_image_url && + product_category_path == o.product_category_path && + merchant_shop_delivery_reference == o.merchant_shop_delivery_reference + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, status, product_code, product_price, product_type, quantity, tax_amount, product_url, product_image_url, product_category_path, merchant_shop_delivery_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order_request.rb b/lib/PCP-server-Ruby-SDK/models/order_request.rb index b40a1f7..3fd9abc 100644 --- a/lib/PCP-server-Ruby-SDK/models/order_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/order_request.rb @@ -3,234 +3,240 @@ require 'time' # Request to execute an Order for the corresponding Checkout for a specific payment method. The provided data from the Commerce Case and the Checkout regarding customer, shipping, and ShoppingCart will be automatically loaded and used for the Payment Execution. In case the paymentMethodSpecificInput has already been provided when creating the Commerce Case or Checkout, this input will automatically be used. An Order can be created for a full or the partial ShoppingCart of the Checkout. For a partial Order a list of items must be provided. The platform will automatically calculate the respective amount to trigger the payment execution. -class OrderRequest - attr_accessor :order_type +module PCPServerSDK + module Models + class OrderRequest + attr_accessor :order_type - attr_accessor :order_references + attr_accessor :order_references - attr_accessor :items + attr_accessor :items - attr_accessor :payment_method_specific_input + attr_accessor :payment_method_specific_input - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'order_type' => :'orderType', - :'order_references' => :'orderReferences', - :'items' => :'items', - :'payment_method_specific_input' => :'paymentMethodSpecificInput' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'order_type' => :'OrderType', - :'order_references' => :'References', - :'items' => :'Array', - :'payment_method_specific_input' => :'PaymentMethodSpecificInput' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'order_type' => :'orderType', + :'order_references' => :'orderReferences', + :'items' => :'items', + :'payment_method_specific_input' => :'paymentMethodSpecificInput' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `OrderRequest` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'order_type' => :'OrderType', + :'order_references' => :'References', + :'items' => :'Array', + :'payment_method_specific_input' => :'PaymentMethodSpecificInput' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `OrderRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'order_type') - self.order_type = attributes[:'order_type'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OrderRequest` initialize method" + end - if attributes.key?(:'order_references') - self.order_references = attributes[:'order_references'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OrderRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'items') - if (value = attributes[:'items']).is_a?(Array) - self.items = value - end - end + if attributes.key?(:'order_type') + self.order_type = attributes[:'order_type'] + end - if attributes.key?(:'payment_method_specific_input') - self.payment_method_specific_input = attributes[:'payment_method_specific_input'] - end - end + if attributes.key?(:'order_references') + self.order_references = attributes[:'order_references'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - order_type == o.order_type && - order_references == o.order_references && - items == o.items && - payment_method_specific_input == o.payment_method_specific_input - end + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_method_specific_input') + self.payment_method_specific_input = attributes[:'payment_method_specific_input'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [order_type, order_references, items, payment_method_specific_input].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + order_type == o.order_type && + order_references == o.order_references && + items == o.items && + payment_method_specific_input == o.payment_method_specific_input + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [order_type, order_references, items, payment_method_specific_input].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order_response.rb b/lib/PCP-server-Ruby-SDK/models/order_response.rb index 48f17c3..a14f8de 100644 --- a/lib/PCP-server-Ruby-SDK/models/order_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/order_response.rb @@ -3,192 +3,196 @@ require 'time' # Object that contains details on the created payment in case one has been created. -class OrderResponse - attr_accessor :create_payment_response +module PCPServerSDK + module Models + class OrderResponse + attr_accessor :create_payment_response + + attr_accessor :shopping_cart + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'create_payment_response' => :'createPaymentResponse', + :'shopping_cart' => :'shoppingCart' + } + end - attr_accessor :shopping_cart + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'create_payment_response' => :'createPaymentResponse', - :'shopping_cart' => :'shoppingCart' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'create_payment_response' => :'CreatePaymentResponse', + :'shopping_cart' => :'ShoppingCartResult' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'create_payment_response' => :'CreatePaymentResponse', - :'shopping_cart' => :'ShoppingCartResult' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `OrderResponse` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `OrderResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `OrderResponse` initialize method" - end + if attributes.key?(:'create_payment_response') + self.create_payment_response = attributes[:'create_payment_response'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `OrderResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'create_payment_response') - self.create_payment_response = attributes[:'create_payment_response'] - end - - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - create_payment_response == o.create_payment_response && - shopping_cart == o.shopping_cart - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + create_payment_response == o.create_payment_response && + shopping_cart == o.shopping_cart + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [create_payment_response, shopping_cart].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [create_payment_response, shopping_cart].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/order_type.rb b/lib/PCP-server-Ruby-SDK/models/order_type.rb index f17613a..b19a919 100644 --- a/lib/PCP-server-Ruby-SDK/models/order_type.rb +++ b/lib/PCP-server-Ruby-SDK/models/order_type.rb @@ -2,26 +2,30 @@ require 'date' require 'time' -class OrderType - FULL = "FULL".freeze - PARTIAL = "PARTIAL".freeze +module PCPServerSDK + module Models + class OrderType + FULL = "FULL".freeze + PARTIAL = "PARTIAL".freeze - def self.all_vars - @all_vars ||= [FULL, PARTIAL].freeze - end + def self.all_vars + @all_vars ||= [FULL, PARTIAL].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if OrderType.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #OrderType" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if OrderType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #OrderType" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/patch_checkout_request.rb b/lib/PCP-server-Ruby-SDK/models/patch_checkout_request.rb index 8982779..87dc98b 100644 --- a/lib/PCP-server-Ruby-SDK/models/patch_checkout_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/patch_checkout_request.rb @@ -3,228 +3,232 @@ require 'time' # An existing shopping cart of a Checkout will not be overwritten with the Patch request. New items can be added to the shoppingCart by providing them in the request. To change existing items (delete, modify or add), the respective itemId must be provided. An item can be completely removed if quantity = 0 is provided. The price of an item can be changed as long as no payment has happened for this item (i.e. as long as an item has no specific status). Items with a status can no longer be removed entirely, however the quantity can be increased or decreased (for items without payment) by using the itemId. If no amountOfMoney for the Checkout is provided, the platform will calculate the respective amount based on the cartItem productPrice and productQuantity. -class PatchCheckoutRequest - attr_accessor :amount_of_money +module PCPServerSDK + module Models + class PatchCheckoutRequest + attr_accessor :amount_of_money - attr_accessor :references + attr_accessor :references - attr_accessor :shipping + attr_accessor :shipping - attr_accessor :shopping_cart + attr_accessor :shopping_cart - attr_accessor :payment_method_specific_input + attr_accessor :payment_method_specific_input - attr_accessor :payment_references + attr_accessor :payment_references - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'references' => :'references', - :'shipping' => :'shipping', - :'shopping_cart' => :'shoppingCart', - :'payment_method_specific_input' => :'paymentMethodSpecificInput', - :'payment_references' => :'paymentReferences' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'references' => :'CheckoutReferences', - :'shipping' => :'Shipping', - :'shopping_cart' => :'ShoppingCartPatch', - :'payment_method_specific_input' => :'PaymentMethodSpecificInput', - :'payment_references' => :'References' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'references' => :'references', + :'shipping' => :'shipping', + :'shopping_cart' => :'shoppingCart', + :'payment_method_specific_input' => :'paymentMethodSpecificInput', + :'payment_references' => :'paymentReferences' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PatchCheckoutRequest` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'references' => :'CheckoutReferences', + :'shipping' => :'Shipping', + :'shopping_cart' => :'ShoppingCartPatch', + :'payment_method_specific_input' => :'PaymentMethodSpecificInput', + :'payment_references' => :'References' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PatchCheckoutRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PatchCheckoutRequest` initialize method" + end - if attributes.key?(:'references') - self.references = attributes[:'references'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PatchCheckoutRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'shipping') - self.shipping = attributes[:'shipping'] - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - if attributes.key?(:'payment_method_specific_input') - self.payment_method_specific_input = attributes[:'payment_method_specific_input'] - end + if attributes.key?(:'shipping') + self.shipping = attributes[:'shipping'] + end - if attributes.key?(:'payment_references') - self.payment_references = attributes[:'payment_references'] - end - end + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - references == o.references && - shipping == o.shipping && - shopping_cart == o.shopping_cart && - payment_method_specific_input == o.payment_method_specific_input && - payment_references == o.payment_references - end + if attributes.key?(:'payment_method_specific_input') + self.payment_method_specific_input = attributes[:'payment_method_specific_input'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_references') + self.payment_references = attributes[:'payment_references'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, references, shipping, shopping_cart, payment_method_specific_input, payment_references].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + references == o.references && + shipping == o.shipping && + shopping_cart == o.shopping_cart && + payment_method_specific_input == o.payment_method_specific_input && + payment_references == o.payment_references + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, references, shipping, shopping_cart, payment_method_specific_input, payment_references].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/patch_commerce_case_request.rb b/lib/PCP-server-Ruby-SDK/models/patch_commerce_case_request.rb index d5c9a45..3fb9809 100644 --- a/lib/PCP-server-Ruby-SDK/models/patch_commerce_case_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/patch_commerce_case_request.rb @@ -3,183 +3,187 @@ require 'time' # Update the customer data of the given Commerce Case -class PatchCommerceCaseRequest - attr_accessor :customer - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'customer' => :'customer' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'customer' => :'Customer' - } - end +module PCPServerSDK + module Models + class PatchCommerceCaseRequest + attr_accessor :customer + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'customer' => :'customer' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PatchCommerceCaseRequest` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'customer' => :'Customer' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PatchCommerceCaseRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'customer') - self.customer = attributes[:'customer'] - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PatchCommerceCaseRequest` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - customer == o.customer - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PatchCommerceCaseRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'customer') + self.customer = attributes[:'customer'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [customer].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + customer == o.customer + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [customer].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_channel.rb b/lib/PCP-server-Ruby-SDK/models/payment_channel.rb index 134eadf..31bd8a1 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_channel.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_channel.rb @@ -2,26 +2,30 @@ require 'date' require 'time' -class PaymentChannel - ECOMMERCE = "ECOMMERCE".freeze - POS = "POS".freeze +module PCPServerSDK + module Models + class PaymentChannel + ECOMMERCE = "ECOMMERCE".freeze + POS = "POS".freeze - def self.all_vars - @all_vars ||= [ECOMMERCE, POS].freeze - end + def self.all_vars + @all_vars ||= [ECOMMERCE, POS].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if PaymentChannel.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #PaymentChannel" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if PaymentChannel.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #PaymentChannel" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_creation_output.rb b/lib/PCP-server-Ruby-SDK/models/payment_creation_output.rb index 526ad5a..38bf794 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_creation_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_creation_output.rb @@ -3,184 +3,188 @@ require 'time' # Object containing the details of the created payment. -class PaymentCreationOutput - # The external reference is an identifier for this transaction and can be used for reconciliation purposes. - attr_accessor :external_reference - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'external_reference' => :'externalReference' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'external_reference' => :'String' - } - end +module PCPServerSDK + module Models + class PaymentCreationOutput + # The external reference is an identifier for this transaction and can be used for reconciliation purposes. + attr_accessor :external_reference + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'external_reference' => :'externalReference' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentCreationOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'external_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentCreationOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'external_reference') - self.external_reference = attributes[:'external_reference'] - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentCreationOutput` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - external_reference == o.external_reference - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentCreationOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'external_reference') + self.external_reference = attributes[:'external_reference'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [external_reference].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + external_reference == o.external_reference + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [external_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_event.rb b/lib/PCP-server-Ruby-SDK/models/payment_event.rb index 524b4b2..879ccf9 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_event.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_event.rb @@ -3,242 +3,248 @@ require 'time' # Detailed information regarding an occurred payment event. -class PaymentEvent - attr_accessor :type +module PCPServerSDK + module Models + class PaymentEvent + attr_accessor :type - attr_accessor :amount_of_money + attr_accessor :amount_of_money - attr_accessor :payment_status + attr_accessor :payment_status - attr_accessor :cancellation_reason + attr_accessor :cancellation_reason - # Reason of the Refund (e.g. communicated by or to the costumer). - attr_accessor :return_reason + # Reason of the Refund (e.g. communicated by or to the costumer). + attr_accessor :return_reason - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'type' => :'type', - :'amount_of_money' => :'amountOfMoney', - :'payment_status' => :'paymentStatus', - :'cancellation_reason' => :'cancellationReason', - :'return_reason' => :'returnReason' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'type' => :'PaymentType', - :'amount_of_money' => :'AmountOfMoney', - :'payment_status' => :'StatusValue', - :'cancellation_reason' => :'CancellationReason', - :'return_reason' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'amount_of_money' => :'amountOfMoney', + :'payment_status' => :'paymentStatus', + :'cancellation_reason' => :'cancellationReason', + :'return_reason' => :'returnReason' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentEvent` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'PaymentType', + :'amount_of_money' => :'AmountOfMoney', + :'payment_status' => :'StatusValue', + :'cancellation_reason' => :'CancellationReason', + :'return_reason' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'type') - self.type = attributes[:'type'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentEvent` initialize method" + end - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'payment_status') - self.payment_status = attributes[:'payment_status'] - end + if attributes.key?(:'type') + self.type = attributes[:'type'] + end - if attributes.key?(:'cancellation_reason') - self.cancellation_reason = attributes[:'cancellation_reason'] - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - if attributes.key?(:'return_reason') - self.return_reason = attributes[:'return_reason'] - end - end + if attributes.key?(:'payment_status') + self.payment_status = attributes[:'payment_status'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - type == o.type && - amount_of_money == o.amount_of_money && - payment_status == o.payment_status && - cancellation_reason == o.cancellation_reason && - return_reason == o.return_reason - end + if attributes.key?(:'cancellation_reason') + self.cancellation_reason = attributes[:'cancellation_reason'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'return_reason') + self.return_reason = attributes[:'return_reason'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [type, amount_of_money, payment_status, cancellation_reason, return_reason].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + type == o.type && + amount_of_money == o.amount_of_money && + payment_status == o.payment_status && + cancellation_reason == o.cancellation_reason && + return_reason == o.return_reason + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [type, amount_of_money, payment_status, cancellation_reason, return_reason].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_execution.rb b/lib/PCP-server-Ruby-SDK/models/payment_execution.rb index cc1b3fc..ccfed52 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_execution.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_execution.rb @@ -3,290 +3,296 @@ require 'time' # Object contains information of the payment with a specific payment method. -class PaymentExecution - # Unique ID of paymentExecution. - attr_accessor :payment_execution_id +module PCPServerSDK + module Models + class PaymentExecution + # Unique ID of paymentExecution. + attr_accessor :payment_execution_id - # Unique payment transaction identifier of the payment gateway. - attr_accessor :payment_id + # Unique payment transaction identifier of the payment gateway. + attr_accessor :payment_id - attr_accessor :card_payment_method_specific_input + attr_accessor :card_payment_method_specific_input - attr_accessor :mobile_payment_method_specific_input + attr_accessor :mobile_payment_method_specific_input - attr_accessor :redirect_payment_method_specific_input + attr_accessor :redirect_payment_method_specific_input - attr_accessor :sepa_direct_debit_payment_method_specific_input + attr_accessor :sepa_direct_debit_payment_method_specific_input - attr_accessor :financing_payment_method_specific_input + attr_accessor :financing_payment_method_specific_input - attr_accessor :payment_channel + attr_accessor :payment_channel - attr_accessor :references + attr_accessor :references - attr_accessor :events + attr_accessor :events - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_execution_id' => :'paymentExecutionId', - :'payment_id' => :'paymentId', - :'card_payment_method_specific_input' => :'cardPaymentMethodSpecificInput', - :'mobile_payment_method_specific_input' => :'mobilePaymentMethodSpecificInput', - :'redirect_payment_method_specific_input' => :'redirectPaymentMethodSpecificInput', - :'sepa_direct_debit_payment_method_specific_input' => :'sepaDirectDebitPaymentMethodSpecificInput', - :'financing_payment_method_specific_input' => :'financingPaymentMethodSpecificInput', - :'payment_channel' => :'paymentChannel', - :'references' => :'references', - :'events' => :'events' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_execution_id' => :'String', - :'payment_id' => :'String', - :'card_payment_method_specific_input' => :'CardPaymentMethodSpecificInput', - :'mobile_payment_method_specific_input' => :'MobilePaymentMethodSpecificInput', - :'redirect_payment_method_specific_input' => :'RedirectPaymentMethodSpecificInput', - :'sepa_direct_debit_payment_method_specific_input' => :'SepaDirectDebitPaymentMethodSpecificInput', - :'financing_payment_method_specific_input' => :'FinancingPaymentMethodSpecificInput', - :'payment_channel' => :'PaymentChannel', - :'references' => :'References', - :'events' => :'Array' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_execution_id' => :'paymentExecutionId', + :'payment_id' => :'paymentId', + :'card_payment_method_specific_input' => :'cardPaymentMethodSpecificInput', + :'mobile_payment_method_specific_input' => :'mobilePaymentMethodSpecificInput', + :'redirect_payment_method_specific_input' => :'redirectPaymentMethodSpecificInput', + :'sepa_direct_debit_payment_method_specific_input' => :'sepaDirectDebitPaymentMethodSpecificInput', + :'financing_payment_method_specific_input' => :'financingPaymentMethodSpecificInput', + :'payment_channel' => :'paymentChannel', + :'references' => :'references', + :'events' => :'events' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentExecution` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_execution_id' => :'String', + :'payment_id' => :'String', + :'card_payment_method_specific_input' => :'CardPaymentMethodSpecificInput', + :'mobile_payment_method_specific_input' => :'MobilePaymentMethodSpecificInput', + :'redirect_payment_method_specific_input' => :'RedirectPaymentMethodSpecificInput', + :'sepa_direct_debit_payment_method_specific_input' => :'SepaDirectDebitPaymentMethodSpecificInput', + :'financing_payment_method_specific_input' => :'FinancingPaymentMethodSpecificInput', + :'payment_channel' => :'PaymentChannel', + :'references' => :'References', + :'events' => :'Array' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentExecution`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_execution_id') - self.payment_execution_id = attributes[:'payment_execution_id'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentExecution` initialize method" + end - if attributes.key?(:'payment_id') - self.payment_id = attributes[:'payment_id'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentExecution`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'card_payment_method_specific_input') - self.card_payment_method_specific_input = attributes[:'card_payment_method_specific_input'] - end + if attributes.key?(:'payment_execution_id') + self.payment_execution_id = attributes[:'payment_execution_id'] + end - if attributes.key?(:'mobile_payment_method_specific_input') - self.mobile_payment_method_specific_input = attributes[:'mobile_payment_method_specific_input'] - end + if attributes.key?(:'payment_id') + self.payment_id = attributes[:'payment_id'] + end - if attributes.key?(:'redirect_payment_method_specific_input') - self.redirect_payment_method_specific_input = attributes[:'redirect_payment_method_specific_input'] - end + if attributes.key?(:'card_payment_method_specific_input') + self.card_payment_method_specific_input = attributes[:'card_payment_method_specific_input'] + end - if attributes.key?(:'sepa_direct_debit_payment_method_specific_input') - self.sepa_direct_debit_payment_method_specific_input = attributes[:'sepa_direct_debit_payment_method_specific_input'] - end + if attributes.key?(:'mobile_payment_method_specific_input') + self.mobile_payment_method_specific_input = attributes[:'mobile_payment_method_specific_input'] + end - if attributes.key?(:'financing_payment_method_specific_input') - self.financing_payment_method_specific_input = attributes[:'financing_payment_method_specific_input'] - end + if attributes.key?(:'redirect_payment_method_specific_input') + self.redirect_payment_method_specific_input = attributes[:'redirect_payment_method_specific_input'] + end - if attributes.key?(:'payment_channel') - self.payment_channel = attributes[:'payment_channel'] - end + if attributes.key?(:'sepa_direct_debit_payment_method_specific_input') + self.sepa_direct_debit_payment_method_specific_input = attributes[:'sepa_direct_debit_payment_method_specific_input'] + end - if attributes.key?(:'references') - self.references = attributes[:'references'] - end + if attributes.key?(:'financing_payment_method_specific_input') + self.financing_payment_method_specific_input = attributes[:'financing_payment_method_specific_input'] + end - if attributes.key?(:'events') - if (value = attributes[:'events']).is_a?(Array) - self.events = value - end - end - end + if attributes.key?(:'payment_channel') + self.payment_channel = attributes[:'payment_channel'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_execution_id == o.payment_execution_id && - payment_id == o.payment_id && - card_payment_method_specific_input == o.card_payment_method_specific_input && - mobile_payment_method_specific_input == o.mobile_payment_method_specific_input && - redirect_payment_method_specific_input == o.redirect_payment_method_specific_input && - sepa_direct_debit_payment_method_specific_input == o.sepa_direct_debit_payment_method_specific_input && - financing_payment_method_specific_input == o.financing_payment_method_specific_input && - payment_channel == o.payment_channel && - references == o.references && - events == o.events - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'events') + if (value = attributes[:'events']).is_a?(Array) + self.events = value + end + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_execution_id, payment_id, card_payment_method_specific_input, mobile_payment_method_specific_input, redirect_payment_method_specific_input, sepa_direct_debit_payment_method_specific_input, financing_payment_method_specific_input, payment_channel, references, events].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_execution_id == o.payment_execution_id && + payment_id == o.payment_id && + card_payment_method_specific_input == o.card_payment_method_specific_input && + mobile_payment_method_specific_input == o.mobile_payment_method_specific_input && + redirect_payment_method_specific_input == o.redirect_payment_method_specific_input && + sepa_direct_debit_payment_method_specific_input == o.sepa_direct_debit_payment_method_specific_input && + financing_payment_method_specific_input == o.financing_payment_method_specific_input && + payment_channel == o.payment_channel && + references == o.references && + events == o.events + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_execution_id, payment_id, card_payment_method_specific_input, mobile_payment_method_specific_input, redirect_payment_method_specific_input, sepa_direct_debit_payment_method_specific_input, financing_payment_method_specific_input, payment_channel, references, events].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_execution_request.rb b/lib/PCP-server-Ruby-SDK/models/payment_execution_request.rb index 843d40e..3227b00 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_execution_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_execution_request.rb @@ -1,194 +1,197 @@ require 'date' require 'time' +module PCPServerSDK + module Models + # Request to trigger a payment for a respective Checkout providing the input for a specific payment method. The data from the Commerce case and the Checkout will not be loaded automatically and there is no validation between the data input in place. Depending on the payment method, information of the customer and / or the shopping cart might be required. For more details regarding payment method specific input please check the documentation. + class PaymentExecutionRequest + attr_accessor :payment_method_specific_input + + attr_accessor :payment_execution_specific_input + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_method_specific_input' => :'paymentMethodSpecificInput', + :'payment_execution_specific_input' => :'paymentExecutionSpecificInput' + } + end -# Request to trigger a payment for a respective Checkout providing the input for a specific payment method. The data from the Commerce case and the Checkout will not be loaded automatically and there is no validation between the data input in place. Depending on the payment method, information of the customer and / or the shopping cart might be required. For more details regarding payment method specific input please check the documentation. -class PaymentExecutionRequest - attr_accessor :payment_method_specific_input - - attr_accessor :payment_execution_specific_input + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_method_specific_input' => :'paymentMethodSpecificInput', - :'payment_execution_specific_input' => :'paymentExecutionSpecificInput' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_method_specific_input' => :'PaymentMethodSpecificInput', + :'payment_execution_specific_input' => :'PaymentExecutionSpecificInput' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_method_specific_input' => :'PaymentMethodSpecificInput', - :'payment_execution_specific_input' => :'PaymentExecutionSpecificInput' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentExecutionRequest` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentExecutionRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentExecutionRequest` initialize method" - end + if attributes.key?(:'payment_method_specific_input') + self.payment_method_specific_input = attributes[:'payment_method_specific_input'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentExecutionRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_execution_specific_input') + self.payment_execution_specific_input = attributes[:'payment_execution_specific_input'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'payment_method_specific_input') - self.payment_method_specific_input = attributes[:'payment_method_specific_input'] - end - if attributes.key?(:'payment_execution_specific_input') - self.payment_execution_specific_input = attributes[:'payment_execution_specific_input'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_method_specific_input == o.payment_method_specific_input && - payment_execution_specific_input == o.payment_execution_specific_input - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_method_specific_input == o.payment_method_specific_input && + payment_execution_specific_input == o.payment_execution_specific_input + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_method_specific_input, payment_execution_specific_input].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_method_specific_input, payment_execution_specific_input].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_execution_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/payment_execution_specific_input.rb index 9722081..dd8a4f7 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_execution_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_execution_specific_input.rb @@ -3,203 +3,207 @@ require 'time' # The amount of the paymentSpecificInput might differ from the Checkout amount in case of partial payments but cannot be higher. Additionally, the total amount of the provided shopping cart cannot exceed the Checkout amount. If a different currency is provided than in the Checkout, the payment execution will be declined. Provided details of the customer and shipping from the Checkout will be automatically loaded and used in the Payment Execution request. The ShoppingCart might differ from the one provided in the Checkout (e.g., for partial payments) and might be required by the payment provider (e.g., BNPL). If the ShoppingCart elements differ from the data provided in the Checkout, the existing data will not be overwritten. -class PaymentExecutionSpecificInput - attr_accessor :amount_of_money +module PCPServerSDK + module Models + class PaymentExecutionSpecificInput + attr_accessor :amount_of_money + + attr_accessor :shopping_cart + + attr_accessor :payment_references + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'shopping_cart' => :'shoppingCart', + :'payment_references' => :'paymentReferences' + } + end - attr_accessor :shopping_cart + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :payment_references + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'shopping_cart' => :'ShoppingCartInput', + :'payment_references' => :'References' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'shopping_cart' => :'shoppingCart', - :'payment_references' => :'paymentReferences' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentExecutionSpecificInput` initialize method" + end - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'shopping_cart' => :'ShoppingCartInput', - :'payment_references' => :'References' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentExecutionSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentExecutionSpecificInput` initialize method" - end + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentExecutionSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_references') + self.payment_references = attributes[:'payment_references'] + else + self.payment_references = nil + end end - h[k.to_sym] = v - } - - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end - - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end - - if attributes.key?(:'payment_references') - self.payment_references = attributes[:'payment_references'] - else - self.payment_references = nil - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - shopping_cart == o.shopping_cart && - payment_references == o.payment_references - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + shopping_cart == o.shopping_cart && + payment_references == o.payment_references + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, shopping_cart, payment_references].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, shopping_cart, payment_references].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_information_request.rb b/lib/PCP-server-Ruby-SDK/models/payment_information_request.rb index abd6d14..5b1537c 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_information_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_information_request.rb @@ -1,252 +1,255 @@ require 'date' require 'time' +module PCPServerSDK + module Models + class PaymentInformationRequest + attr_accessor :amount_of_money + + attr_accessor :type + + attr_accessor :payment_channel + + # Payment method identifier - please check the product documentation for a full overview of possible values. + attr_accessor :payment_product_id + + # Unique reference of the PaymentInformation. In case of card present transactions, the reference from the ECR or terminal will be used. It is always the reference for external transactions. (e.g. card present payments, cash payments or payments processed by other payment providers). + attr_accessor :merchant_reference + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end -class PaymentInformationRequest - attr_accessor :amount_of_money - - attr_accessor :type - - attr_accessor :payment_channel - - # Payment method identifier - please check the product documentation for a full overview of possible values. - attr_accessor :payment_product_id - - # Unique reference of the PaymentInformation. In case of card present transactions, the reference from the ECR or terminal will be used. It is always the reference for external transactions. (e.g. card present payments, cash payments or payments processed by other payment providers). - attr_accessor :merchant_reference - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'type' => :'type', - :'payment_channel' => :'paymentChannel', - :'payment_product_id' => :'paymentProductId', - :'merchant_reference' => :'merchantReference' - } - end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'type' => :'PaymentType', - :'payment_channel' => :'PaymentChannel', - :'payment_product_id' => :'Integer', - :'merchant_reference' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'type' => :'type', + :'payment_channel' => :'paymentChannel', + :'payment_product_id' => :'paymentProductId', + :'merchant_reference' => :'merchantReference' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentInformationRequest` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'type' => :'PaymentType', + :'payment_channel' => :'PaymentChannel', + :'payment_product_id' => :'Integer', + :'merchant_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentInformationRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - else - self.amount_of_money = nil - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentInformationRequest` initialize method" + end - if attributes.key?(:'type') - self.type = attributes[:'type'] - else - self.type = nil - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentInformationRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'payment_channel') - self.payment_channel = attributes[:'payment_channel'] - else - self.payment_channel = nil - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + else + self.amount_of_money = nil + end - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - else - self.payment_product_id = nil - end + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = nil + end - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - end - end + if attributes.key?(:'payment_channel') + self.payment_channel = attributes[:'payment_channel'] + else + self.payment_channel = nil + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - type == o.type && - payment_channel == o.payment_channel && - payment_product_id == o.payment_product_id && - merchant_reference == o.merchant_reference - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + else + self.payment_product_id = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, type, payment_channel, payment_product_id, merchant_reference].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + type == o.type && + payment_channel == o.payment_channel && + payment_product_id == o.payment_product_id && + merchant_reference == o.merchant_reference + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, type, payment_channel, payment_product_id, merchant_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_information_response.rb b/lib/PCP-server-Ruby-SDK/models/payment_information_response.rb index 1f74195..3ce9f8b 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_information_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_information_response.rb @@ -3,305 +3,310 @@ require 'time' # Object containing the related data of the created Payment Information. -class PaymentInformationResponse - # Unique ID of the Commerce Case. - attr_accessor :commerce_case_id +module PCPServerSDK + module Models + class PaymentInformationResponse + # Unique ID of the Commerce Case. + attr_accessor :commerce_case_id - # Unique ID of the Commerce Case. - attr_accessor :checkout_id + # Unique ID of the Commerce Case. + attr_accessor :checkout_id - # Unique identifier of the customer. - attr_accessor :merchant_customer_id + # Unique identifier of the customer. + attr_accessor :merchant_customer_id - # Unique ID of the Payment Information. - attr_accessor :payment_information_id + # Unique ID of the Payment Information. + attr_accessor :payment_information_id - attr_accessor :payment_channel + attr_accessor :payment_channel - # Payment product identifier - please check see product documentation for a full overview of possible values. - attr_accessor :payment_product_id + # Payment product identifier - please check see product documentation for a full overview of possible values. + attr_accessor :payment_product_id - # Unique identifier of the POS terminal of the payment transaction. - attr_accessor :terminal_id + # Unique identifier of the POS terminal of the payment transaction. + attr_accessor :terminal_id - # Unique ID that identifies a store location or transaction point and which refers to the contract number of the merchant accepting the card. - attr_accessor :card_acceptor_id + # Unique ID that identifies a store location or transaction point and which refers to the contract number of the merchant accepting the card. + attr_accessor :card_acceptor_id - # Unique reference of the PaymentInformation. In case of card present transactions, the reference from the ECR or terminal will be used. It is always the reference for external transactions. (e.g. card present payments, cash payments or payments processed by other payment providers). - attr_accessor :merchant_reference + # Unique reference of the PaymentInformation. In case of card present transactions, the reference from the ECR or terminal will be used. It is always the reference for external transactions. (e.g. card present payments, cash payments or payments processed by other payment providers). + attr_accessor :merchant_reference - attr_accessor :card_payment_details + attr_accessor :card_payment_details - attr_accessor :events + attr_accessor :events - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'commerce_case_id' => :'commerceCaseId', - :'checkout_id' => :'checkoutId', - :'merchant_customer_id' => :'merchantCustomerId', - :'payment_information_id' => :'paymentInformationId', - :'payment_channel' => :'paymentChannel', - :'payment_product_id' => :'paymentProductId', - :'terminal_id' => :'terminalId', - :'card_acceptor_id' => :'cardAcceptorId', - :'merchant_reference' => :'merchantReference', - :'card_payment_details' => :'cardPaymentDetails', - :'events' => :'events' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'commerce_case_id' => :'commerceCaseId', + :'checkout_id' => :'checkoutId', + :'merchant_customer_id' => :'merchantCustomerId', + :'payment_information_id' => :'paymentInformationId', + :'payment_channel' => :'paymentChannel', + :'payment_product_id' => :'paymentProductId', + :'terminal_id' => :'terminalId', + :'card_acceptor_id' => :'cardAcceptorId', + :'merchant_reference' => :'merchantReference', + :'card_payment_details' => :'cardPaymentDetails', + :'events' => :'events' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'commerce_case_id' => :'String', - :'checkout_id' => :'String', - :'merchant_customer_id' => :'String', - :'payment_information_id' => :'String', - :'payment_channel' => :'PaymentChannel', - :'payment_product_id' => :'Integer', - :'terminal_id' => :'String', - :'card_acceptor_id' => :'String', - :'merchant_reference' => :'String', - :'card_payment_details' => :'CardPaymentDetails', - :'events' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'commerce_case_id' => :'String', + :'checkout_id' => :'String', + :'merchant_customer_id' => :'String', + :'payment_information_id' => :'String', + :'payment_channel' => :'PaymentChannel', + :'payment_product_id' => :'Integer', + :'terminal_id' => :'String', + :'card_acceptor_id' => :'String', + :'merchant_reference' => :'String', + :'card_payment_details' => :'CardPaymentDetails', + :'events' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentInformationResponse` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentInformationResponse` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentInformationResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentInformationResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'commerce_case_id') - self.commerce_case_id = attributes[:'commerce_case_id'] - end + if attributes.key?(:'commerce_case_id') + self.commerce_case_id = attributes[:'commerce_case_id'] + end - if attributes.key?(:'checkout_id') - self.checkout_id = attributes[:'checkout_id'] - end + if attributes.key?(:'checkout_id') + self.checkout_id = attributes[:'checkout_id'] + end - if attributes.key?(:'merchant_customer_id') - self.merchant_customer_id = attributes[:'merchant_customer_id'] - end + if attributes.key?(:'merchant_customer_id') + self.merchant_customer_id = attributes[:'merchant_customer_id'] + end - if attributes.key?(:'payment_information_id') - self.payment_information_id = attributes[:'payment_information_id'] - end + if attributes.key?(:'payment_information_id') + self.payment_information_id = attributes[:'payment_information_id'] + end - if attributes.key?(:'payment_channel') - self.payment_channel = attributes[:'payment_channel'] - end + if attributes.key?(:'payment_channel') + self.payment_channel = attributes[:'payment_channel'] + end - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - if attributes.key?(:'terminal_id') - self.terminal_id = attributes[:'terminal_id'] - end + if attributes.key?(:'terminal_id') + self.terminal_id = attributes[:'terminal_id'] + end - if attributes.key?(:'card_acceptor_id') - self.card_acceptor_id = attributes[:'card_acceptor_id'] - end + if attributes.key?(:'card_acceptor_id') + self.card_acceptor_id = attributes[:'card_acceptor_id'] + end - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + end - if attributes.key?(:'card_payment_details') - self.card_payment_details = attributes[:'card_payment_details'] - end + if attributes.key?(:'card_payment_details') + self.card_payment_details = attributes[:'card_payment_details'] + end - if attributes.key?(:'events') - if (value = attributes[:'events']).is_a?(Array) - self.events = value + if attributes.key?(:'events') + if (value = attributes[:'events']).is_a?(Array) + self.events = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - commerce_case_id == o.commerce_case_id && - checkout_id == o.checkout_id && - merchant_customer_id == o.merchant_customer_id && - payment_information_id == o.payment_information_id && - payment_channel == o.payment_channel && - payment_product_id == o.payment_product_id && - terminal_id == o.terminal_id && - card_acceptor_id == o.card_acceptor_id && - merchant_reference == o.merchant_reference && - card_payment_details == o.card_payment_details && - events == o.events - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + commerce_case_id == o.commerce_case_id && + checkout_id == o.checkout_id && + merchant_customer_id == o.merchant_customer_id && + payment_information_id == o.payment_information_id && + payment_channel == o.payment_channel && + payment_product_id == o.payment_product_id && + terminal_id == o.terminal_id && + card_acceptor_id == o.card_acceptor_id && + merchant_reference == o.merchant_reference && + card_payment_details == o.card_payment_details && + events == o.events + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [commerce_case_id, checkout_id, merchant_customer_id, payment_information_id, payment_channel, payment_product_id, terminal_id, card_acceptor_id, merchant_reference, card_payment_details, events].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [commerce_case_id, checkout_id, merchant_customer_id, payment_information_id, payment_channel, payment_product_id, terminal_id, card_acceptor_id, merchant_reference, card_payment_details, events].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/payment_method_specific_input.rb index 09a58a6..e3458cc 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_method_specific_input.rb @@ -3,259 +3,265 @@ require 'time' # Input for the payment for a respective payment method. In case the paymentMethodSpecificInput has already been provided when creating the Commerce Case or Checkout, it will automatically be used for the Payment Execution. If a new input will be provided, the existing input will be updated. -class PaymentMethodSpecificInput - attr_accessor :card_payment_method_specific_input +module PCPServerSDK + module Models + class PaymentMethodSpecificInput + attr_accessor :card_payment_method_specific_input - attr_accessor :mobile_payment_method_specific_input + attr_accessor :mobile_payment_method_specific_input - attr_accessor :redirect_payment_method_specific_input + attr_accessor :redirect_payment_method_specific_input - attr_accessor :sepa_direct_debit_payment_method_specific_input + attr_accessor :sepa_direct_debit_payment_method_specific_input - attr_accessor :financing_payment_method_specific_input + attr_accessor :financing_payment_method_specific_input - attr_accessor :customer_device + attr_accessor :customer_device - attr_accessor :payment_channel + attr_accessor :payment_channel - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'card_payment_method_specific_input' => :'cardPaymentMethodSpecificInput', - :'mobile_payment_method_specific_input' => :'mobilePaymentMethodSpecificInput', - :'redirect_payment_method_specific_input' => :'redirectPaymentMethodSpecificInput', - :'sepa_direct_debit_payment_method_specific_input' => :'sepaDirectDebitPaymentMethodSpecificInput', - :'financing_payment_method_specific_input' => :'financingPaymentMethodSpecificInput', - :'customer_device' => :'customerDevice', - :'payment_channel' => :'paymentChannel' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'card_payment_method_specific_input' => :'CardPaymentMethodSpecificInput', - :'mobile_payment_method_specific_input' => :'MobilePaymentMethodSpecificInput', - :'redirect_payment_method_specific_input' => :'RedirectPaymentMethodSpecificInput', - :'sepa_direct_debit_payment_method_specific_input' => :'SepaDirectDebitPaymentMethodSpecificInput', - :'financing_payment_method_specific_input' => :'FinancingPaymentMethodSpecificInput', - :'customer_device' => :'CustomerDevice', - :'payment_channel' => :'PaymentChannel' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'card_payment_method_specific_input' => :'cardPaymentMethodSpecificInput', + :'mobile_payment_method_specific_input' => :'mobilePaymentMethodSpecificInput', + :'redirect_payment_method_specific_input' => :'redirectPaymentMethodSpecificInput', + :'sepa_direct_debit_payment_method_specific_input' => :'sepaDirectDebitPaymentMethodSpecificInput', + :'financing_payment_method_specific_input' => :'financingPaymentMethodSpecificInput', + :'customer_device' => :'customerDevice', + :'payment_channel' => :'paymentChannel' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentMethodSpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'card_payment_method_specific_input' => :'CardPaymentMethodSpecificInput', + :'mobile_payment_method_specific_input' => :'MobilePaymentMethodSpecificInput', + :'redirect_payment_method_specific_input' => :'RedirectPaymentMethodSpecificInput', + :'sepa_direct_debit_payment_method_specific_input' => :'SepaDirectDebitPaymentMethodSpecificInput', + :'financing_payment_method_specific_input' => :'FinancingPaymentMethodSpecificInput', + :'customer_device' => :'CustomerDevice', + :'payment_channel' => :'PaymentChannel' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'card_payment_method_specific_input') - self.card_payment_method_specific_input = attributes[:'card_payment_method_specific_input'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentMethodSpecificInput` initialize method" + end - if attributes.key?(:'mobile_payment_method_specific_input') - self.mobile_payment_method_specific_input = attributes[:'mobile_payment_method_specific_input'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'redirect_payment_method_specific_input') - self.redirect_payment_method_specific_input = attributes[:'redirect_payment_method_specific_input'] - end + if attributes.key?(:'card_payment_method_specific_input') + self.card_payment_method_specific_input = attributes[:'card_payment_method_specific_input'] + end - if attributes.key?(:'sepa_direct_debit_payment_method_specific_input') - self.sepa_direct_debit_payment_method_specific_input = attributes[:'sepa_direct_debit_payment_method_specific_input'] - end + if attributes.key?(:'mobile_payment_method_specific_input') + self.mobile_payment_method_specific_input = attributes[:'mobile_payment_method_specific_input'] + end - if attributes.key?(:'financing_payment_method_specific_input') - self.financing_payment_method_specific_input = attributes[:'financing_payment_method_specific_input'] - end + if attributes.key?(:'redirect_payment_method_specific_input') + self.redirect_payment_method_specific_input = attributes[:'redirect_payment_method_specific_input'] + end - if attributes.key?(:'customer_device') - self.customer_device = attributes[:'customer_device'] - end + if attributes.key?(:'sepa_direct_debit_payment_method_specific_input') + self.sepa_direct_debit_payment_method_specific_input = attributes[:'sepa_direct_debit_payment_method_specific_input'] + end - if attributes.key?(:'payment_channel') - self.payment_channel = attributes[:'payment_channel'] - end - end + if attributes.key?(:'financing_payment_method_specific_input') + self.financing_payment_method_specific_input = attributes[:'financing_payment_method_specific_input'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - card_payment_method_specific_input == o.card_payment_method_specific_input && - mobile_payment_method_specific_input == o.mobile_payment_method_specific_input && - redirect_payment_method_specific_input == o.redirect_payment_method_specific_input && - sepa_direct_debit_payment_method_specific_input == o.sepa_direct_debit_payment_method_specific_input && - financing_payment_method_specific_input == o.financing_payment_method_specific_input && - customer_device == o.customer_device && - payment_channel == o.payment_channel - end + if attributes.key?(:'customer_device') + self.customer_device = attributes[:'customer_device'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_channel') + self.payment_channel = attributes[:'payment_channel'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [card_payment_method_specific_input, mobile_payment_method_specific_input, redirect_payment_method_specific_input, sepa_direct_debit_payment_method_specific_input, financing_payment_method_specific_input, customer_device, payment_channel].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + card_payment_method_specific_input == o.card_payment_method_specific_input && + mobile_payment_method_specific_input == o.mobile_payment_method_specific_input && + redirect_payment_method_specific_input == o.redirect_payment_method_specific_input && + sepa_direct_debit_payment_method_specific_input == o.sepa_direct_debit_payment_method_specific_input && + financing_payment_method_specific_input == o.financing_payment_method_specific_input && + customer_device == o.customer_device && + payment_channel == o.payment_channel + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [card_payment_method_specific_input, mobile_payment_method_specific_input, redirect_payment_method_specific_input, sepa_direct_debit_payment_method_specific_input, financing_payment_method_specific_input, customer_device, payment_channel].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_output.rb b/lib/PCP-server-Ruby-SDK/models/payment_output.rb index 0d5f0e7..1c09414 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_output.rb @@ -3,257 +3,261 @@ require 'time' # Object containing payment details. -class PaymentOutput - attr_accessor :amount_of_money +module PCPServerSDK + module Models + class PaymentOutput + attr_accessor :amount_of_money - # It allows you to store additional parameters for the transaction in JSON format. This field should not contain any personal data. - attr_accessor :merchant_parameters + # It allows you to store additional parameters for the transaction in JSON format. This field should not contain any personal data. + attr_accessor :merchant_parameters - attr_accessor :references + attr_accessor :references - attr_accessor :card_payment_method_specific_output + attr_accessor :card_payment_method_specific_output - attr_accessor :mobile_payment_method_specific_output + attr_accessor :mobile_payment_method_specific_output - # Payment method identifier based on the paymentProductId. - attr_accessor :payment_method + # Payment method identifier based on the paymentProductId. + attr_accessor :payment_method - attr_accessor :redirect_payment_method_specific_output + attr_accessor :redirect_payment_method_specific_output - attr_accessor :sepa_direct_debit_payment_method_specific_output + attr_accessor :sepa_direct_debit_payment_method_specific_output - attr_accessor :financing_payment_method_specific_output + attr_accessor :financing_payment_method_specific_output - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'merchant_parameters' => :'merchantParameters', - :'references' => :'references', - :'card_payment_method_specific_output' => :'cardPaymentMethodSpecificOutput', - :'mobile_payment_method_specific_output' => :'mobilePaymentMethodSpecificOutput', - :'payment_method' => :'paymentMethod', - :'redirect_payment_method_specific_output' => :'redirectPaymentMethodSpecificOutput', - :'sepa_direct_debit_payment_method_specific_output' => :'sepaDirectDebitPaymentMethodSpecificOutput', - :'financing_payment_method_specific_output' => :'financingPaymentMethodSpecificOutput' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'merchant_parameters' => :'String', - :'references' => :'PaymentReferences', - :'card_payment_method_specific_output' => :'CardPaymentMethodSpecificOutput', - :'mobile_payment_method_specific_output' => :'MobilePaymentMethodSpecificOutput', - :'payment_method' => :'String', - :'redirect_payment_method_specific_output' => :'RedirectPaymentMethodSpecificOutput', - :'sepa_direct_debit_payment_method_specific_output' => :'SepaDirectDebitPaymentMethodSpecificOutput', - :'financing_payment_method_specific_output' => :'FinancingPaymentMethodSpecificOutput' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'merchant_parameters' => :'merchantParameters', + :'references' => :'references', + :'card_payment_method_specific_output' => :'cardPaymentMethodSpecificOutput', + :'mobile_payment_method_specific_output' => :'mobilePaymentMethodSpecificOutput', + :'payment_method' => :'paymentMethod', + :'redirect_payment_method_specific_output' => :'redirectPaymentMethodSpecificOutput', + :'sepa_direct_debit_payment_method_specific_output' => :'sepaDirectDebitPaymentMethodSpecificOutput', + :'financing_payment_method_specific_output' => :'financingPaymentMethodSpecificOutput' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'merchant_parameters' => :'String', + :'references' => :'PaymentReferences', + :'card_payment_method_specific_output' => :'CardPaymentMethodSpecificOutput', + :'mobile_payment_method_specific_output' => :'MobilePaymentMethodSpecificOutput', + :'payment_method' => :'String', + :'redirect_payment_method_specific_output' => :'RedirectPaymentMethodSpecificOutput', + :'sepa_direct_debit_payment_method_specific_output' => :'SepaDirectDebitPaymentMethodSpecificOutput', + :'financing_payment_method_specific_output' => :'FinancingPaymentMethodSpecificOutput' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentOutput` initialize method" + end - if attributes.key?(:'merchant_parameters') - self.merchant_parameters = attributes[:'merchant_parameters'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'references') - self.references = attributes[:'references'] - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - if attributes.key?(:'card_payment_method_specific_output') - self.card_payment_method_specific_output = attributes[:'card_payment_method_specific_output'] - end + if attributes.key?(:'merchant_parameters') + self.merchant_parameters = attributes[:'merchant_parameters'] + end - if attributes.key?(:'mobile_payment_method_specific_output') - self.mobile_payment_method_specific_output = attributes[:'mobile_payment_method_specific_output'] - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - if attributes.key?(:'payment_method') - self.payment_method = attributes[:'payment_method'] - end + if attributes.key?(:'card_payment_method_specific_output') + self.card_payment_method_specific_output = attributes[:'card_payment_method_specific_output'] + end - if attributes.key?(:'redirect_payment_method_specific_output') - self.redirect_payment_method_specific_output = attributes[:'redirect_payment_method_specific_output'] - end + if attributes.key?(:'mobile_payment_method_specific_output') + self.mobile_payment_method_specific_output = attributes[:'mobile_payment_method_specific_output'] + end - if attributes.key?(:'sepa_direct_debit_payment_method_specific_output') - self.sepa_direct_debit_payment_method_specific_output = attributes[:'sepa_direct_debit_payment_method_specific_output'] - end + if attributes.key?(:'payment_method') + self.payment_method = attributes[:'payment_method'] + end - if attributes.key?(:'financing_payment_method_specific_output') - self.financing_payment_method_specific_output = attributes[:'financing_payment_method_specific_output'] - end - end + if attributes.key?(:'redirect_payment_method_specific_output') + self.redirect_payment_method_specific_output = attributes[:'redirect_payment_method_specific_output'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - merchant_parameters == o.merchant_parameters && - references == o.references && - card_payment_method_specific_output == o.card_payment_method_specific_output && - mobile_payment_method_specific_output == o.mobile_payment_method_specific_output && - payment_method == o.payment_method && - redirect_payment_method_specific_output == o.redirect_payment_method_specific_output && - sepa_direct_debit_payment_method_specific_output == o.sepa_direct_debit_payment_method_specific_output && - financing_payment_method_specific_output == o.financing_payment_method_specific_output - end + if attributes.key?(:'sepa_direct_debit_payment_method_specific_output') + self.sepa_direct_debit_payment_method_specific_output = attributes[:'sepa_direct_debit_payment_method_specific_output'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'financing_payment_method_specific_output') + self.financing_payment_method_specific_output = attributes[:'financing_payment_method_specific_output'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, merchant_parameters, references, card_payment_method_specific_output, mobile_payment_method_specific_output, payment_method, redirect_payment_method_specific_output, sepa_direct_debit_payment_method_specific_output, financing_payment_method_specific_output].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + merchant_parameters == o.merchant_parameters && + references == o.references && + card_payment_method_specific_output == o.card_payment_method_specific_output && + mobile_payment_method_specific_output == o.mobile_payment_method_specific_output && + payment_method == o.payment_method && + redirect_payment_method_specific_output == o.redirect_payment_method_specific_output && + sepa_direct_debit_payment_method_specific_output == o.sepa_direct_debit_payment_method_specific_output && + financing_payment_method_specific_output == o.financing_payment_method_specific_output + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, merchant_parameters, references, card_payment_method_specific_output, mobile_payment_method_specific_output, payment_method, redirect_payment_method_specific_output, sepa_direct_debit_payment_method_specific_output, financing_payment_method_specific_output].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_product320_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/payment_product320_specific_input.rb index b112390..7ff79d9 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_product320_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_product320_specific_input.rb @@ -3,214 +3,220 @@ require 'time' # Object containing additional Information needed for Apple Pay payment transactions. -class PaymentProduct320SpecificInput - attr_accessor :network - - attr_accessor :token - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values +module PCPServerSDK + module Models + class PaymentProduct320SpecificInput + attr_accessor :network + + attr_accessor :token + + + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'network' => :'network', - :'token' => :'token' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'network' => :'String', - :'token' => :'ApplePaymentDataTokenInformation' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'network' => :'network', + :'token' => :'token' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct320SpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'network' => :'String', + :'token' => :'ApplePaymentDataTokenInformation' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct320SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'network') - self.network = attributes[:'network'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct320SpecificInput` initialize method" + end - if attributes.key?(:'token') - self.token = attributes[:'token'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct320SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - network == o.network && - token == o.token - end + if attributes.key?(:'network') + self.network = attributes[:'network'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'token') + self.token = attributes[:'token'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [network, token].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + network == o.network && + token == o.token + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [network, token].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_input.rb index 2f0defe..a4b27a9 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_input.rb @@ -3,197 +3,201 @@ require 'time' # Object containing specific information for PAYONE Secured Installment. -class PaymentProduct3391SpecificInput - # ID of the selected installment option. Will be provided in the response of the Order / Payment Execution request. - attr_accessor :installment_option_id - - attr_accessor :bank_account_information - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'installment_option_id' => :'installmentOptionId', - :'bank_account_information' => :'bankAccountInformation' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'installment_option_id' => :'String', - :'bank_account_information' => :'BankAccountInformation' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end +module PCPServerSDK + module Models + class PaymentProduct3391SpecificInput + # ID of the selected installment option. Will be provided in the response of the Order / Payment Execution request. + attr_accessor :installment_option_id + + attr_accessor :bank_account_information + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'installment_option_id' => :'installmentOptionId', + :'bank_account_information' => :'bankAccountInformation' + } + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct3391SpecificInput` initialize method" - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct3391SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # Attribute type mapping. + def self.openapi_types + { + :'installment_option_id' => :'String', + :'bank_account_information' => :'BankAccountInformation' + } end - h[k.to_sym] = v - } - if attributes.key?(:'installment_option_id') - self.installment_option_id = attributes[:'installment_option_id'] - else - self.installment_option_id = nil - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - if attributes.key?(:'bank_account_information') - self.bank_account_information = attributes[:'bank_account_information'] - else - self.bank_account_information = nil - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct3391SpecificInput` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - installment_option_id == o.installment_option_id && - bank_account_information == o.bank_account_information - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct3391SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'installment_option_id') + self.installment_option_id = attributes[:'installment_option_id'] + else + self.installment_option_id = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'bank_account_information') + self.bank_account_information = attributes[:'bank_account_information'] + else + self.bank_account_information = nil + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [installment_option_id, bank_account_information].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + installment_option_id == o.installment_option_id && + bank_account_information == o.bank_account_information + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [installment_option_id, bank_account_information].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_output.rb index 887b571..da627b4 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_product3391_specific_output.rb @@ -3,186 +3,190 @@ require 'time' # Object containing specific information for PAYONE Secured Installment. -class PaymentProduct3391SpecificOutput - # List of installment options. - attr_accessor :installment_options - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'installment_options' => :'installmentOptions' - } - end +module PCPServerSDK + module Models + class PaymentProduct3391SpecificOutput + # List of installment options. + attr_accessor :installment_options + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'installment_options' => :'installmentOptions' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'installment_options' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'installment_options' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct3391SpecificOutput` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct3391SpecificOutput` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct3391SpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct3391SpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'installment_options') + if (value = attributes[:'installment_options']).is_a?(Array) + self.installment_options = value + end + end end - h[k.to_sym] = v - } - if attributes.key?(:'installment_options') - if (value = attributes[:'installment_options']).is_a?(Array) - self.installment_options = value + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + installment_options == o.installment_options end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - installment_options == o.installment_options - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [installment_options].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [installment_options].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_product3392_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/payment_product3392_specific_input.rb index 790751a..393a47c 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_product3392_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_product3392_specific_input.rb @@ -3,185 +3,189 @@ require 'time' # Object containing specific information for PAYONE Secured Direct. Debit. -class PaymentProduct3392SpecificInput - attr_accessor :bank_account_information - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'bank_account_information' => :'bankAccountInformation' - } - end +module PCPServerSDK + module Models + class PaymentProduct3392SpecificInput + attr_accessor :bank_account_information + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'bank_account_information' => :'bankAccountInformation' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'bank_account_information' => :'BankAccountInformation' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'bank_account_information' => :'BankAccountInformation' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct3392SpecificInput` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct3392SpecificInput` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct3392SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct3392SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'bank_account_information') + self.bank_account_information = attributes[:'bank_account_information'] + else + self.bank_account_information = nil + end end - h[k.to_sym] = v - } - - if attributes.key?(:'bank_account_information') - self.bank_account_information = attributes[:'bank_account_information'] - else - self.bank_account_information = nil - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - bank_account_information == o.bank_account_information - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bank_account_information == o.bank_account_information + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [bank_account_information].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [bank_account_information].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_product771_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/payment_product771_specific_output.rb index 7287c44..3b05f5e 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_product771_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_product771_specific_output.rb @@ -3,184 +3,188 @@ require 'time' # Output that is SEPA Direct Debit specific (i.e. the used mandate). -class PaymentProduct771SpecificOutput - # Unique reference fo a SEPA Mandate - attr_accessor :mandate_reference - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'mandate_reference' => :'mandateReference' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'mandate_reference' => :'String' - } - end +module PCPServerSDK + module Models + class PaymentProduct771SpecificOutput + # Unique reference fo a SEPA Mandate + attr_accessor :mandate_reference + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'mandate_reference' => :'mandateReference' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct771SpecificOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'mandate_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct771SpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'mandate_reference') - self.mandate_reference = attributes[:'mandate_reference'] - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct771SpecificOutput` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - mandate_reference == o.mandate_reference - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct771SpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'mandate_reference') + self.mandate_reference = attributes[:'mandate_reference'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [mandate_reference].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + mandate_reference == o.mandate_reference + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [mandate_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_product840_customer_account.rb b/lib/PCP-server-Ruby-SDK/models/payment_product840_customer_account.rb index 8930326..9acf744 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_product840_customer_account.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_product840_customer_account.rb @@ -3,214 +3,218 @@ require 'time' # Object containing the details of the PayPal account. -class PaymentProduct840CustomerAccount - # Name of the company in case the PayPal account is owned by a business - attr_accessor :company_name - - # First name of the PayPal account holder - attr_accessor :first_name - - # The unique identifier of a PayPal account and will never change in the life cycle of a PayPal account. - attr_accessor :payer_id - - # Surname of the PayPal account holder - attr_accessor :surname - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'company_name' => :'companyName', - :'first_name' => :'firstName', - :'payer_id' => :'payerId', - :'surname' => :'surname' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'company_name' => :'String', - :'first_name' => :'String', - :'payer_id' => :'String', - :'surname' => :'String' - } - end +module PCPServerSDK + module Models + class PaymentProduct840CustomerAccount + # Name of the company in case the PayPal account is owned by a business + attr_accessor :company_name + + # First name of the PayPal account holder + attr_accessor :first_name + + # The unique identifier of a PayPal account and will never change in the life cycle of a PayPal account. + attr_accessor :payer_id + + # Surname of the PayPal account holder + attr_accessor :surname + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'company_name' => :'companyName', + :'first_name' => :'firstName', + :'payer_id' => :'payerId', + :'surname' => :'surname' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct840CustomerAccount` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'company_name' => :'String', + :'first_name' => :'String', + :'payer_id' => :'String', + :'surname' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct840CustomerAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'company_name') - self.company_name = attributes[:'company_name'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct840CustomerAccount` initialize method" + end - if attributes.key?(:'first_name') - self.first_name = attributes[:'first_name'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct840CustomerAccount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'payer_id') - self.payer_id = attributes[:'payer_id'] - end + if attributes.key?(:'company_name') + self.company_name = attributes[:'company_name'] + end - if attributes.key?(:'surname') - self.surname = attributes[:'surname'] - end - end + if attributes.key?(:'first_name') + self.first_name = attributes[:'first_name'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - company_name == o.company_name && - first_name == o.first_name && - payer_id == o.payer_id && - surname == o.surname - end + if attributes.key?(:'payer_id') + self.payer_id = attributes[:'payer_id'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'surname') + self.surname = attributes[:'surname'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [company_name, first_name, payer_id, surname].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + company_name == o.company_name && + first_name == o.first_name && + payer_id == o.payer_id && + surname == o.surname + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [company_name, first_name, payer_id, surname].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output.rb index 2ae77a6..6abdd2c 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output.rb @@ -3,201 +3,205 @@ require 'time' # PayPal (payment product 840) specific details. -class PaymentProduct840SpecificOutput - attr_accessor :billing_address +module PCPServerSDK + module Models + class PaymentProduct840SpecificOutput + attr_accessor :billing_address + + attr_accessor :customer_account + + attr_accessor :shipping_address + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'billing_address' => :'billingAddress', + :'customer_account' => :'customerAccount', + :'shipping_address' => :'shippingAddress' + } + end - attr_accessor :customer_account + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :shipping_address + # Attribute type mapping. + def self.openapi_types + { + :'billing_address' => :'Address', + :'customer_account' => :'PaymentProduct840CustomerAccount', + :'shipping_address' => :'Address' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'billing_address' => :'billingAddress', - :'customer_account' => :'customerAccount', - :'shipping_address' => :'shippingAddress' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct840SpecificOutput` initialize method" + end - # Attribute type mapping. - def self.openapi_types - { - :'billing_address' => :'Address', - :'customer_account' => :'PaymentProduct840CustomerAccount', - :'shipping_address' => :'Address' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct840SpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'billing_address') + self.billing_address = attributes[:'billing_address'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentProduct840SpecificOutput` initialize method" - end + if attributes.key?(:'customer_account') + self.customer_account = attributes[:'customer_account'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentProduct840SpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'shipping_address') + self.shipping_address = attributes[:'shipping_address'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'billing_address') - self.billing_address = attributes[:'billing_address'] - end - - if attributes.key?(:'customer_account') - self.customer_account = attributes[:'customer_account'] - end - - if attributes.key?(:'shipping_address') - self.shipping_address = attributes[:'shipping_address'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - billing_address == o.billing_address && - customer_account == o.customer_account && - shipping_address == o.shipping_address - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + billing_address == o.billing_address && + customer_account == o.customer_account && + shipping_address == o.shipping_address + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [billing_address, customer_account, shipping_address].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [billing_address, customer_account, shipping_address].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_references.rb b/lib/PCP-server-Ruby-SDK/models/payment_references.rb index e46ecaa..a50ad78 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_references.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_references.rb @@ -3,184 +3,188 @@ require 'time' # Object that holds all reference properties that are linked to this transaction. -class PaymentReferences - # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. - attr_accessor :merchant_reference - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'merchant_reference' => :'merchantReference' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'merchant_reference' => :'String' - } - end +module PCPServerSDK + module Models + class PaymentReferences + # Unique reference of the Commerce Case that is also returned for reporting and reconciliation purposes. + attr_accessor :merchant_reference + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'merchant_reference' => :'merchantReference' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentReferences` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'merchant_reference' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentReferences`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentReferences` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - merchant_reference == o.merchant_reference - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentReferences`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [merchant_reference].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + merchant_reference == o.merchant_reference + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [merchant_reference].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_response.rb b/lib/PCP-server-Ruby-SDK/models/payment_response.rb index f2356ab..3cf85ee 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_response.rb @@ -3,233 +3,239 @@ require 'time' # Object that holds the payment related properties. -class PaymentResponse - attr_accessor :payment_output +module PCPServerSDK + module Models + class PaymentResponse + attr_accessor :payment_output - attr_accessor :status + attr_accessor :status - attr_accessor :status_output + attr_accessor :status_output - # Unique payment transaction identifier of the payment gateway. - attr_accessor :id + # Unique payment transaction identifier of the payment gateway. + attr_accessor :id - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_output' => :'paymentOutput', - :'status' => :'status', - :'status_output' => :'statusOutput', - :'id' => :'id' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_output' => :'PaymentOutput', - :'status' => :'StatusValue', - :'status_output' => :'PaymentStatusOutput', - :'id' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_output' => :'paymentOutput', + :'status' => :'status', + :'status_output' => :'statusOutput', + :'id' => :'id' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentResponse` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_output' => :'PaymentOutput', + :'status' => :'StatusValue', + :'status_output' => :'PaymentStatusOutput', + :'id' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_output') - self.payment_output = attributes[:'payment_output'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentResponse` initialize method" + end - if attributes.key?(:'status') - self.status = attributes[:'status'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'status_output') - self.status_output = attributes[:'status_output'] - end + if attributes.key?(:'payment_output') + self.payment_output = attributes[:'payment_output'] + end - if attributes.key?(:'id') - self.id = attributes[:'id'] - end - end + if attributes.key?(:'status') + self.status = attributes[:'status'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_output == o.payment_output && - status == o.status && - status_output == o.status_output && - id == o.id - end + if attributes.key?(:'status_output') + self.status_output = attributes[:'status_output'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_output, status, status_output, id].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_output == o.payment_output && + status == o.status && + status_output == o.status_output && + id == o.id + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_output, status, status_output, id].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_status_output.rb b/lib/PCP-server-Ruby-SDK/models/payment_status_output.rb index 6102e7a..544463f 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_status_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_status_output.rb @@ -3,235 +3,241 @@ require 'time' # This object has the numeric representation of the current payment status, timestamp of last status change and performable action on the current payment resource. In case of failed payments and negative scenarios, detailed error information is listed. -class PaymentStatusOutput - # Flag indicating if the payment can be cancelled - attr_accessor :is_cancellable +module PCPServerSDK + module Models + class PaymentStatusOutput + # Flag indicating if the payment can be cancelled + attr_accessor :is_cancellable - attr_accessor :status_category + attr_accessor :status_category - # Indicates if the transaction has been authorized - attr_accessor :is_authorized + # Indicates if the transaction has been authorized + attr_accessor :is_authorized - # Flag indicating if the payment can be refunded - attr_accessor :is_refundable + # Flag indicating if the payment can be refunded + attr_accessor :is_refundable - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'is_cancellable' => :'isCancellable', - :'status_category' => :'statusCategory', - :'is_authorized' => :'isAuthorized', - :'is_refundable' => :'isRefundable' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'is_cancellable' => :'Boolean', - :'status_category' => :'StatusCategoryValue', - :'is_authorized' => :'Boolean', - :'is_refundable' => :'Boolean' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'is_cancellable' => :'isCancellable', + :'status_category' => :'statusCategory', + :'is_authorized' => :'isAuthorized', + :'is_refundable' => :'isRefundable' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentStatusOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'is_cancellable' => :'Boolean', + :'status_category' => :'StatusCategoryValue', + :'is_authorized' => :'Boolean', + :'is_refundable' => :'Boolean' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentStatusOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'is_cancellable') - self.is_cancellable = attributes[:'is_cancellable'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PaymentStatusOutput` initialize method" + end - if attributes.key?(:'status_category') - self.status_category = attributes[:'status_category'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PaymentStatusOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'is_authorized') - self.is_authorized = attributes[:'is_authorized'] - end + if attributes.key?(:'is_cancellable') + self.is_cancellable = attributes[:'is_cancellable'] + end - if attributes.key?(:'is_refundable') - self.is_refundable = attributes[:'is_refundable'] - end - end + if attributes.key?(:'status_category') + self.status_category = attributes[:'status_category'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - is_cancellable == o.is_cancellable && - status_category == o.status_category && - is_authorized == o.is_authorized && - is_refundable == o.is_refundable - end + if attributes.key?(:'is_authorized') + self.is_authorized = attributes[:'is_authorized'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'is_refundable') + self.is_refundable = attributes[:'is_refundable'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [is_cancellable, status_category, is_authorized, is_refundable].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + is_cancellable == o.is_cancellable && + status_category == o.status_category && + is_authorized == o.is_authorized && + is_refundable == o.is_refundable + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [is_cancellable, status_category, is_authorized, is_refundable].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payment_type.rb b/lib/PCP-server-Ruby-SDK/models/payment_type.rb index 1b259b4..4b8749f 100644 --- a/lib/PCP-server-Ruby-SDK/models/payment_type.rb +++ b/lib/PCP-server-Ruby-SDK/models/payment_type.rb @@ -2,32 +2,36 @@ require 'date' require 'time' -class PaymentType - SALE = "SALE".freeze - RESERVATION = "RESERVATION".freeze - CAPTURE = "CAPTURE".freeze - REFUND = "REFUND".freeze - REVERSAL = "REVERSAL".freeze - CHARGEBACK_REVERSAL = "CHARGEBACK_REVERSAL".freeze - CREDIT_NOTE = "CREDIT_NOTE".freeze - DEBIT_NOTE = "DEBIT_NOTE".freeze +module PCPServerSDK + module Models + class PaymentType + SALE = "SALE".freeze + RESERVATION = "RESERVATION".freeze + CAPTURE = "CAPTURE".freeze + REFUND = "REFUND".freeze + REVERSAL = "REVERSAL".freeze + CHARGEBACK_REVERSAL = "CHARGEBACK_REVERSAL".freeze + CREDIT_NOTE = "CREDIT_NOTE".freeze + DEBIT_NOTE = "DEBIT_NOTE".freeze - def self.all_vars - @all_vars ||= [SALE, RESERVATION, CAPTURE, REFUND, REVERSAL, CHARGEBACK_REVERSAL, CREDIT_NOTE, DEBIT_NOTE].freeze - end + def self.all_vars + @all_vars ||= [SALE, RESERVATION, CAPTURE, REFUND, REVERSAL, CHARGEBACK_REVERSAL, CREDIT_NOTE, DEBIT_NOTE].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if PaymentType.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #PaymentType" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if PaymentType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #PaymentType" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payout_output.rb b/lib/PCP-server-Ruby-SDK/models/payout_output.rb index f951d3d..a827a3d 100644 --- a/lib/PCP-server-Ruby-SDK/models/payout_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/payout_output.rb @@ -3,202 +3,206 @@ require 'time' # Object containing details from the created payout. -class PayoutOutput - attr_accessor :amount_of_money +module PCPServerSDK + module Models + class PayoutOutput + attr_accessor :amount_of_money + + attr_accessor :references + + # Payment method identifier based on the paymentProductId. + attr_accessor :payment_method + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'references' => :'references', + :'payment_method' => :'paymentMethod' + } + end - attr_accessor :references + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Payment method identifier based on the paymentProductId. - attr_accessor :payment_method + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'references' => :'PaymentReferences', + :'payment_method' => :'String' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'references' => :'references', - :'payment_method' => :'paymentMethod' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PayoutOutput` initialize method" + end - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'references' => :'PaymentReferences', - :'payment_method' => :'String' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PayoutOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PayoutOutput` initialize method" - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PayoutOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_method') + self.payment_method = attributes[:'payment_method'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end - - if attributes.key?(:'references') - self.references = attributes[:'references'] - end - - if attributes.key?(:'payment_method') - self.payment_method = attributes[:'payment_method'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - references == o.references && - payment_method == o.payment_method - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + references == o.references && + payment_method == o.payment_method + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, references, payment_method].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, references, payment_method].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/payout_response.rb b/lib/PCP-server-Ruby-SDK/models/payout_response.rb index c393591..a7a8ee0 100644 --- a/lib/PCP-server-Ruby-SDK/models/payout_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/payout_response.rb @@ -3,233 +3,239 @@ require 'time' # Object that holds the payment related properties for the refund of a Payment Information. -class PayoutResponse - attr_accessor :payout_output +module PCPServerSDK + module Models + class PayoutResponse + attr_accessor :payout_output - attr_accessor :status + attr_accessor :status - attr_accessor :status_category + attr_accessor :status_category - # Unique payment transaction identifier of the payment gateway. - attr_accessor :id + # Unique payment transaction identifier of the payment gateway. + attr_accessor :id - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payout_output' => :'payoutOutput', - :'status' => :'status', - :'status_category' => :'statusCategory', - :'id' => :'id' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'payout_output' => :'PayoutOutput', - :'status' => :'StatusValue', - :'status_category' => :'StatusCategoryValue', - :'id' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payout_output' => :'payoutOutput', + :'status' => :'status', + :'status_category' => :'statusCategory', + :'id' => :'id' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PayoutResponse` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payout_output' => :'PayoutOutput', + :'status' => :'StatusValue', + :'status_category' => :'StatusCategoryValue', + :'id' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PayoutResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payout_output') - self.payout_output = attributes[:'payout_output'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PayoutResponse` initialize method" + end - if attributes.key?(:'status') - self.status = attributes[:'status'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PayoutResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'status_category') - self.status_category = attributes[:'status_category'] - end + if attributes.key?(:'payout_output') + self.payout_output = attributes[:'payout_output'] + end - if attributes.key?(:'id') - self.id = attributes[:'id'] - end - end + if attributes.key?(:'status') + self.status = attributes[:'status'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payout_output == o.payout_output && - status == o.status && - status_category == o.status_category && - id == o.id - end + if attributes.key?(:'status_category') + self.status_category = attributes[:'status_category'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payout_output, status, status_category, id].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payout_output == o.payout_output && + status == o.status && + status_category == o.status_category && + id == o.id + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payout_output, status, status_category, id].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/personal_information.rb b/lib/PCP-server-Ruby-SDK/models/personal_information.rb index 1125f21..bb64db8 100644 --- a/lib/PCP-server-Ruby-SDK/models/personal_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/personal_information.rb @@ -3,225 +3,231 @@ require 'time' # Object containing personal information like name, date of birth and gender. -class PersonalInformation - # The date of birth of the customer of the recipient of the loan. Format YYYYMMDD - attr_accessor :date_of_birth - - # The gender of the customer, possible values are: * MALE * FEMALE * UNKNOWN - attr_accessor :gender - - attr_accessor :name - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values +module PCPServerSDK + module Models + class PersonalInformation + # The date of birth of the customer of the recipient of the loan. Format YYYYMMDD + attr_accessor :date_of_birth + + # The gender of the customer, possible values are: * MALE * FEMALE * UNKNOWN + attr_accessor :gender + + attr_accessor :name + + + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'date_of_birth' => :'dateOfBirth', - :'gender' => :'gender', - :'name' => :'name' - } - end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'date_of_birth' => :'String', - :'gender' => :'String', - :'name' => :'PersonalName' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'date_of_birth' => :'dateOfBirth', + :'gender' => :'gender', + :'name' => :'name' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PersonalInformation` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'date_of_birth' => :'String', + :'gender' => :'String', + :'name' => :'PersonalName' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PersonalInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'date_of_birth') - self.date_of_birth = attributes[:'date_of_birth'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PersonalInformation` initialize method" + end - if attributes.key?(:'gender') - self.gender = attributes[:'gender'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PersonalInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'name') - self.name = attributes[:'name'] - end - end + if attributes.key?(:'date_of_birth') + self.date_of_birth = attributes[:'date_of_birth'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - date_of_birth == o.date_of_birth && - gender == o.gender && - name == o.name - end + if attributes.key?(:'gender') + self.gender = attributes[:'gender'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [date_of_birth, gender, name].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + date_of_birth == o.date_of_birth && + gender == o.gender && + name == o.name + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [date_of_birth, gender, name].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/personal_name.rb b/lib/PCP-server-Ruby-SDK/models/personal_name.rb index be20d00..65bd20c 100644 --- a/lib/PCP-server-Ruby-SDK/models/personal_name.rb +++ b/lib/PCP-server-Ruby-SDK/models/personal_name.rb @@ -3,204 +3,208 @@ require 'time' # Object containing the name details of the customer -class PersonalName - # Given name(s) or first name(s) of the customer - attr_accessor :first_name - - # Surname(s) or last name(s) of the customer - attr_accessor :surname - - # Title of customer - attr_accessor :title - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'first_name' => :'firstName', - :'surname' => :'surname', - :'title' => :'title' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'first_name' => :'String', - :'surname' => :'String', - :'title' => :'String' - } - end +module PCPServerSDK + module Models + class PersonalName + # Given name(s) or first name(s) of the customer + attr_accessor :first_name + + # Surname(s) or last name(s) of the customer + attr_accessor :surname + + # Title of customer + attr_accessor :title + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'first_name' => :'firstName', + :'surname' => :'surname', + :'title' => :'title' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PersonalName` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'first_name' => :'String', + :'surname' => :'String', + :'title' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PersonalName`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'first_name') - self.first_name = attributes[:'first_name'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PersonalName` initialize method" + end - if attributes.key?(:'surname') - self.surname = attributes[:'surname'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PersonalName`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'title') - self.title = attributes[:'title'] - end - end + if attributes.key?(:'first_name') + self.first_name = attributes[:'first_name'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - first_name == o.first_name && - surname == o.surname && - title == o.title - end + if attributes.key?(:'surname') + self.surname = attributes[:'surname'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'title') + self.title = attributes[:'title'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [first_name, surname, title].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + first_name == o.first_name && + surname == o.surname && + title == o.title + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [first_name, surname, title].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/positive_amount_of_money.rb b/lib/PCP-server-Ruby-SDK/models/positive_amount_of_money.rb index 07b5192..6ae8da4 100644 --- a/lib/PCP-server-Ruby-SDK/models/positive_amount_of_money.rb +++ b/lib/PCP-server-Ruby-SDK/models/positive_amount_of_money.rb @@ -3,198 +3,202 @@ require 'time' # Object containing amount and ISO currency code attributes -class PositiveAmountOfMoney - # Amount in cents and always having 2 decimals - attr_accessor :amount - - # Three-letter ISO currency code representing the currency for the amount - attr_accessor :currency_code - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount' => :'amount', - :'currency_code' => :'currencyCode' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'amount' => :'Integer', - :'currency_code' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end +module PCPServerSDK + module Models + class PositiveAmountOfMoney + # Amount in cents and always having 2 decimals + attr_accessor :amount + + # Three-letter ISO currency code representing the currency for the amount + attr_accessor :currency_code + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount' => :'amount', + :'currency_code' => :'currencyCode' + } + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `PositiveAmountOfMoney` initialize method" - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `PositiveAmountOfMoney`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # Attribute type mapping. + def self.openapi_types + { + :'amount' => :'Integer', + :'currency_code' => :'String' + } end - h[k.to_sym] = v - } - if attributes.key?(:'amount') - self.amount = attributes[:'amount'] - else - self.amount = nil - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - if attributes.key?(:'currency_code') - self.currency_code = attributes[:'currency_code'] - else - self.currency_code = nil - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `PositiveAmountOfMoney` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount == o.amount && - currency_code == o.currency_code - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `PositiveAmountOfMoney`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'amount') + self.amount = attributes[:'amount'] + else + self.amount = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'currency_code') + self.currency_code = attributes[:'currency_code'] + else + self.currency_code = nil + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount, currency_code].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount == o.amount && + currency_code == o.currency_code + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount, currency_code].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/processing_mandate_information.rb b/lib/PCP-server-Ruby-SDK/models/processing_mandate_information.rb index 046e78f..9d82935 100644 --- a/lib/PCP-server-Ruby-SDK/models/processing_mandate_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/processing_mandate_information.rb @@ -3,254 +3,260 @@ require 'time' # Object containing the relevant information of a SEPA Direct Debit mandate for processing (mandatory fields in pain.008). Renamed from CreateMandateWithReturnUrl to ProcessingMandateInformation. -class ProcessingMandateInformation - attr_accessor :bank_account_iban +module PCPServerSDK + module Models + class ProcessingMandateInformation + attr_accessor :bank_account_iban - attr_accessor :recurrence_type + attr_accessor :recurrence_type - # The unique identifier of the mandate - attr_accessor :unique_mandate_reference + # The unique identifier of the mandate + attr_accessor :unique_mandate_reference - # The date of signature of the mandate. Format YYYYMMDD - attr_accessor :date_of_signature + # The date of signature of the mandate. Format YYYYMMDD + attr_accessor :date_of_signature - # Your unique creditor identifier. - attr_accessor :creditor_id + # Your unique creditor identifier. + attr_accessor :creditor_id - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'bank_account_iban' => :'bankAccountIban', - :'recurrence_type' => :'recurrenceType', - :'unique_mandate_reference' => :'uniqueMandateReference', - :'date_of_signature' => :'dateOfSignature', - :'creditor_id' => :'creditorId' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'bank_account_iban' => :'BankAccountInformation', - :'recurrence_type' => :'MandateRecurrenceType', - :'unique_mandate_reference' => :'String', - :'date_of_signature' => :'String', - :'creditor_id' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'bank_account_iban' => :'bankAccountIban', + :'recurrence_type' => :'recurrenceType', + :'unique_mandate_reference' => :'uniqueMandateReference', + :'date_of_signature' => :'dateOfSignature', + :'creditor_id' => :'creditorId' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ProcessingMandateInformation` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'bank_account_iban' => :'BankAccountInformation', + :'recurrence_type' => :'MandateRecurrenceType', + :'unique_mandate_reference' => :'String', + :'date_of_signature' => :'String', + :'creditor_id' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ProcessingMandateInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'bank_account_iban') - self.bank_account_iban = attributes[:'bank_account_iban'] - else - self.bank_account_iban = nil - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ProcessingMandateInformation` initialize method" + end - if attributes.key?(:'recurrence_type') - self.recurrence_type = attributes[:'recurrence_type'] - else - self.recurrence_type = nil - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ProcessingMandateInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'unique_mandate_reference') - self.unique_mandate_reference = attributes[:'unique_mandate_reference'] - else - self.unique_mandate_reference = nil - end + if attributes.key?(:'bank_account_iban') + self.bank_account_iban = attributes[:'bank_account_iban'] + else + self.bank_account_iban = nil + end - if attributes.key?(:'date_of_signature') - self.date_of_signature = attributes[:'date_of_signature'] - else - self.date_of_signature = nil - end + if attributes.key?(:'recurrence_type') + self.recurrence_type = attributes[:'recurrence_type'] + else + self.recurrence_type = nil + end - if attributes.key?(:'creditor_id') - self.creditor_id = attributes[:'creditor_id'] - else - self.creditor_id = nil - end - end + if attributes.key?(:'unique_mandate_reference') + self.unique_mandate_reference = attributes[:'unique_mandate_reference'] + else + self.unique_mandate_reference = nil + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - bank_account_iban == o.bank_account_iban && - recurrence_type == o.recurrence_type && - unique_mandate_reference == o.unique_mandate_reference && - date_of_signature == o.date_of_signature && - creditor_id == o.creditor_id - end + if attributes.key?(:'date_of_signature') + self.date_of_signature = attributes[:'date_of_signature'] + else + self.date_of_signature = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'creditor_id') + self.creditor_id = attributes[:'creditor_id'] + else + self.creditor_id = nil + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [bank_account_iban, recurrence_type, unique_mandate_reference, date_of_signature, creditor_id].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + bank_account_iban == o.bank_account_iban && + recurrence_type == o.recurrence_type && + unique_mandate_reference == o.unique_mandate_reference && + date_of_signature == o.date_of_signature && + creditor_id == o.creditor_id + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [bank_account_iban, recurrence_type, unique_mandate_reference, date_of_signature, creditor_id].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/product_type.rb b/lib/PCP-server-Ruby-SDK/models/product_type.rb index f550219..6812faa 100644 --- a/lib/PCP-server-Ruby-SDK/models/product_type.rb +++ b/lib/PCP-server-Ruby-SDK/models/product_type.rb @@ -2,28 +2,32 @@ require 'date' require 'time' -class ProductType - GOODS = "GOODS".freeze - SHIPMENT = "SHIPMENT".freeze - HANDLING_FEE = "HANDLING_FEE".freeze - DISCOUNT = "DISCOUNT".freeze +module PCPServerSDK + module Models + class ProductType + GOODS = "GOODS".freeze + SHIPMENT = "SHIPMENT".freeze + HANDLING_FEE = "HANDLING_FEE".freeze + DISCOUNT = "DISCOUNT".freeze - def self.all_vars - @all_vars ||= [GOODS, SHIPMENT, HANDLING_FEE, DISCOUNT].freeze - end + def self.all_vars + @all_vars ||= [GOODS, SHIPMENT, HANDLING_FEE, DISCOUNT].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if ProductType.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #ProductType" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ProductType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ProductType" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/redirect_data.rb b/lib/PCP-server-Ruby-SDK/models/redirect_data.rb index 5b4c26a..6215f99 100644 --- a/lib/PCP-server-Ruby-SDK/models/redirect_data.rb +++ b/lib/PCP-server-Ruby-SDK/models/redirect_data.rb @@ -3,184 +3,188 @@ require 'time' # Object containing all data needed to redirect the customer. -class RedirectData - # The URL that the customer should be redirected to. Be sure to redirect using the GET method - attr_accessor :redirect_url - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'redirect_url' => :'redirectURL' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'redirect_url' => :'String' - } - end +module PCPServerSDK + module Models + class RedirectData + # The URL that the customer should be redirected to. Be sure to redirect using the GET method + attr_accessor :redirect_url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'redirect_url' => :'redirectURL' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectData` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'redirect_url' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'redirect_url') - self.redirect_url = attributes[:'redirect_url'] - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectData` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - redirect_url == o.redirect_url - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'redirect_url') + self.redirect_url = attributes[:'redirect_url'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [redirect_url].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + redirect_url == o.redirect_url + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [redirect_url].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input.rb index 0c72081..0a04d00 100644 --- a/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input.rb @@ -3,242 +3,246 @@ require 'time' # Object containing the specific input details for payments that involve redirects to 3rd parties to complete, like iDeal and PayPal -class RedirectPaymentMethodSpecificInput - # * true = the payment requires approval before the funds will be captured using the Approve payment or Capture payment API * false = the payment does not require approval, and the funds will be captured automatically If the parameter is not provided in the request, the default value will be true - attr_accessor :requires_approval +module PCPServerSDK + module Models + class RedirectPaymentMethodSpecificInput + # * true = the payment requires approval before the funds will be captured using the Approve payment or Capture payment API * false = the payment does not require approval, and the funds will be captured automatically If the parameter is not provided in the request, the default value will be true + attr_accessor :requires_approval + + # ID of the token to use to create the payment. + attr_accessor :payment_processing_token + + # Token to identify the card in the reporting. + attr_accessor :reporting_token + + # Indicates if this transaction should be tokenized * true - Tokenize the transaction. * false - Do not tokenize the transaction, unless it would be tokenized by other means such as auto- tokenization of recurring payments. example: false + attr_accessor :tokenize + + # Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id + + attr_accessor :payment_product840_specific_input + + attr_accessor :redirection_data + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'requires_approval' => :'requiresApproval', + :'payment_processing_token' => :'paymentProcessingToken', + :'reporting_token' => :'reportingToken', + :'tokenize' => :'tokenize', + :'payment_product_id' => :'paymentProductId', + :'payment_product840_specific_input' => :'paymentProduct840SpecificInput', + :'redirection_data' => :'redirectionData' + } + end - # ID of the token to use to create the payment. - attr_accessor :payment_processing_token + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Token to identify the card in the reporting. - attr_accessor :reporting_token + # Attribute type mapping. + def self.openapi_types + { + :'requires_approval' => :'Boolean', + :'payment_processing_token' => :'String', + :'reporting_token' => :'String', + :'tokenize' => :'Boolean', + :'payment_product_id' => :'Integer', + :'payment_product840_specific_input' => :'RedirectPaymentProduct840SpecificInput', + :'redirection_data' => :'RedirectionData' + } + end - # Indicates if this transaction should be tokenized * true - Tokenize the transaction. * false - Do not tokenize the transaction, unless it would be tokenized by other means such as auto- tokenization of recurring payments. example: false - attr_accessor :tokenize + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectPaymentMethodSpecificInput` initialize method" + end - attr_accessor :payment_product840_specific_input + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - attr_accessor :redirection_data + if attributes.key?(:'requires_approval') + self.requires_approval = attributes[:'requires_approval'] + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'requires_approval' => :'requiresApproval', - :'payment_processing_token' => :'paymentProcessingToken', - :'reporting_token' => :'reportingToken', - :'tokenize' => :'tokenize', - :'payment_product_id' => :'paymentProductId', - :'payment_product840_specific_input' => :'paymentProduct840SpecificInput', - :'redirection_data' => :'redirectionData' - } - end + if attributes.key?(:'payment_processing_token') + self.payment_processing_token = attributes[:'payment_processing_token'] + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + if attributes.key?(:'reporting_token') + self.reporting_token = attributes[:'reporting_token'] + end - # Attribute type mapping. - def self.openapi_types - { - :'requires_approval' => :'Boolean', - :'payment_processing_token' => :'String', - :'reporting_token' => :'String', - :'tokenize' => :'Boolean', - :'payment_product_id' => :'Integer', - :'payment_product840_specific_input' => :'RedirectPaymentProduct840SpecificInput', - :'redirection_data' => :'RedirectionData' - } - end + if attributes.key?(:'tokenize') + self.tokenize = attributes[:'tokenize'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectPaymentMethodSpecificInput` initialize method" - end + if attributes.key?(:'payment_product840_specific_input') + self.payment_product840_specific_input = attributes[:'payment_product840_specific_input'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'redirection_data') + self.redirection_data = attributes[:'redirection_data'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'requires_approval') - self.requires_approval = attributes[:'requires_approval'] - end - - if attributes.key?(:'payment_processing_token') - self.payment_processing_token = attributes[:'payment_processing_token'] - end - - if attributes.key?(:'reporting_token') - self.reporting_token = attributes[:'reporting_token'] - end - - if attributes.key?(:'tokenize') - self.tokenize = attributes[:'tokenize'] - end - - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end - - if attributes.key?(:'payment_product840_specific_input') - self.payment_product840_specific_input = attributes[:'payment_product840_specific_input'] - end - if attributes.key?(:'redirection_data') - self.redirection_data = attributes[:'redirection_data'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - requires_approval == o.requires_approval && - payment_processing_token == o.payment_processing_token && - reporting_token == o.reporting_token && - tokenize == o.tokenize && - payment_product_id == o.payment_product_id && - payment_product840_specific_input == o.payment_product840_specific_input && - redirection_data == o.redirection_data - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + requires_approval == o.requires_approval && + payment_processing_token == o.payment_processing_token && + reporting_token == o.reporting_token && + tokenize == o.tokenize && + payment_product_id == o.payment_product_id && + payment_product840_specific_input == o.payment_product840_specific_input && + redirection_data == o.redirection_data + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [requires_approval, payment_processing_token, reporting_token, tokenize, payment_product_id, payment_product840_specific_input, redirection_data].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [requires_approval, payment_processing_token, reporting_token, tokenize, payment_product_id, payment_product840_specific_input, redirection_data].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output.rb index 2303c69..c8d7abe 100644 --- a/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output.rb @@ -3,213 +3,217 @@ require 'time' # Object containing the redirect payment product details. -class RedirectPaymentMethodSpecificOutput - # <- Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id - - attr_accessor :payment_product840_specific_output - - # ID of the token. This property is populated when the payment was done with a token. - attr_accessor :payment_processing_token - - # Token to identify the card in the reporting. - attr_accessor :reporting_token - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'payment_product840_specific_output' => :'paymentProduct840SpecificOutput', - :'payment_processing_token' => :'paymentProcessingToken', - :'reporting_token' => :'reportingToken' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'payment_product840_specific_output' => :'PaymentProduct840SpecificOutput', - :'payment_processing_token' => :'String', - :'reporting_token' => :'String' - } - end +module PCPServerSDK + module Models + class RedirectPaymentMethodSpecificOutput + # <- Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id + + attr_accessor :payment_product840_specific_output + + # ID of the token. This property is populated when the payment was done with a token. + attr_accessor :payment_processing_token + + # Token to identify the card in the reporting. + attr_accessor :reporting_token + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'payment_product840_specific_output' => :'paymentProduct840SpecificOutput', + :'payment_processing_token' => :'paymentProcessingToken', + :'reporting_token' => :'reportingToken' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectPaymentMethodSpecificOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'payment_product840_specific_output' => :'PaymentProduct840SpecificOutput', + :'payment_processing_token' => :'String', + :'reporting_token' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectPaymentMethodSpecificOutput` initialize method" + end - if attributes.key?(:'payment_product840_specific_output') - self.payment_product840_specific_output = attributes[:'payment_product840_specific_output'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'payment_processing_token') - self.payment_processing_token = attributes[:'payment_processing_token'] - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - if attributes.key?(:'reporting_token') - self.reporting_token = attributes[:'reporting_token'] - end - end + if attributes.key?(:'payment_product840_specific_output') + self.payment_product840_specific_output = attributes[:'payment_product840_specific_output'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - payment_product840_specific_output == o.payment_product840_specific_output && - payment_processing_token == o.payment_processing_token && - reporting_token == o.reporting_token - end + if attributes.key?(:'payment_processing_token') + self.payment_processing_token = attributes[:'payment_processing_token'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'reporting_token') + self.reporting_token = attributes[:'reporting_token'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, payment_product840_specific_output, payment_processing_token, reporting_token].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + payment_product840_specific_output == o.payment_product840_specific_output && + payment_processing_token == o.payment_processing_token && + reporting_token == o.reporting_token + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, payment_product840_specific_output, payment_processing_token, reporting_token].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/redirect_payment_product840_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/redirect_payment_product840_specific_input.rb index aa99ee1..0e45371 100644 --- a/lib/PCP-server-Ruby-SDK/models/redirect_payment_product840_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/redirect_payment_product840_specific_input.rb @@ -3,184 +3,188 @@ require 'time' # Object containing specific input required for PayPal payments (Payment product ID 840) -class RedirectPaymentProduct840SpecificInput - # Indicates whether to use PayPal Express Checkout Shortcut. * true = When shortcut is enabled, the consumer can select a shipping address during PayPal checkout. * false = When shortcut is disabled, the consumer cannot change the shipping address. Default value is false. Please note that this field is ignored when order.additionalInput.typeInformation.purchaseType is set to \"digital\" - attr_accessor :address_selection_at_pay_pal - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'address_selection_at_pay_pal' => :'addressSelectionAtPayPal' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'address_selection_at_pay_pal' => :'Boolean' - } - end +module PCPServerSDK + module Models + class RedirectPaymentProduct840SpecificInput + # Indicates whether to use PayPal Express Checkout Shortcut. * true = When shortcut is enabled, the consumer can select a shipping address during PayPal checkout. * false = When shortcut is disabled, the consumer cannot change the shipping address. Default value is false. Please note that this field is ignored when order.additionalInput.typeInformation.purchaseType is set to \"digital\" + attr_accessor :address_selection_at_pay_pal + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'address_selection_at_pay_pal' => :'addressSelectionAtPayPal' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectPaymentProduct840SpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'address_selection_at_pay_pal' => :'Boolean' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectPaymentProduct840SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'address_selection_at_pay_pal') - self.address_selection_at_pay_pal = attributes[:'address_selection_at_pay_pal'] - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectPaymentProduct840SpecificInput` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - address_selection_at_pay_pal == o.address_selection_at_pay_pal - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectPaymentProduct840SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'address_selection_at_pay_pal') + self.address_selection_at_pay_pal = attributes[:'address_selection_at_pay_pal'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [address_selection_at_pay_pal].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + address_selection_at_pay_pal == o.address_selection_at_pay_pal + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [address_selection_at_pay_pal].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/redirection_data.rb b/lib/PCP-server-Ruby-SDK/models/redirection_data.rb index fcdc952..bd78690 100644 --- a/lib/PCP-server-Ruby-SDK/models/redirection_data.rb +++ b/lib/PCP-server-Ruby-SDK/models/redirection_data.rb @@ -3,186 +3,190 @@ require 'time' # Object containing browser specific redirection related data. -class RedirectionData - # The URL that the customer is redirected to after the payment flow has finished. You can add any number of key value pairs in the query string that, for instance help you to identify the customer when they return to your site. Please note that we will also append some additional key value pairs that will also help you with this identification process. Note: The provided URL should be absolute and contain the protocol to use, e.g. http:// or https://. For use on mobile devices a custom protocol can be used in the form of protocol://. This protocol must be registered on the device first. URLs without a protocol will be rejected. - attr_accessor :return_url - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'return_url' => :'returnUrl' - } - end +module PCPServerSDK + module Models + class RedirectionData + # The URL that the customer is redirected to after the payment flow has finished. You can add any number of key value pairs in the query string that, for instance help you to identify the customer when they return to your site. Please note that we will also append some additional key value pairs that will also help you with this identification process. Note: The provided URL should be absolute and contain the protocol to use, e.g. http:// or https://. For use on mobile devices a custom protocol can be used in the form of protocol://. This protocol must be registered on the device first. URLs without a protocol will be rejected. + attr_accessor :return_url + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'return_url' => :'returnUrl' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'return_url' => :'String' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'return_url' => :'String' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectionData` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RedirectionData` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectionData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RedirectionData`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'return_url') + self.return_url = attributes[:'return_url'] + else + self.return_url = nil + end end - h[k.to_sym] = v - } - - if attributes.key?(:'return_url') - self.return_url = attributes[:'return_url'] - else - self.return_url = nil - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - return_url == o.return_url - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + return_url == o.return_url + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [return_url].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [return_url].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/references.rb b/lib/PCP-server-Ruby-SDK/models/references.rb index 0f2e347..88e6be9 100644 --- a/lib/PCP-server-Ruby-SDK/models/references.rb +++ b/lib/PCP-server-Ruby-SDK/models/references.rb @@ -3,206 +3,210 @@ require 'time' # Object that holds all reference properties that are linked to this transaction. -class References - # Descriptive text that is used towards to customer, either during an online Checkout at a third party and/or on the statement of the customer. For card transactions this is usually referred to as a Soft Descriptor. The maximum allowed length varies per card acquirer: * AIB - 22 characters * American Express - 25 characters * Atos Origin BNP - 15 characters * Barclays - 25 characters * Catella - 22 characters * CBA - 20 characters * Elavon - 25 characters * First Data - 25 characters * INICIS (INIPAY) - 22-30 characters * JCB - 25 characters * Merchant Solutions - 22-25 characters * Payvision (EU & HK) - 25 characters * SEB Euroline - 22 characters * Sub1 Argentina - 15 characters * Wells Fargo - 25 characters Note that we advise you to use 22 characters as the max length as beyond this our experience is that issuers will start to truncate. We currently also only allow per API call overrides for AIB and Barclays For alternative payment products the maximum allowed length varies per payment product: * 402 e-Przelewy - 30 characters * 404 INICIS - 80 characters * 802 Nordea ePayment Finland - 234 characters * 809 iDeal - 32 characters * 836 SOFORT - 42 characters * 840 PayPal - 127 characters * 841 WebMoney - 175 characters * 849 Yandex - 64 characters * 861 Alipay - 256 characters * 863 WeChat Pay - 32 characters * 880 BOKU - 20 characters * 8580 Qiwi - 255 characters * 1504 Konbini - 80 characters All other payment products don't support a descriptor. - attr_accessor :descriptor - - # The merchantReference is a unique identifier for a payment and can be used for reporting purposes. The merchantReference is required for the execution of a payment and has to be unique. In case a payment has failed the same merchantReference can be used again. Once a successful payment has been made the same merchantReference can no longer be used and will be rejected. - attr_accessor :merchant_reference - - # It allows you to store additional parameters for the transaction in JSON format. This field must not contain any personal data. - attr_accessor :merchant_parameters - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'descriptor' => :'descriptor', - :'merchant_reference' => :'merchantReference', - :'merchant_parameters' => :'merchantParameters' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'descriptor' => :'String', - :'merchant_reference' => :'String', - :'merchant_parameters' => :'String' - } - end +module PCPServerSDK + module Models + class References + # Descriptive text that is used towards to customer, either during an online Checkout at a third party and/or on the statement of the customer. For card transactions this is usually referred to as a Soft Descriptor. The maximum allowed length varies per card acquirer: * AIB - 22 characters * American Express - 25 characters * Atos Origin BNP - 15 characters * Barclays - 25 characters * Catella - 22 characters * CBA - 20 characters * Elavon - 25 characters * First Data - 25 characters * INICIS (INIPAY) - 22-30 characters * JCB - 25 characters * Merchant Solutions - 22-25 characters * Payvision (EU & HK) - 25 characters * SEB Euroline - 22 characters * Sub1 Argentina - 15 characters * Wells Fargo - 25 characters Note that we advise you to use 22 characters as the max length as beyond this our experience is that issuers will start to truncate. We currently also only allow per API call overrides for AIB and Barclays For alternative payment products the maximum allowed length varies per payment product: * 402 e-Przelewy - 30 characters * 404 INICIS - 80 characters * 802 Nordea ePayment Finland - 234 characters * 809 iDeal - 32 characters * 836 SOFORT - 42 characters * 840 PayPal - 127 characters * 841 WebMoney - 175 characters * 849 Yandex - 64 characters * 861 Alipay - 256 characters * 863 WeChat Pay - 32 characters * 880 BOKU - 20 characters * 8580 Qiwi - 255 characters * 1504 Konbini - 80 characters All other payment products don't support a descriptor. + attr_accessor :descriptor + + # The merchantReference is a unique identifier for a payment and can be used for reporting purposes. The merchantReference is required for the execution of a payment and has to be unique. In case a payment has failed the same merchantReference can be used again. Once a successful payment has been made the same merchantReference can no longer be used and will be rejected. + attr_accessor :merchant_reference + + # It allows you to store additional parameters for the transaction in JSON format. This field must not contain any personal data. + attr_accessor :merchant_parameters + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'descriptor' => :'descriptor', + :'merchant_reference' => :'merchantReference', + :'merchant_parameters' => :'merchantParameters' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `References` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'descriptor' => :'String', + :'merchant_reference' => :'String', + :'merchant_parameters' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `References`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'descriptor') - self.descriptor = attributes[:'descriptor'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `References` initialize method" + end - if attributes.key?(:'merchant_reference') - self.merchant_reference = attributes[:'merchant_reference'] - else - self.merchant_reference = nil - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `References`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'merchant_parameters') - self.merchant_parameters = attributes[:'merchant_parameters'] - end - end + if attributes.key?(:'descriptor') + self.descriptor = attributes[:'descriptor'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - descriptor == o.descriptor && - merchant_reference == o.merchant_reference && - merchant_parameters == o.merchant_parameters - end + if attributes.key?(:'merchant_reference') + self.merchant_reference = attributes[:'merchant_reference'] + else + self.merchant_reference = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'merchant_parameters') + self.merchant_parameters = attributes[:'merchant_parameters'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [descriptor, merchant_reference, merchant_parameters].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + descriptor == o.descriptor && + merchant_reference == o.merchant_reference && + merchant_parameters == o.merchant_parameters + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [descriptor, merchant_reference, merchant_parameters].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/refund_error_response.rb b/lib/PCP-server-Ruby-SDK/models/refund_error_response.rb index 0f19529..79110d9 100644 --- a/lib/PCP-server-Ruby-SDK/models/refund_error_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/refund_error_response.rb @@ -2,195 +2,199 @@ require 'date' require 'time' -class RefundErrorResponse - # Unique reference, for debugging purposes, of this error response - attr_accessor :error_id - - attr_accessor :errors - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'error_id' => :'errorId', - :'errors' => :'errors' - } - end +module PCPServerSDK + module Models + class RefundErrorResponse + # Unique reference, for debugging purposes, of this error response + attr_accessor :error_id + + attr_accessor :errors + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'error_id' => :'errorId', + :'errors' => :'errors' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'error_id' => :'String', - :'errors' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'error_id' => :'String', + :'errors' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RefundErrorResponse` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RefundErrorResponse` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RefundErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RefundErrorResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'error_id') - self.error_id = attributes[:'error_id'] - end + if attributes.key?(:'error_id') + self.error_id = attributes[:'error_id'] + end - if attributes.key?(:'errors') - if (value = attributes[:'errors']).is_a?(Array) - self.errors = value + if attributes.key?(:'errors') + if (value = attributes[:'errors']).is_a?(Array) + self.errors = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - error_id == o.error_id && - errors == o.errors - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + error_id == o.error_id && + errors == o.errors + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [error_id, errors].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [error_id, errors].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/refund_output.rb b/lib/PCP-server-Ruby-SDK/models/refund_output.rb index a028777..88ccc4d 100644 --- a/lib/PCP-server-Ruby-SDK/models/refund_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/refund_output.rb @@ -3,212 +3,216 @@ require 'time' # Object containing Refund details -class RefundOutput - attr_accessor :amount_of_money +module PCPServerSDK + module Models + class RefundOutput + attr_accessor :amount_of_money + + # It allows you to store additional parameters for the transaction in JSON format. This field must not contain any personal data. + attr_accessor :merchant_parameters + + attr_accessor :references + + # Payment method identifier used by the our payment engine. + attr_accessor :payment_method + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'merchant_parameters' => :'merchantParameters', + :'references' => :'references', + :'payment_method' => :'paymentMethod' + } + end - # It allows you to store additional parameters for the transaction in JSON format. This field must not contain any personal data. - attr_accessor :merchant_parameters + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :references + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'AmountOfMoney', + :'merchant_parameters' => :'String', + :'references' => :'PaymentReferences', + :'payment_method' => :'String' + } + end - # Payment method identifier used by the our payment engine. - attr_accessor :payment_method + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'merchant_parameters' => :'merchantParameters', - :'references' => :'references', - :'payment_method' => :'paymentMethod' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RefundOutput` initialize method" + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RefundOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'AmountOfMoney', - :'merchant_parameters' => :'String', - :'references' => :'PaymentReferences', - :'payment_method' => :'String' - } - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'merchant_parameters') + self.merchant_parameters = attributes[:'merchant_parameters'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RefundOutput` initialize method" - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RefundOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'payment_method') + self.payment_method = attributes[:'payment_method'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end - - if attributes.key?(:'merchant_parameters') - self.merchant_parameters = attributes[:'merchant_parameters'] - end - - if attributes.key?(:'references') - self.references = attributes[:'references'] - end - - if attributes.key?(:'payment_method') - self.payment_method = attributes[:'payment_method'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - merchant_parameters == o.merchant_parameters && - references == o.references && - payment_method == o.payment_method - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + merchant_parameters == o.merchant_parameters && + references == o.references && + payment_method == o.payment_method + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, merchant_parameters, references, payment_method].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, merchant_parameters, references, payment_method].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/refund_payment_response.rb b/lib/PCP-server-Ruby-SDK/models/refund_payment_response.rb index 36dd594..8e48aa9 100644 --- a/lib/PCP-server-Ruby-SDK/models/refund_payment_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/refund_payment_response.rb @@ -3,233 +3,239 @@ require 'time' # This object has the numeric representation of the current Refund status, timestamp of last status change and performable action on the current Refund resource. In case of a rejected Refund, detailed error information is listed. -class RefundPaymentResponse - attr_accessor :refund_output +module PCPServerSDK + module Models + class RefundPaymentResponse + attr_accessor :refund_output - attr_accessor :status + attr_accessor :status - attr_accessor :status_output + attr_accessor :status_output - # Unique payment transaction identifier of the payment gateway. - attr_accessor :id + # Unique payment transaction identifier of the payment gateway. + attr_accessor :id - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'refund_output' => :'refundOutput', - :'status' => :'status', - :'status_output' => :'statusOutput', - :'id' => :'id' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'refund_output' => :'RefundOutput', - :'status' => :'StatusValue', - :'status_output' => :'PaymentStatusOutput', - :'id' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'refund_output' => :'refundOutput', + :'status' => :'status', + :'status_output' => :'statusOutput', + :'id' => :'id' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RefundPaymentResponse` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'refund_output' => :'RefundOutput', + :'status' => :'StatusValue', + :'status_output' => :'PaymentStatusOutput', + :'id' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RefundPaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'refund_output') - self.refund_output = attributes[:'refund_output'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RefundPaymentResponse` initialize method" + end - if attributes.key?(:'status') - self.status = attributes[:'status'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RefundPaymentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'status_output') - self.status_output = attributes[:'status_output'] - end + if attributes.key?(:'refund_output') + self.refund_output = attributes[:'refund_output'] + end - if attributes.key?(:'id') - self.id = attributes[:'id'] - end - end + if attributes.key?(:'status') + self.status = attributes[:'status'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - refund_output == o.refund_output && - status == o.status && - status_output == o.status_output && - id == o.id - end + if attributes.key?(:'status_output') + self.status_output = attributes[:'status_output'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [refund_output, status, status_output, id].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + refund_output == o.refund_output && + status == o.status && + status_output == o.status_output && + id == o.id + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [refund_output, status, status_output, id].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/refund_request.rb b/lib/PCP-server-Ruby-SDK/models/refund_request.rb index 32988b3..a0e2dcc 100644 --- a/lib/PCP-server-Ruby-SDK/models/refund_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/refund_request.rb @@ -3,201 +3,205 @@ require 'time' # Request to refund a payment for a Checkout. It is possible to perform multiple partial refunds by providing an amount that is lower than the total captured amount. The returnReason can be provided for reporting and reconciliation purposes but is not mandatory. -class RefundRequest - attr_accessor :amount_of_money +module PCPServerSDK + module Models + class RefundRequest + attr_accessor :amount_of_money + + attr_accessor :references + + attr_accessor :_return + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'amount_of_money' => :'amountOfMoney', + :'references' => :'references', + :'_return' => :'return' + } + end - attr_accessor :references + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - attr_accessor :_return + # Attribute type mapping. + def self.openapi_types + { + :'amount_of_money' => :'PositiveAmountOfMoney', + :'references' => :'PaymentReferences', + :'_return' => :'ReturnInformation' + } + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'amount_of_money' => :'amountOfMoney', - :'references' => :'references', - :'_return' => :'return' - } - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `RefundRequest` initialize method" + end - # Attribute type mapping. - def self.openapi_types - { - :'amount_of_money' => :'PositiveAmountOfMoney', - :'references' => :'PaymentReferences', - :'_return' => :'ReturnInformation' - } - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `RefundRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + if attributes.key?(:'amount_of_money') + self.amount_of_money = attributes[:'amount_of_money'] + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `RefundRequest` initialize method" - end + if attributes.key?(:'references') + self.references = attributes[:'references'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `RefundRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'_return') + self._return = attributes[:'_return'] + end end - h[k.to_sym] = v - } - - if attributes.key?(:'amount_of_money') - self.amount_of_money = attributes[:'amount_of_money'] - end - - if attributes.key?(:'references') - self.references = attributes[:'references'] - end - - if attributes.key?(:'_return') - self._return = attributes[:'_return'] - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - amount_of_money == o.amount_of_money && - references == o.references && - _return == o._return - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + amount_of_money == o.amount_of_money && + references == o.references && + _return == o._return + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [amount_of_money, references, _return].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [amount_of_money, references, _return].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/return_information.rb b/lib/PCP-server-Ruby-SDK/models/return_information.rb index 57845e5..74e09b1 100644 --- a/lib/PCP-server-Ruby-SDK/models/return_information.rb +++ b/lib/PCP-server-Ruby-SDK/models/return_information.rb @@ -3,196 +3,200 @@ require 'time' # Return object contains additional information about the return/shipment, which is the basis for the Refund. The amountOfMoney in the cartItem will not be used in the request. -class ReturnInformation - # Reason of the Refund (e.g. communicated by or to the consumer). - attr_accessor :return_reason - - # Items returned. - attr_accessor :items - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'return_reason' => :'returnReason', - :'items' => :'items' - } - end +module PCPServerSDK + module Models + class ReturnInformation + # Reason of the Refund (e.g. communicated by or to the consumer). + attr_accessor :return_reason + + # Items returned. + attr_accessor :items + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'return_reason' => :'returnReason', + :'items' => :'items' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'return_reason' => :'String', - :'items' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'return_reason' => :'String', + :'items' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ReturnInformation` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ReturnInformation` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ReturnInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ReturnInformation`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'return_reason') - self.return_reason = attributes[:'return_reason'] - end + if attributes.key?(:'return_reason') + self.return_reason = attributes[:'return_reason'] + end - if attributes.key?(:'items') - if (value = attributes[:'items']).is_a?(Array) - self.items = value + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - return_reason == o.return_reason && - items == o.items - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + return_reason == o.return_reason && + items == o.items + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [return_reason, items].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [return_reason, items].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/return_item.rb b/lib/PCP-server-Ruby-SDK/models/return_item.rb index 65c30f5..a94d9a3 100644 --- a/lib/PCP-server-Ruby-SDK/models/return_item.rb +++ b/lib/PCP-server-Ruby-SDK/models/return_item.rb @@ -2,198 +2,202 @@ require 'date' require 'time' -class ReturnItem - # Id of the item to return. - attr_accessor :id - - # Quantity of the units being returned, should be greater than zero Note: Must not be all spaces or all zeros - attr_accessor :quantity - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'id' => :'id', - :'quantity' => :'quantity' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'id' => :'String', - :'quantity' => :'Integer' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end +module PCPServerSDK + module Models + class ReturnItem + # Id of the item to return. + attr_accessor :id + + # Quantity of the units being returned, should be greater than zero Note: Must not be all spaces or all zeros + attr_accessor :quantity + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'quantity' => :'quantity' + } + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ReturnItem` initialize method" - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ReturnItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'quantity' => :'Integer' + } end - h[k.to_sym] = v - } - if attributes.key?(:'id') - self.id = attributes[:'id'] - else - self.id = nil - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - if attributes.key?(:'quantity') - self.quantity = attributes[:'quantity'] - else - self.quantity = nil - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ReturnItem` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - id == o.id && - quantity == o.quantity - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ReturnItem`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + else + self.id = nil + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'quantity') + self.quantity = attributes[:'quantity'] + else + self.quantity = nil + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [id, quantity].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id && + quantity == o.quantity + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [id, quantity].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/return_request.rb b/lib/PCP-server-Ruby-SDK/models/return_request.rb index 16c6f9e..a6892a1 100644 --- a/lib/PCP-server-Ruby-SDK/models/return_request.rb +++ b/lib/PCP-server-Ruby-SDK/models/return_request.rb @@ -175,7 +175,7 @@ def self._deserialize(type, value) end else # model # models (e.g. Pet) or oneOf - klass = const_get(type) + klass = PCPServerSDK::Models.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end diff --git a/lib/PCP-server-Ruby-SDK/models/return_response.rb b/lib/PCP-server-Ruby-SDK/models/return_response.rb index 382969f..92e5083 100644 --- a/lib/PCP-server-Ruby-SDK/models/return_response.rb +++ b/lib/PCP-server-Ruby-SDK/models/return_response.rb @@ -2,192 +2,196 @@ require 'date' require 'time' -class ReturnResponse - attr_accessor :return_payment_response +module PCPServerSDK + module Models + class ReturnResponse + attr_accessor :return_payment_response + + attr_accessor :shopping_cart + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'return_payment_response' => :'returnPaymentResponse', + :'shopping_cart' => :'shoppingCart' + } + end - attr_accessor :shopping_cart + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'return_payment_response' => :'returnPaymentResponse', - :'shopping_cart' => :'shoppingCart' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'return_payment_response' => :'RefundPaymentResponse', + :'shopping_cart' => :'ShoppingCartResult' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Attribute type mapping. - def self.openapi_types - { - :'return_payment_response' => :'RefundPaymentResponse', - :'shopping_cart' => :'ShoppingCartResult' - } - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ReturnResponse` initialize method" + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ReturnResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ReturnResponse` initialize method" - end + if attributes.key?(:'return_payment_response') + self.return_payment_response = attributes[:'return_payment_response'] + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ReturnResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + if attributes.key?(:'shopping_cart') + self.shopping_cart = attributes[:'shopping_cart'] + end end - h[k.to_sym] = v - } - if attributes.key?(:'return_payment_response') - self.return_payment_response = attributes[:'return_payment_response'] - end - - if attributes.key?(:'shopping_cart') - self.shopping_cart = attributes[:'shopping_cart'] - end - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - return_payment_response == o.return_payment_response && - shopping_cart == o.shopping_cart - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + return_payment_response == o.return_payment_response && + shopping_cart == o.shopping_cart + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [return_payment_response, shopping_cart].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [return_payment_response, shopping_cart].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/return_type.rb b/lib/PCP-server-Ruby-SDK/models/return_type.rb index 5bb06b7..9ed23c8 100644 --- a/lib/PCP-server-Ruby-SDK/models/return_type.rb +++ b/lib/PCP-server-Ruby-SDK/models/return_type.rb @@ -2,26 +2,30 @@ require 'date' require 'time' -class ReturnType - FULL = "FULL".freeze - PARTIAL = "PARTIAL".freeze +module PCPServerSDK + module Models + class ReturnType + FULL = "FULL".freeze + PARTIAL = "PARTIAL".freeze - def self.all_vars - @all_vars ||= [FULL, PARTIAL].freeze - end + def self.all_vars + @all_vars ||= [FULL, PARTIAL].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if ReturnType.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #ReturnType" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if ReturnType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #ReturnType" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_input.rb index 96a03b6..4d769a2 100644 --- a/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_input.rb @@ -3,193 +3,197 @@ require 'time' # Object containing the specific input details for SEPA direct debit payments -class SepaDirectDebitPaymentMethodSpecificInput - attr_accessor :payment_product771_specific_input - - # Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product771_specific_input' => :'paymentProduct771SpecificInput', - :'payment_product_id' => :'paymentProductId' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'payment_product771_specific_input' => :'SepaDirectDebitPaymentProduct771SpecificInput', - :'payment_product_id' => :'Integer' - } - end +module PCPServerSDK + module Models + class SepaDirectDebitPaymentMethodSpecificInput + attr_accessor :payment_product771_specific_input + + # Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product771_specific_input' => :'paymentProduct771SpecificInput', + :'payment_product_id' => :'paymentProductId' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `SepaDirectDebitPaymentMethodSpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_product771_specific_input' => :'SepaDirectDebitPaymentProduct771SpecificInput', + :'payment_product_id' => :'Integer' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `SepaDirectDebitPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_product771_specific_input') - self.payment_product771_specific_input = attributes[:'payment_product771_specific_input'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `SepaDirectDebitPaymentMethodSpecificInput` initialize method" + end - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `SepaDirectDebitPaymentMethodSpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product771_specific_input == o.payment_product771_specific_input && - payment_product_id == o.payment_product_id - end + if attributes.key?(:'payment_product771_specific_input') + self.payment_product771_specific_input = attributes[:'payment_product771_specific_input'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product771_specific_input, payment_product_id].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product771_specific_input == o.payment_product771_specific_input && + payment_product_id == o.payment_product_id + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product771_specific_input, payment_product_id].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_output.rb b/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_output.rb index 53f26b2..10b352c 100644 --- a/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_method_specific_output.rb @@ -3,193 +3,197 @@ require 'time' # Object containing the SEPA direct debit details. -class SepaDirectDebitPaymentMethodSpecificOutput - # Payment product identifier - please check product documentation for a full overview of possible values. - attr_accessor :payment_product_id - - attr_accessor :payment_product771_specific_output - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_product_id' => :'paymentProductId', - :'payment_product771_specific_output' => :'paymentProduct771SpecificOutput' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'payment_product_id' => :'Integer', - :'payment_product771_specific_output' => :'PaymentProduct771SpecificOutput' - } - end +module PCPServerSDK + module Models + class SepaDirectDebitPaymentMethodSpecificOutput + # Payment product identifier - please check product documentation for a full overview of possible values. + attr_accessor :payment_product_id + + attr_accessor :payment_product771_specific_output + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_product_id' => :'paymentProductId', + :'payment_product771_specific_output' => :'paymentProduct771SpecificOutput' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `SepaDirectDebitPaymentMethodSpecificOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_product_id' => :'Integer', + :'payment_product771_specific_output' => :'PaymentProduct771SpecificOutput' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `SepaDirectDebitPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_product_id') - self.payment_product_id = attributes[:'payment_product_id'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `SepaDirectDebitPaymentMethodSpecificOutput` initialize method" + end - if attributes.key?(:'payment_product771_specific_output') - self.payment_product771_specific_output = attributes[:'payment_product771_specific_output'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `SepaDirectDebitPaymentMethodSpecificOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_product_id == o.payment_product_id && - payment_product771_specific_output == o.payment_product771_specific_output - end + if attributes.key?(:'payment_product_id') + self.payment_product_id = attributes[:'payment_product_id'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'payment_product771_specific_output') + self.payment_product771_specific_output = attributes[:'payment_product771_specific_output'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_product_id, payment_product771_specific_output].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_product_id == o.payment_product_id && + payment_product771_specific_output == o.payment_product771_specific_output + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_product_id, payment_product771_specific_output].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_product771_specific_input.rb b/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_product771_specific_input.rb index 322d257..477efcb 100644 --- a/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_product771_specific_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/sepa_direct_debit_payment_product771_specific_input.rb @@ -3,193 +3,197 @@ require 'time' # Object containing information specific to SEPA Direct Debit -class SepaDirectDebitPaymentProduct771SpecificInput - # The unique reference of the existing mandate to use in this payment. - attr_accessor :existing_unique_mandate_reference - - attr_accessor :mandate - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'existing_unique_mandate_reference' => :'existingUniqueMandateReference', - :'mandate' => :'mandate' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'existing_unique_mandate_reference' => :'String', - :'mandate' => :'ProcessingMandateInformation' - } - end +module PCPServerSDK + module Models + class SepaDirectDebitPaymentProduct771SpecificInput + # The unique reference of the existing mandate to use in this payment. + attr_accessor :existing_unique_mandate_reference + + attr_accessor :mandate + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'existing_unique_mandate_reference' => :'existingUniqueMandateReference', + :'mandate' => :'mandate' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `SepaDirectDebitPaymentProduct771SpecificInput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'existing_unique_mandate_reference' => :'String', + :'mandate' => :'ProcessingMandateInformation' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `SepaDirectDebitPaymentProduct771SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'existing_unique_mandate_reference') - self.existing_unique_mandate_reference = attributes[:'existing_unique_mandate_reference'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `SepaDirectDebitPaymentProduct771SpecificInput` initialize method" + end - if attributes.key?(:'mandate') - self.mandate = attributes[:'mandate'] - end - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `SepaDirectDebitPaymentProduct771SpecificInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - existing_unique_mandate_reference == o.existing_unique_mandate_reference && - mandate == o.mandate - end + if attributes.key?(:'existing_unique_mandate_reference') + self.existing_unique_mandate_reference = attributes[:'existing_unique_mandate_reference'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'mandate') + self.mandate = attributes[:'mandate'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [existing_unique_mandate_reference, mandate].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + existing_unique_mandate_reference == o.existing_unique_mandate_reference && + mandate == o.mandate + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [existing_unique_mandate_reference, mandate].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/shipping.rb b/lib/PCP-server-Ruby-SDK/models/shipping.rb index 7103c1a..4f2980b 100644 --- a/lib/PCP-server-Ruby-SDK/models/shipping.rb +++ b/lib/PCP-server-Ruby-SDK/models/shipping.rb @@ -3,183 +3,187 @@ require 'time' # Object containing information regarding shipping / delivery -class Shipping - attr_accessor :address - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'address' => :'address' - } - end - - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'address' => :'AddressPersonal' - } - end +module PCPServerSDK + module Models + class Shipping + attr_accessor :address + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'address' => :'address' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Shipping` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'address' => :'AddressPersonal' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Shipping`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'address') - self.address = attributes[:'address'] - end - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Shipping` initialize method" + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - address == o.address - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Shipping`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'address') + self.address = attributes[:'address'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [address].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + address == o.address + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [address].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/shopping_cart_input.rb b/lib/PCP-server-Ruby-SDK/models/shopping_cart_input.rb index dd9dc4d..55fb22a 100644 --- a/lib/PCP-server-Ruby-SDK/models/shopping_cart_input.rb +++ b/lib/PCP-server-Ruby-SDK/models/shopping_cart_input.rb @@ -3,185 +3,189 @@ require 'time' # Shopping cart data, including items and specific amounts. -class ShoppingCartInput - attr_accessor :items - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'items' => :'items' - } - end +module PCPServerSDK + module Models + class ShoppingCartInput + attr_accessor :items + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'items' => :'items' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'items' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'items' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ShoppingCartInput` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ShoppingCartInput` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ShoppingCartInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ShoppingCartInput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end end - h[k.to_sym] = v - } - if attributes.key?(:'items') - if (value = attributes[:'items']).is_a?(Array) - self.items = value + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + items == o.items end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - items == o.items - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [items].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [items].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/shopping_cart_patch.rb b/lib/PCP-server-Ruby-SDK/models/shopping_cart_patch.rb index 4ae0904..6d1e9f2 100644 --- a/lib/PCP-server-Ruby-SDK/models/shopping_cart_patch.rb +++ b/lib/PCP-server-Ruby-SDK/models/shopping_cart_patch.rb @@ -3,185 +3,189 @@ require 'time' # Shopping cart data, including items and specific amounts. -class ShoppingCartPatch - attr_accessor :items - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'items' => :'items' - } - end +module PCPServerSDK + module Models + class ShoppingCartPatch + attr_accessor :items + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'items' => :'items' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'items' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'items' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ShoppingCartPatch` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ShoppingCartPatch` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ShoppingCartPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ShoppingCartPatch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end end - h[k.to_sym] = v - } - if attributes.key?(:'items') - if (value = attributes[:'items']).is_a?(Array) - self.items = value + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + items == o.items end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - items == o.items - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [items].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [items].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/shopping_cart_result.rb b/lib/PCP-server-Ruby-SDK/models/shopping_cart_result.rb index b627e5c..15c538d 100644 --- a/lib/PCP-server-Ruby-SDK/models/shopping_cart_result.rb +++ b/lib/PCP-server-Ruby-SDK/models/shopping_cart_result.rb @@ -3,185 +3,189 @@ require 'time' # Shopping cart data, including items and specific amounts. -class ShoppingCartResult - attr_accessor :items - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'items' => :'items' - } - end +module PCPServerSDK + module Models + class ShoppingCartResult + attr_accessor :items + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'items' => :'items' + } + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Attribute type mapping. - def self.openapi_types - { - :'items' => :'Array' - } - end + # Attribute type mapping. + def self.openapi_types + { + :'items' => :'Array' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ShoppingCartResult` initialize method" - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ShoppingCartResult` initialize method" + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ShoppingCartResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ShoppingCartResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'items') + if (value = attributes[:'items']).is_a?(Array) + self.items = value + end + end end - h[k.to_sym] = v - } - if attributes.key?(:'items') - if (value = attributes[:'items']).is_a?(Array) - self.items = value + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + items == o.items end - end - end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - items == o.items - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [items].hash - end + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [items].hash + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + new(transformed_hash) end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/status_category_value.rb b/lib/PCP-server-Ruby-SDK/models/status_category_value.rb index cb17c6d..9db63a2 100644 --- a/lib/PCP-server-Ruby-SDK/models/status_category_value.rb +++ b/lib/PCP-server-Ruby-SDK/models/status_category_value.rb @@ -2,32 +2,36 @@ require 'date' require 'time' -class StatusCategoryValue - CREATED = "CREATED".freeze - UNSUCCESSFUL = "UNSUCCESSFUL".freeze - PENDING_PAYMENT = "PENDING_PAYMENT".freeze - PENDING_MERCHANT = "PENDING_MERCHANT".freeze - PENDING_CONNECT_OR_3_RD_PARTY = "PENDING_CONNECT_OR_3RD_PARTY".freeze - COMPLETED = "COMPLETED".freeze - REVERSED = "REVERSED".freeze - REFUNDED = "REFUNDED".freeze +module PCPServerSDK + module Models + class StatusCategoryValue + CREATED = "CREATED".freeze + UNSUCCESSFUL = "UNSUCCESSFUL".freeze + PENDING_PAYMENT = "PENDING_PAYMENT".freeze + PENDING_MERCHANT = "PENDING_MERCHANT".freeze + PENDING_CONNECT_OR_3_RD_PARTY = "PENDING_CONNECT_OR_3RD_PARTY".freeze + COMPLETED = "COMPLETED".freeze + REVERSED = "REVERSED".freeze + REFUNDED = "REFUNDED".freeze - def self.all_vars - @all_vars ||= [CREATED, UNSUCCESSFUL, PENDING_PAYMENT, PENDING_MERCHANT, PENDING_CONNECT_OR_3_RD_PARTY, COMPLETED, REVERSED, REFUNDED].freeze - end + def self.all_vars + @all_vars ||= [CREATED, UNSUCCESSFUL, PENDING_PAYMENT, PENDING_MERCHANT, PENDING_CONNECT_OR_3_RD_PARTY, COMPLETED, REVERSED, REFUNDED].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if StatusCategoryValue.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #StatusCategoryValue" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if StatusCategoryValue.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #StatusCategoryValue" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/status_checkout.rb b/lib/PCP-server-Ruby-SDK/models/status_checkout.rb index 8d57f0e..8e1be43 100644 --- a/lib/PCP-server-Ruby-SDK/models/status_checkout.rb +++ b/lib/PCP-server-Ruby-SDK/models/status_checkout.rb @@ -2,30 +2,34 @@ require 'date' require 'time' -class StatusCheckout - OPEN = "OPEN".freeze - PENDING_COMPLETION = "PENDING_COMPLETION".freeze - COMPLETED = "COMPLETED".freeze - BILLED = "BILLED".freeze - CHARGEBACKED = "CHARGEBACKED".freeze - DELETED = "DELETED".freeze +module PCPServerSDK + module Models + class StatusCheckout + OPEN = "OPEN".freeze + PENDING_COMPLETION = "PENDING_COMPLETION".freeze + COMPLETED = "COMPLETED".freeze + BILLED = "BILLED".freeze + CHARGEBACKED = "CHARGEBACKED".freeze + DELETED = "DELETED".freeze - def self.all_vars - @all_vars ||= [OPEN, PENDING_COMPLETION, COMPLETED, BILLED, CHARGEBACKED, DELETED].freeze - end + def self.all_vars + @all_vars ||= [OPEN, PENDING_COMPLETION, COMPLETED, BILLED, CHARGEBACKED, DELETED].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if StatusCheckout.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #StatusCheckout" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if StatusCheckout.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #StatusCheckout" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/status_output.rb b/lib/PCP-server-Ruby-SDK/models/status_output.rb index 848b257..9f5cc07 100644 --- a/lib/PCP-server-Ruby-SDK/models/status_output.rb +++ b/lib/PCP-server-Ruby-SDK/models/status_output.rb @@ -3,266 +3,272 @@ require 'time' # Contains information about whether the payment of the Checkout has already been completed and how much of the total sum has been collected already. -class StatusOutput - # * WAITING_FOR_PAYMENT - There does not yet exist a PaymentExecution nor a PaymentInformation for this Checkout. * PAYMENT_NOT_COMPLETED - There exists a PaymentExecution or a PaymentInformation for this Checkout, but all or some part of the total amount is still unpaid. * PAYMENT_COMPLETED - There exists a PaymentExecution or a PaymentInformation for this Checkout and the total amount is fully paid. * NO_PAYMENT - Checkout was created and deleted. No Payment Execution and no other actions can be triggered on the Checkout. - attr_accessor :payment_status +module PCPServerSDK + module Models + class StatusOutput + # * WAITING_FOR_PAYMENT - There does not yet exist a PaymentExecution nor a PaymentInformation for this Checkout. * PAYMENT_NOT_COMPLETED - There exists a PaymentExecution or a PaymentInformation for this Checkout, but all or some part of the total amount is still unpaid. * PAYMENT_COMPLETED - There exists a PaymentExecution or a PaymentInformation for this Checkout and the total amount is fully paid. * NO_PAYMENT - Checkout was created and deleted. No Payment Execution and no other actions can be triggered on the Checkout. + attr_accessor :payment_status - # Indicates whether the Checkout can still be modified. False if any payment is already in progress, true otherwise. - attr_accessor :is_modifiable + # Indicates whether the Checkout can still be modified. False if any payment is already in progress, true otherwise. + attr_accessor :is_modifiable - # Amount in cents always having 2 decimals. The amount yet to be paid. - attr_accessor :open_amount + # Amount in cents always having 2 decimals. The amount yet to be paid. + attr_accessor :open_amount - # Amount in cents always having 2 decimals. The amount that has already been collected. - attr_accessor :collected_amount + # Amount in cents always having 2 decimals. The amount that has already been collected. + attr_accessor :collected_amount - # Amount in cents always having 2 decimals. The amount that has already been cancelled. - attr_accessor :cancelled_amount + # Amount in cents always having 2 decimals. The amount that has already been cancelled. + attr_accessor :cancelled_amount - # Amount in cents always having 2 decimals. Amount that has been collected but was refunded to the customer. - attr_accessor :refunded_amount + # Amount in cents always having 2 decimals. Amount that has been collected but was refunded to the customer. + attr_accessor :refunded_amount - # Amount in cents always having 2 decimals. Amount that has been collected but was charged back by the customer. - attr_accessor :chargeback_amount + # Amount in cents always having 2 decimals. Amount that has been collected but was charged back by the customer. + attr_accessor :chargeback_amount - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - def valid?(value) - !value || allowable_values.include?(value) - end - end + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'payment_status' => :'paymentStatus', - :'is_modifiable' => :'isModifiable', - :'open_amount' => :'openAmount', - :'collected_amount' => :'collectedAmount', - :'cancelled_amount' => :'cancelledAmount', - :'refunded_amount' => :'refundedAmount', - :'chargeback_amount' => :'chargebackAmount' - } - end + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end + def valid?(value) + !value || allowable_values.include?(value) + end + end - # Attribute type mapping. - def self.openapi_types - { - :'payment_status' => :'String', - :'is_modifiable' => :'Boolean', - :'open_amount' => :'Integer', - :'collected_amount' => :'Integer', - :'cancelled_amount' => :'Integer', - :'refunded_amount' => :'Integer', - :'chargeback_amount' => :'Integer' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'payment_status' => :'paymentStatus', + :'is_modifiable' => :'isModifiable', + :'open_amount' => :'openAmount', + :'collected_amount' => :'collectedAmount', + :'cancelled_amount' => :'cancelledAmount', + :'refunded_amount' => :'refundedAmount', + :'chargeback_amount' => :'chargebackAmount' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `StatusOutput` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'payment_status' => :'String', + :'is_modifiable' => :'Boolean', + :'open_amount' => :'Integer', + :'collected_amount' => :'Integer', + :'cancelled_amount' => :'Integer', + :'refunded_amount' => :'Integer', + :'chargeback_amount' => :'Integer' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `StatusOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'payment_status') - self.payment_status = attributes[:'payment_status'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `StatusOutput` initialize method" + end - if attributes.key?(:'is_modifiable') - self.is_modifiable = attributes[:'is_modifiable'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `StatusOutput`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'open_amount') - self.open_amount = attributes[:'open_amount'] - end + if attributes.key?(:'payment_status') + self.payment_status = attributes[:'payment_status'] + end - if attributes.key?(:'collected_amount') - self.collected_amount = attributes[:'collected_amount'] - end + if attributes.key?(:'is_modifiable') + self.is_modifiable = attributes[:'is_modifiable'] + end - if attributes.key?(:'cancelled_amount') - self.cancelled_amount = attributes[:'cancelled_amount'] - end + if attributes.key?(:'open_amount') + self.open_amount = attributes[:'open_amount'] + end - if attributes.key?(:'refunded_amount') - self.refunded_amount = attributes[:'refunded_amount'] - end + if attributes.key?(:'collected_amount') + self.collected_amount = attributes[:'collected_amount'] + end - if attributes.key?(:'chargeback_amount') - self.chargeback_amount = attributes[:'chargeback_amount'] - end - end + if attributes.key?(:'cancelled_amount') + self.cancelled_amount = attributes[:'cancelled_amount'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - payment_status == o.payment_status && - is_modifiable == o.is_modifiable && - open_amount == o.open_amount && - collected_amount == o.collected_amount && - cancelled_amount == o.cancelled_amount && - refunded_amount == o.refunded_amount && - chargeback_amount == o.chargeback_amount - end + if attributes.key?(:'refunded_amount') + self.refunded_amount = attributes[:'refunded_amount'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'chargeback_amount') + self.chargeback_amount = attributes[:'chargeback_amount'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [payment_status, is_modifiable, open_amount, collected_amount, cancelled_amount, refunded_amount, chargeback_amount].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + payment_status == o.payment_status && + is_modifiable == o.is_modifiable && + open_amount == o.open_amount && + collected_amount == o.collected_amount && + cancelled_amount == o.cancelled_amount && + refunded_amount == o.refunded_amount && + chargeback_amount == o.chargeback_amount + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [payment_status, is_modifiable, open_amount, collected_amount, cancelled_amount, refunded_amount, chargeback_amount].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/status_value.rb b/lib/PCP-server-Ruby-SDK/models/status_value.rb index d79c5c5..45a510b 100644 --- a/lib/PCP-server-Ruby-SDK/models/status_value.rb +++ b/lib/PCP-server-Ruby-SDK/models/status_value.rb @@ -2,47 +2,51 @@ require 'date' require 'time' -class StatusValue - CREATED = "CREATED".freeze - CANCELLED = "CANCELLED".freeze - REJECTED = "REJECTED".freeze - REJECTED_CAPTURE = "REJECTED_CAPTURE".freeze - REDIRECTED = "REDIRECTED".freeze - PENDING_PAYMENT = "PENDING_PAYMENT".freeze - PENDING_COMPLETION = "PENDING_COMPLETION".freeze - PENDING_CAPTURE = "PENDING_CAPTURE".freeze - AUTHORIZATION_REQUESTED = "AUTHORIZATION_REQUESTED".freeze - CAPTURE_REQUESTED = "CAPTURE_REQUESTED".freeze - CAPTURED = "CAPTURED".freeze - REVERSED = "REVERSED".freeze - REFUND_REQUESTED = "REFUND_REQUESTED".freeze - REFUNDED = "REFUNDED".freeze - REJECTED_REFUND = "REJECTED_REFUND".freeze - CANCELLATION_REQUESTED = "CANCELLATION_REQUESTED".freeze - PAUSED = "PAUSED".freeze - CHARGEBACKED = "CHARGEBACKED".freeze - CHARGEBACK_REVERSED = "CHARGEBACK_REVERSED".freeze - ACCOUNT_CREDITED = "ACCOUNT_CREDITED".freeze - ACCOUNT_DEBITED = "ACCOUNT_DEBITED".freeze - PAYOUT_REQUESTED = "PAYOUT_REQUESTED".freeze - REJECTED_CREDIT = "REJECTED_CREDIT".freeze +module PCPServerSDK + module Models + class StatusValue + CREATED = "CREATED".freeze + CANCELLED = "CANCELLED".freeze + REJECTED = "REJECTED".freeze + REJECTED_CAPTURE = "REJECTED_CAPTURE".freeze + REDIRECTED = "REDIRECTED".freeze + PENDING_PAYMENT = "PENDING_PAYMENT".freeze + PENDING_COMPLETION = "PENDING_COMPLETION".freeze + PENDING_CAPTURE = "PENDING_CAPTURE".freeze + AUTHORIZATION_REQUESTED = "AUTHORIZATION_REQUESTED".freeze + CAPTURE_REQUESTED = "CAPTURE_REQUESTED".freeze + CAPTURED = "CAPTURED".freeze + REVERSED = "REVERSED".freeze + REFUND_REQUESTED = "REFUND_REQUESTED".freeze + REFUNDED = "REFUNDED".freeze + REJECTED_REFUND = "REJECTED_REFUND".freeze + CANCELLATION_REQUESTED = "CANCELLATION_REQUESTED".freeze + PAUSED = "PAUSED".freeze + CHARGEBACKED = "CHARGEBACKED".freeze + CHARGEBACK_REVERSED = "CHARGEBACK_REVERSED".freeze + ACCOUNT_CREDITED = "ACCOUNT_CREDITED".freeze + ACCOUNT_DEBITED = "ACCOUNT_DEBITED".freeze + PAYOUT_REQUESTED = "PAYOUT_REQUESTED".freeze + REJECTED_CREDIT = "REJECTED_CREDIT".freeze - def self.all_vars - @all_vars ||= [CREATED, CANCELLED, REJECTED, REJECTED_CAPTURE, REDIRECTED, PENDING_PAYMENT, PENDING_COMPLETION, PENDING_CAPTURE, AUTHORIZATION_REQUESTED, CAPTURE_REQUESTED, CAPTURED, REVERSED, REFUND_REQUESTED, REFUNDED, REJECTED_REFUND, CANCELLATION_REQUESTED, PAUSED, CHARGEBACKED, CHARGEBACK_REVERSED, ACCOUNT_CREDITED, ACCOUNT_DEBITED, PAYOUT_REQUESTED, REJECTED_CREDIT].freeze - end + def self.all_vars + @all_vars ||= [CREATED, CANCELLED, REJECTED, REJECTED_CAPTURE, REDIRECTED, PENDING_PAYMENT, PENDING_COMPLETION, PENDING_CAPTURE, AUTHORIZATION_REQUESTED, CAPTURE_REQUESTED, CAPTURED, REVERSED, REFUND_REQUESTED, REFUNDED, REJECTED_REFUND, CANCELLATION_REQUESTED, PAUSED, CHARGEBACKED, CHARGEBACK_REVERSED, ACCOUNT_CREDITED, ACCOUNT_DEBITED, PAYOUT_REQUESTED, REJECTED_CREDIT].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if StatusValue.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #StatusValue" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if StatusValue.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #StatusValue" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/three_d_secure_results.rb b/lib/PCP-server-Ruby-SDK/models/three_d_secure_results.rb index a93b7c7..04896d6 100644 --- a/lib/PCP-server-Ruby-SDK/models/three_d_secure_results.rb +++ b/lib/PCP-server-Ruby-SDK/models/three_d_secure_results.rb @@ -3,226 +3,232 @@ require 'time' # 3D Secure results object -class ThreeDSecureResults - # 3D Secure Protocol version used during this transaction. - attr_accessor :version - - # 3D Secure ECI (Electronic Commerce Indicator) depending on the Scheme. Returned by DS. - attr_accessor :scheme_eci - - # Exemption requested and applied in the authorization. - attr_accessor :applied_exemption - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values +module PCPServerSDK + module Models + class ThreeDSecureResults + # 3D Secure Protocol version used during this transaction. + attr_accessor :version + + # 3D Secure ECI (Electronic Commerce Indicator) depending on the Scheme. Returned by DS. + attr_accessor :scheme_eci + + # Exemption requested and applied in the authorization. + attr_accessor :applied_exemption + + + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value + def valid?(value) + !value || allowable_values.include?(value) end end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'version' => :'version', - :'scheme_eci' => :'schemeEci', - :'applied_exemption' => :'appliedExemption' - } - end - # Returns all the JSON keys this model knows about - def self.acceptable_attributes - attribute_map.values - end - - # Attribute type mapping. - def self.openapi_types - { - :'version' => :'String', - :'scheme_eci' => :'String', - :'applied_exemption' => :'String' - } - end + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'version' => :'version', + :'scheme_eci' => :'schemeEci', + :'applied_exemption' => :'appliedExemption' + } + end - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end + # Returns all the JSON keys this model knows about + def self.acceptable_attributes + attribute_map.values + end - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `ThreeDSecureResults` initialize method" - end + # Attribute type mapping. + def self.openapi_types + { + :'version' => :'String', + :'scheme_eci' => :'String', + :'applied_exemption' => :'String' + } + end - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `ThreeDSecureResults`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) end - h[k.to_sym] = v - } - if attributes.key?(:'version') - self.version = attributes[:'version'] - end + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `ThreeDSecureResults` initialize method" + end - if attributes.key?(:'scheme_eci') - self.scheme_eci = attributes[:'scheme_eci'] - end + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `ThreeDSecureResults`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } - if attributes.key?(:'applied_exemption') - self.applied_exemption = attributes[:'applied_exemption'] - end - end + if attributes.key?(:'version') + self.version = attributes[:'version'] + end - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - version == o.version && - scheme_eci == o.scheme_eci && - applied_exemption == o.applied_exemption - end + if attributes.key?(:'scheme_eci') + self.scheme_eci = attributes[:'scheme_eci'] + end - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end + if attributes.key?(:'applied_exemption') + self.applied_exemption = attributes[:'applied_exemption'] + end + end - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [version, scheme_eci, applied_exemption].hash - end + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + version == o.version && + scheme_eci == o.scheme_eci && + applied_exemption == o.applied_exemption + end - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - attributes = attributes.transform_keys(&:to_sym) - transformed_hash = {} - openapi_types.each_pair do |key, type| - if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = nil - elsif type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[attribute_map[key]].is_a?(Array) - transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } - end - elsif !attributes[attribute_map[key]].nil? - transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o end - end - new(transformed_hash) - end - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def self._deserialize(type, value) - case type.to_sym - when :Time - Time.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [version, scheme_eci, applied_exemption].hash end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + attributes = attributes.transform_keys(&:to_sym) + transformed_hash = {} + openapi_types.each_pair do |key, type| + if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = nil + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[attribute_map[key]].is_a?(Array) + transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } + end + elsif !attributes[attribute_map[key]].nil? + transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) + end end + new(transformed_hash) end - else # model - # models (e.g. Pet) or oneOf - klass = const_get(type) - klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) - end - end - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def self._deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + # models (e.g. Pet) or oneOf + klass = PCPServerSDK::Models.const_get(type) + klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) + end + end - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash end - hash[param] = _to_hash(value) - end - hash - end + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end end - elsif value.respond_to? :to_hash - value.to_hash - else - value end end end diff --git a/lib/PCP-server-Ruby-SDK/models/transaction_channel.rb b/lib/PCP-server-Ruby-SDK/models/transaction_channel.rb index a0ad02b..e52286f 100644 --- a/lib/PCP-server-Ruby-SDK/models/transaction_channel.rb +++ b/lib/PCP-server-Ruby-SDK/models/transaction_channel.rb @@ -2,26 +2,30 @@ require 'date' require 'time' -class TransactionChannel - ECOMMERCE = "ECOMMERCE".freeze - MOTO = "MOTO".freeze +module PCPServerSDK + module Models + class TransactionChannel + ECOMMERCE = "ECOMMERCE".freeze + MOTO = "MOTO".freeze - def self.all_vars - @all_vars ||= [ECOMMERCE, MOTO].freeze - end + def self.all_vars + @all_vars ||= [ECOMMERCE, MOTO].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if TransactionChannel.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #TransactionChannel" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if TransactionChannel.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #TransactionChannel" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_requestor.rb b/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_requestor.rb index 0fff2a2..33efb1c 100644 --- a/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_requestor.rb +++ b/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_requestor.rb @@ -2,26 +2,30 @@ require 'date' require 'time' -class UnscheduledCardOnFileRequestor - MERCHANT_INITIATED = "merchantInitiated".freeze - CARDHOLDER_INITIATED = "cardholderInitiated".freeze +module PCPServerSDK + module Models + class UnscheduledCardOnFileRequestor + MERCHANT_INITIATED = "merchantInitiated".freeze + CARDHOLDER_INITIATED = "cardholderInitiated".freeze - def self.all_vars - @all_vars ||= [MERCHANT_INITIATED, CARDHOLDER_INITIATED].freeze - end + def self.all_vars + @all_vars ||= [MERCHANT_INITIATED, CARDHOLDER_INITIATED].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if UnscheduledCardOnFileRequestor.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #UnscheduledCardOnFileRequestor" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if UnscheduledCardOnFileRequestor.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #UnscheduledCardOnFileRequestor" + end + end end end diff --git a/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_sequence_indicator.rb b/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_sequence_indicator.rb index afd1d9c..9df4505 100644 --- a/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_sequence_indicator.rb +++ b/lib/PCP-server-Ruby-SDK/models/unscheduled_card_on_file_sequence_indicator.rb @@ -2,26 +2,30 @@ require 'date' require 'time' -class UnscheduledCardOnFileSequenceIndicator - FIRST = "first".freeze - SUBSEQUENT = "subsequent".freeze +module PCPServerSDK + module Models + class UnscheduledCardOnFileSequenceIndicator + FIRST = "first".freeze + SUBSEQUENT = "subsequent".freeze - def self.all_vars - @all_vars ||= [FIRST, SUBSEQUENT].freeze - end + def self.all_vars + @all_vars ||= [FIRST, SUBSEQUENT].freeze + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def self.build_from_hash(value) - new.build_from_hash(value) - end + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end - # Builds the enum from string - # @param [String] The enum value in the form of the string - # @return [String] The enum value - def build_from_hash(value) - return value if UnscheduledCardOnFileSequenceIndicator.all_vars.include?(value) - raise "Invalid ENUM value #{value} for class #UnscheduledCardOnFileSequenceIndicator" + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if UnscheduledCardOnFileSequenceIndicator.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #UnscheduledCardOnFileSequenceIndicator" + end + end end end