apimatic-cp-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +28 -0
- data/README.md +178 -0
- data/bin/console +15 -0
- data/lib/cell_point_api/api_helper.rb +10 -0
- data/lib/cell_point_api/apis/apple_pay_api.rb +51 -0
- data/lib/cell_point_api/apis/authentication_api.rb +81 -0
- data/lib/cell_point_api/apis/base_api.rb +67 -0
- data/lib/cell_point_api/apis/bulk_api.rb +93 -0
- data/lib/cell_point_api/apis/cards_api.rb +104 -0
- data/lib/cell_point_api/apis/notes_api.rb +66 -0
- data/lib/cell_point_api/apis/oauth_authorization_api.rb +44 -0
- data/lib/cell_point_api/apis/orders_api.rb +483 -0
- data/lib/cell_point_api/apis/payment_methods_api.rb +57 -0
- data/lib/cell_point_api/apis/proxy_api.rb +91 -0
- data/lib/cell_point_api/apis/transactions_api.rb +546 -0
- data/lib/cell_point_api/apis/wallet_api.rb +39 -0
- data/lib/cell_point_api/client.rb +145 -0
- data/lib/cell_point_api/configuration.rb +180 -0
- data/lib/cell_point_api/events/callbacks/callbacks_handler.rb +37 -0
- data/lib/cell_point_api/events/unknown_event.rb +32 -0
- data/lib/cell_point_api/exceptions/api_exception.rb +21 -0
- data/lib/cell_point_api/exceptions/oauth_provider_exception.rb +64 -0
- data/lib/cell_point_api/exceptions/problem_exception.rb +75 -0
- data/lib/cell_point_api/http/api_response.rb +19 -0
- data/lib/cell_point_api/http/auth/cpd_issued_jwt.rb +156 -0
- data/lib/cell_point_api/http/auth/merchant_issued_jwt.rb +53 -0
- data/lib/cell_point_api/http/http_call_back.rb +10 -0
- data/lib/cell_point_api/http/http_method_enum.rb +10 -0
- data/lib/cell_point_api/http/http_request.rb +10 -0
- data/lib/cell_point_api/http/http_response.rb +10 -0
- data/lib/cell_point_api/http/proxy_settings.rb +22 -0
- data/lib/cell_point_api/logging/configuration/api_logging_configuration.rb +186 -0
- data/lib/cell_point_api/logging/sdk_logger.rb +17 -0
- data/lib/cell_point_api/models/account.rb +168 -0
- data/lib/cell_point_api/models/account_status.rb +52 -0
- data/lib/cell_point_api/models/account_type.rb +44 -0
- data/lib/cell_point_api/models/action_base.rb +74 -0
- data/lib/cell_point_api/models/action_completion_response.rb +77 -0
- data/lib/cell_point_api/models/action_result_status.rb +40 -0
- data/lib/cell_point_api/models/action_type.rb +36 -0
- data/lib/cell_point_api/models/activity.rb +244 -0
- data/lib/cell_point_api/models/activity_data.rb +127 -0
- data/lib/cell_point_api/models/address_verification_status.rb +56 -0
- data/lib/cell_point_api/models/airline_ancillary.rb +244 -0
- data/lib/cell_point_api/models/airline_ancillary_data.rb +120 -0
- data/lib/cell_point_api/models/airline_fare.rb +348 -0
- data/lib/cell_point_api/models/airline_fare_data.rb +217 -0
- data/lib/cell_point_api/models/airline_industry_data.rb +152 -0
- data/lib/cell_point_api/models/airport.rb +144 -0
- data/lib/cell_point_api/models/amount.rb +105 -0
- data/lib/cell_point_api/models/ancillary_details.rb +366 -0
- data/lib/cell_point_api/models/apple_pay_config.rb +83 -0
- data/lib/cell_point_api/models/apple_pay_instrument_apple_pay_node.rb +119 -0
- data/lib/cell_point_api/models/apple_pay_payment_instrument.rb +123 -0
- data/lib/cell_point_api/models/apple_tokenized_token.rb +143 -0
- data/lib/cell_point_api/models/audience.rb +36 -0
- data/lib/cell_point_api/models/authorization.rb +145 -0
- data/lib/cell_point_api/models/authorization_group.rb +99 -0
- data/lib/cell_point_api/models/authorization_group1.rb +216 -0
- data/lib/cell_point_api/models/authorization_group_full.rb +193 -0
- data/lib/cell_point_api/models/authorize_order_by_id_post201_response.rb +128 -0
- data/lib/cell_point_api/models/auto_rental.rb +195 -0
- data/lib/cell_point_api/models/auto_rental_data.rb +76 -0
- data/lib/cell_point_api/models/auto_rental_industry_data.rb +182 -0
- data/lib/cell_point_api/models/base_model.rb +110 -0
- data/lib/cell_point_api/models/bin.rb +73 -0
- data/lib/cell_point_api/models/breadcrumb.rb +86 -0
- data/lib/cell_point_api/models/browser_info.rb +114 -0
- data/lib/cell_point_api/models/bundle.rb +195 -0
- data/lib/cell_point_api/models/bundled_activity.rb +229 -0
- data/lib/cell_point_api/models/bundled_airline_ancillary.rb +226 -0
- data/lib/cell_point_api/models/bundled_airline_fare.rb +330 -0
- data/lib/cell_point_api/models/bundled_auto_rental.rb +176 -0
- data/lib/cell_point_api/models/bundled_discount.rb +132 -0
- data/lib/cell_point_api/models/bundled_item_base.rb +123 -0
- data/lib/cell_point_api/models/bundled_lodging_reservation.rb +176 -0
- data/lib/cell_point_api/models/bundled_product.rb +161 -0
- data/lib/cell_point_api/models/buyer.rb +129 -0
- data/lib/cell_point_api/models/buyer_fingerprint.rb +125 -0
- data/lib/cell_point_api/models/buyer_history.rb +199 -0
- data/lib/cell_point_api/models/cancel.rb +109 -0
- data/lib/cell_point_api/models/cancelled_payment_transactions.rb +84 -0
- data/lib/cell_point_api/models/capabilities.rb +77 -0
- data/lib/cell_point_api/models/capture.rb +84 -0
- data/lib/cell_point_api/models/capture_payment_response.rb +159 -0
- data/lib/cell_point_api/models/card.rb +131 -0
- data/lib/cell_point_api/models/card_config.rb +105 -0
- data/lib/cell_point_api/models/card_identification.rb +126 -0
- data/lib/cell_point_api/models/card_instrument_card_node.rb +232 -0
- data/lib/cell_point_api/models/card_number.rb +122 -0
- data/lib/cell_point_api/models/card_payment_instrument.rb +136 -0
- data/lib/cell_point_api/models/card_scheme.rb +63 -0
- data/lib/cell_point_api/models/card_scheme_configuration.rb +87 -0
- data/lib/cell_point_api/models/carrier.rb +82 -0
- data/lib/cell_point_api/models/category.rb +36 -0
- data/lib/cell_point_api/models/client_assertion.rb +135 -0
- data/lib/cell_point_api/models/close.rb +89 -0
- data/lib/cell_point_api/models/close_refund_response.rb +73 -0
- data/lib/cell_point_api/models/closed_payment_transactions.rb +83 -0
- data/lib/cell_point_api/models/codeshare.rb +87 -0
- data/lib/cell_point_api/models/complete_person_name.rb +120 -0
- data/lib/cell_point_api/models/completion_redirect.rb +93 -0
- data/lib/cell_point_api/models/configuration.rb +86 -0
- data/lib/cell_point_api/models/contact_data.rb +82 -0
- data/lib/cell_point_api/models/cpu.rb +74 -0
- data/lib/cell_point_api/models/device_os.rb +60 -0
- data/lib/cell_point_api/models/discount.rb +150 -0
- data/lib/cell_point_api/models/discount_data.rb +83 -0
- data/lib/cell_point_api/models/driver.rb +86 -0
- data/lib/cell_point_api/models/external_transaction.rb +227 -0
- data/lib/cell_point_api/models/externally_tokenized_card.rb +81 -0
- data/lib/cell_point_api/models/failover.rb +105 -0
- data/lib/cell_point_api/models/failure_category.rb +62 -0
- data/lib/cell_point_api/models/failure_module.rb +58 -0
- data/lib/cell_point_api/models/fingerprint.rb +82 -0
- data/lib/cell_point_api/models/fraud_assessment.rb +163 -0
- data/lib/cell_point_api/models/fulfilled_activity.rb +207 -0
- data/lib/cell_point_api/models/fulfilled_airline_ancillary.rb +207 -0
- data/lib/cell_point_api/models/fulfilled_airline_fare.rb +207 -0
- data/lib/cell_point_api/models/fulfilled_auto_rental.rb +207 -0
- data/lib/cell_point_api/models/fulfilled_bundle.rb +207 -0
- data/lib/cell_point_api/models/fulfilled_discount.rb +178 -0
- data/lib/cell_point_api/models/fulfilled_line_item_base.rb +177 -0
- data/lib/cell_point_api/models/fulfilled_lodging_reservation.rb +207 -0
- data/lib/cell_point_api/models/fulfilled_order.rb +148 -0
- data/lib/cell_point_api/models/fulfilled_product.rb +207 -0
- data/lib/cell_point_api/models/fulfilled_tax_line.rb +162 -0
- data/lib/cell_point_api/models/fulfillment_data.rb +90 -0
- data/lib/cell_point_api/models/fulfillment_status.rb +41 -0
- data/lib/cell_point_api/models/funding_type.rb +40 -0
- data/lib/cell_point_api/models/gender.rb +40 -0
- data/lib/cell_point_api/models/hpp_data.rb +155 -0
- data/lib/cell_point_api/models/identifying_document.rb +159 -0
- data/lib/cell_point_api/models/identifying_document_type.rb +60 -0
- data/lib/cell_point_api/models/industry_data.rb +124 -0
- data/lib/cell_point_api/models/informational_price_row.rb +97 -0
- data/lib/cell_point_api/models/informational_price_section.rb +104 -0
- data/lib/cell_point_api/models/itinerary_type.rb +47 -0
- data/lib/cell_point_api/models/journey_segment.rb +83 -0
- data/lib/cell_point_api/models/line_item_base.rb +101 -0
- data/lib/cell_point_api/models/line_item_type.rb +60 -0
- data/lib/cell_point_api/models/links.rb +86 -0
- data/lib/cell_point_api/models/location.rb +153 -0
- data/lib/cell_point_api/models/lodging_industry_data.rb +216 -0
- data/lib/cell_point_api/models/lodging_reservation.rb +195 -0
- data/lib/cell_point_api/models/lodging_reservation_data.rb +76 -0
- data/lib/cell_point_api/models/loyalty_account.rb +103 -0
- data/lib/cell_point_api/models/network_info.rb +76 -0
- data/lib/cell_point_api/models/non_negative_amount.rb +105 -0
- data/lib/cell_point_api/models/non_positive_amount.rb +105 -0
- data/lib/cell_point_api/models/note.rb +139 -0
- data/lib/cell_point_api/models/note_request.rb +90 -0
- data/lib/cell_point_api/models/oauth_provider_error.rb +62 -0
- data/lib/cell_point_api/models/oauth_scope_cpd_issued_jwt.rb +158 -0
- data/lib/cell_point_api/models/oauth_token.rb +96 -0
- data/lib/cell_point_api/models/order.rb +414 -0
- data/lib/cell_point_api/models/order_canceled_reason.rb +56 -0
- data/lib/cell_point_api/models/order_core.rb +343 -0
- data/lib/cell_point_api/models/order_extended.rb +150 -0
- data/lib/cell_point_api/models/order_payment_summary.rb +117 -0
- data/lib/cell_point_api/models/order_status.rb +161 -0
- data/lib/cell_point_api/models/order_status_type.rb +58 -0
- data/lib/cell_point_api/models/order_transactions.rb +88 -0
- data/lib/cell_point_api/models/owner.rb +131 -0
- data/lib/cell_point_api/models/page_type.rb +26 -0
- data/lib/cell_point_api/models/passenger.rb +229 -0
- data/lib/cell_point_api/models/password_change_type.rb +41 -0
- data/lib/cell_point_api/models/pay_pal_action.rb +129 -0
- data/lib/cell_point_api/models/pay_pal_payment_instrument.rb +88 -0
- data/lib/cell_point_api/models/payment_data.rb +102 -0
- data/lib/cell_point_api/models/payment_data_header.rb +94 -0
- data/lib/cell_point_api/models/payment_data_version.rb +26 -0
- data/lib/cell_point_api/models/payment_field.rb +68 -0
- data/lib/cell_point_api/models/payment_instrument_base.rb +87 -0
- data/lib/cell_point_api/models/payment_method.rb +52 -0
- data/lib/cell_point_api/models/payment_methods_for_order_get200_response.rb +157 -0
- data/lib/cell_point_api/models/payment_methods_search_vouchers_post200_response.rb +82 -0
- data/lib/cell_point_api/models/payment_processor.rb +121 -0
- data/lib/cell_point_api/models/payment_status.rb +122 -0
- data/lib/cell_point_api/models/payment_transaction.rb +605 -0
- data/lib/cell_point_api/models/payment_transaction_authorized_amount.rb +105 -0
- data/lib/cell_point_api/models/payment_transaction_canceled_amount.rb +105 -0
- data/lib/cell_point_api/models/payment_transaction_captured_amount.rb +105 -0
- data/lib/cell_point_api/models/payment_transaction_pending_authorize_amount.rb +106 -0
- data/lib/cell_point_api/models/payment_transaction_pending_cancel_amount.rb +106 -0
- data/lib/cell_point_api/models/payment_transaction_pending_capture_amount.rb +106 -0
- data/lib/cell_point_api/models/payment_transaction_processing_fee.rb +106 -0
- data/lib/cell_point_api/models/payment_transaction_refunded_amount.rb +105 -0
- data/lib/cell_point_api/models/payments_v1_bulks_response.rb +74 -0
- data/lib/cell_point_api/models/payments_v1_orders_payments_retry_failed_refunds_request.rb +74 -0
- data/lib/cell_point_api/models/payments_v1_refunds_closures_request.rb +74 -0
- data/lib/cell_point_api/models/payments_v1_refunds_retry_failed_refunds_request.rb +74 -0
- data/lib/cell_point_api/models/payments_v1_schemes_response.rb +76 -0
- data/lib/cell_point_api/models/paypal_config.rb +94 -0
- data/lib/cell_point_api/models/person.rb +161 -0
- data/lib/cell_point_api/models/person_name.rb +89 -0
- data/lib/cell_point_api/models/phone.rb +132 -0
- data/lib/cell_point_api/models/pk_payment_method.rb +111 -0
- data/lib/cell_point_api/models/pk_payment_token.rb +94 -0
- data/lib/cell_point_api/models/postal_address.rb +217 -0
- data/lib/cell_point_api/models/price_summary.rb +191 -0
- data/lib/cell_point_api/models/product.rb +179 -0
- data/lib/cell_point_api/models/product_data.rb +104 -0
- data/lib/cell_point_api/models/property.rb +110 -0
- data/lib/cell_point_api/models/provider.rb +129 -0
- data/lib/cell_point_api/models/psp.rb +26 -0
- data/lib/cell_point_api/models/redirect_action.rb +116 -0
- data/lib/cell_point_api/models/refund_item.rb +310 -0
- data/lib/cell_point_api/models/refund_method.rb +36 -0
- data/lib/cell_point_api/models/refund_order_group_post201_response.rb +91 -0
- data/lib/cell_point_api/models/refund_reason.rb +104 -0
- data/lib/cell_point_api/models/refund_request.rb +161 -0
- data/lib/cell_point_api/models/refund_status.rb +44 -0
- data/lib/cell_point_api/models/refund_transaction.rb +311 -0
- data/lib/cell_point_api/models/refund_transaction_amount.rb +105 -0
- data/lib/cell_point_api/models/refund_type.rb +38 -0
- data/lib/cell_point_api/models/related_payment.rb +106 -0
- data/lib/cell_point_api/models/related_refund.rb +106 -0
- data/lib/cell_point_api/models/rental_location.rb +226 -0
- data/lib/cell_point_api/models/retry_refund_response.rb +73 -0
- data/lib/cell_point_api/models/reward.rb +101 -0
- data/lib/cell_point_api/models/room.rb +100 -0
- data/lib/cell_point_api/models/sales_channel.rb +36 -0
- data/lib/cell_point_api/models/save_pk_payment_token_request.rb +83 -0
- data/lib/cell_point_api/models/save_wallet_payment_token_request.rb +83 -0
- data/lib/cell_point_api/models/screen.rb +97 -0
- data/lib/cell_point_api/models/search_vouchers_request.rb +119 -0
- data/lib/cell_point_api/models/security_code.rb +83 -0
- data/lib/cell_point_api/models/security_code_match_status.rb +50 -0
- data/lib/cell_point_api/models/status.rb +43 -0
- data/lib/cell_point_api/models/status1.rb +52 -0
- data/lib/cell_point_api/models/summary.rb +82 -0
- data/lib/cell_point_api/models/tax.rb +134 -0
- data/lib/cell_point_api/models/taxes_and_fees_breakdown_page.rb +82 -0
- data/lib/cell_point_api/models/token_post200_response.rb +96 -0
- data/lib/cell_point_api/models/tokenized_card.rb +229 -0
- data/lib/cell_point_api/models/tokenized_card_with_contact_data.rb +247 -0
- data/lib/cell_point_api/models/tokenized_data.rb +169 -0
- data/lib/cell_point_api/models/total_row.rb +83 -0
- data/lib/cell_point_api/models/transaction_action.rb +108 -0
- data/lib/cell_point_api/models/transaction_action_result.rb +94 -0
- data/lib/cell_point_api/models/transaction_base.rb +132 -0
- data/lib/cell_point_api/models/transaction_failure.rb +222 -0
- data/lib/cell_point_api/models/travel_journey.rb +139 -0
- data/lib/cell_point_api/models/travel_leg.rb +194 -0
- data/lib/cell_point_api/models/trigger_bulk_request.rb +83 -0
- data/lib/cell_point_api/models/type.rb +67 -0
- data/lib/cell_point_api/models/type1.rb +47 -0
- data/lib/cell_point_api/models/type2.rb +40 -0
- data/lib/cell_point_api/models/type3.rb +41 -0
- data/lib/cell_point_api/models/type4.rb +56 -0
- data/lib/cell_point_api/models/type5.rb +78 -0
- data/lib/cell_point_api/models/uplift_config.rb +73 -0
- data/lib/cell_point_api/models/uplift_payment_instrument.rb +102 -0
- data/lib/cell_point_api/models/vehicle.rb +139 -0
- data/lib/cell_point_api/models/voucher_config.rb +92 -0
- data/lib/cell_point_api/models/voucher_issuer.rb +26 -0
- data/lib/cell_point_api/models/voucher_payment_instrument.rb +233 -0
- data/lib/cell_point_api/models/voucher_payment_instrument_node.rb +198 -0
- data/lib/cell_point_api/models/voucher_type.rb +36 -0
- data/lib/cell_point_api/models/wallet_instrument_wallet_node.rb +136 -0
- data/lib/cell_point_api/models/wallet_payment_instrument.rb +123 -0
- data/lib/cell_point_api/models/wallet_tokenized_token.rb +148 -0
- data/lib/cell_point_api/models/wallet_tokenized_token_identification.rb +75 -0
- data/lib/cell_point_api/models/wallet_type.rb +36 -0
- data/lib/cell_point_api/utilities/date_time_helper.rb +11 -0
- data/lib/cell_point_api/utilities/file_wrapper.rb +28 -0
- data/lib/cell_point_api/utilities/union_type_lookup.rb +260 -0
- data/lib/cell_point_api.rb +301 -0
- metadata +354 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# cell_point_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module CellPointApi
|
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
|
8
|
+
class CpdIssuedJwt < CoreLibrary::HeaderAuth
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
# Display error message on occurrence of authentication failure.
|
|
11
|
+
# @returns [String] The oAuth error message.
|
|
12
|
+
def error_message
|
|
13
|
+
'CpdIssuedJwt: OAuthToken is undefined or expired.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(cpd_issued_jwt_credentials, config)
|
|
18
|
+
@_oauth_client_id = cpd_issued_jwt_credentials.oauth_client_id unless
|
|
19
|
+
cpd_issued_jwt_credentials.nil? || cpd_issued_jwt_credentials.oauth_client_id.nil?
|
|
20
|
+
@_oauth_client_secret = cpd_issued_jwt_credentials.oauth_client_secret unless
|
|
21
|
+
cpd_issued_jwt_credentials.nil? || cpd_issued_jwt_credentials.oauth_client_secret.nil?
|
|
22
|
+
@_oauth_token = cpd_issued_jwt_credentials.oauth_token unless
|
|
23
|
+
cpd_issued_jwt_credentials.nil? || cpd_issued_jwt_credentials.oauth_token.nil?
|
|
24
|
+
@_oauth_scopes = cpd_issued_jwt_credentials.oauth_scopes unless
|
|
25
|
+
cpd_issued_jwt_credentials.nil? || cpd_issued_jwt_credentials.oauth_scopes.nil?
|
|
26
|
+
@_oauth_clock_skew = cpd_issued_jwt_credentials.oauth_clock_skew unless
|
|
27
|
+
cpd_issued_jwt_credentials.nil? || cpd_issued_jwt_credentials.oauth_clock_skew.nil?
|
|
28
|
+
@_oauth_token_provider = cpd_issued_jwt_credentials.oauth_token_provider unless
|
|
29
|
+
cpd_issued_jwt_credentials.nil? || cpd_issued_jwt_credentials.oauth_token_provider.nil?
|
|
30
|
+
@_oauth_on_token_update = cpd_issued_jwt_credentials.oauth_on_token_update unless
|
|
31
|
+
cpd_issued_jwt_credentials.nil? || cpd_issued_jwt_credentials.oauth_on_token_update.nil?
|
|
32
|
+
@_o_auth_api = OauthAuthorizationApi.new(config)
|
|
33
|
+
super({})
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Validates the oAuth token.
|
|
37
|
+
# @return [Boolean] true if the token is present and not expired.
|
|
38
|
+
def valid
|
|
39
|
+
@_oauth_token = get_token_from_provider
|
|
40
|
+
@_oauth_token.is_a?(OAuthToken) && !token_expired?(@_oauth_token)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Builds the basic auth header for endpoints in the OAuth Authorization Controller.
|
|
44
|
+
# @return [String] The value of the Authentication header.
|
|
45
|
+
def build_basic_auth_header
|
|
46
|
+
"Basic #{AuthHelper.get_base64_encoded_value(@_oauth_client_id, @_oauth_client_secret)}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Fetches the token.
|
|
50
|
+
# @param [Hash] additional_params Any additional form parameters.
|
|
51
|
+
# @return [OAuthToken] The oAuth token instance.
|
|
52
|
+
def fetch_token(additional_params: nil)
|
|
53
|
+
token = @_o_auth_api.request_token_cpd_issued_jwt(
|
|
54
|
+
build_basic_auth_header,
|
|
55
|
+
scope: !@_oauth_scopes.nil? ? Array(@_oauth_scopes).compact.join(' ') : @_oauth_scopes,
|
|
56
|
+
_field_parameters: additional_params
|
|
57
|
+
).data
|
|
58
|
+
if token.respond_to?('expires_in') && !token.expires_in.nil?
|
|
59
|
+
token.expiry = AuthHelper.get_token_expiry(token.expires_in, Time.now.utc.to_i)
|
|
60
|
+
end
|
|
61
|
+
token
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Checks if OAuth token has expired.
|
|
65
|
+
# @param [OAuthToken] token The oAuth token instance.
|
|
66
|
+
# @return [Boolean] true if the token's expiry exist and also the token is expired, false otherwise.
|
|
67
|
+
def token_expired?(token)
|
|
68
|
+
token.respond_to?('expiry') && AuthHelper.token_expired?(token.expiry, @_oauth_clock_skew)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def apply(http_request)
|
|
72
|
+
auth_params = { 'Authorization' => "Bearer #{@_oauth_token.access_token}" }
|
|
73
|
+
AuthHelper.apply(auth_params, http_request.method(:add_header))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
# This provides the OAuth Token from either the user configured callbacks or from default provider.
|
|
79
|
+
# @return [OAuthToken] The fetched oauth token.
|
|
80
|
+
def get_token_from_provider
|
|
81
|
+
return @_oauth_token if @_oauth_token && !token_expired?(@_oauth_token)
|
|
82
|
+
|
|
83
|
+
if @_o_auth_token_provider
|
|
84
|
+
o_auth_token = @_o_auth_token_provider.call(@_oauth_token, self)
|
|
85
|
+
@_o_auth_on_token_update&.call(o_auth_token)
|
|
86
|
+
return o_auth_token
|
|
87
|
+
end
|
|
88
|
+
begin
|
|
89
|
+
o_auth_token = fetch_token
|
|
90
|
+
@_o_auth_on_token_update&.call(o_auth_token)
|
|
91
|
+
o_auth_token
|
|
92
|
+
rescue ApiException
|
|
93
|
+
@_o_auth_token
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Data class for CpdIssuedJwtCredentials.
|
|
99
|
+
class CpdIssuedJwtCredentials
|
|
100
|
+
attr_reader :oauth_client_id, :oauth_client_secret, :oauth_token,
|
|
101
|
+
:oauth_scopes, :oauth_token_provider, :oauth_on_token_update,
|
|
102
|
+
:oauth_clock_skew
|
|
103
|
+
|
|
104
|
+
def initialize(oauth_client_id:, oauth_client_secret:, oauth_token: nil,
|
|
105
|
+
oauth_scopes: nil, oauth_token_provider: nil,
|
|
106
|
+
oauth_on_token_update: nil, oauth_clock_skew: 0)
|
|
107
|
+
raise ArgumentError, 'oauth_client_id cannot be nil' if oauth_client_id.nil?
|
|
108
|
+
raise ArgumentError, 'oauth_client_secret cannot be nil' if oauth_client_secret.nil?
|
|
109
|
+
|
|
110
|
+
@oauth_client_id = oauth_client_id
|
|
111
|
+
@oauth_client_secret = oauth_client_secret
|
|
112
|
+
@oauth_token = oauth_token
|
|
113
|
+
@oauth_scopes = oauth_scopes
|
|
114
|
+
@oauth_token_provider = oauth_token_provider
|
|
115
|
+
@oauth_on_token_update = oauth_on_token_update
|
|
116
|
+
@oauth_clock_skew = oauth_clock_skew
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def self.from_env
|
|
120
|
+
oauth_client_id = ENV['CPD_ISSUED_JWT_OAUTH_CLIENT_ID']
|
|
121
|
+
oauth_client_secret = ENV['CPD_ISSUED_JWT_OAUTH_CLIENT_SECRET']
|
|
122
|
+
oauth_scopes = ENV['CPD_ISSUED_JWT_OAUTH_SCOPES']
|
|
123
|
+
oauth_clock_skew = ENV['CPD_ISSUED_JWT_OAUTH_CLOCK_SKEW']
|
|
124
|
+
all_nil = [
|
|
125
|
+
oauth_client_id,
|
|
126
|
+
oauth_client_secret
|
|
127
|
+
].all?(&:nil?)
|
|
128
|
+
return nil if all_nil
|
|
129
|
+
|
|
130
|
+
new(oauth_client_id: oauth_client_id,
|
|
131
|
+
oauth_client_secret: oauth_client_secret, oauth_scopes: oauth_scopes,
|
|
132
|
+
oauth_clock_skew: oauth_clock_skew)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def clone_with(oauth_client_id: nil, oauth_client_secret: nil,
|
|
136
|
+
oauth_token: nil, oauth_scopes: nil,
|
|
137
|
+
oauth_token_provider: nil, oauth_on_token_update: nil,
|
|
138
|
+
oauth_clock_skew: nil)
|
|
139
|
+
oauth_client_id ||= self.oauth_client_id
|
|
140
|
+
oauth_client_secret ||= self.oauth_client_secret
|
|
141
|
+
oauth_token ||= self.oauth_token
|
|
142
|
+
oauth_scopes ||= self.oauth_scopes
|
|
143
|
+
oauth_token_provider ||= self.oauth_token_provider
|
|
144
|
+
oauth_on_token_update ||= self.oauth_on_token_update
|
|
145
|
+
oauth_clock_skew ||= self.oauth_clock_skew
|
|
146
|
+
|
|
147
|
+
CpdIssuedJwtCredentials.new(oauth_client_id: oauth_client_id,
|
|
148
|
+
oauth_client_secret: oauth_client_secret,
|
|
149
|
+
oauth_token: oauth_token,
|
|
150
|
+
oauth_scopes: oauth_scopes,
|
|
151
|
+
oauth_token_provider: oauth_token_provider,
|
|
152
|
+
oauth_on_token_update: oauth_on_token_update,
|
|
153
|
+
oauth_clock_skew: oauth_clock_skew)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# cell_point_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module CellPointApi
|
|
7
|
+
# Utility class for OAuth 2 authorization and token management.
|
|
8
|
+
class MerchantIssuedJwt < CoreLibrary::HeaderAuth
|
|
9
|
+
include CoreLibrary
|
|
10
|
+
# Display error message on occurrence of authentication failure.
|
|
11
|
+
# @returns [String] The oAuth error message.
|
|
12
|
+
def error_message
|
|
13
|
+
'MerchantIssuedJwt: access_token is undefined.'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Initialization constructor.
|
|
17
|
+
def initialize(merchant_issued_jwt_credentials)
|
|
18
|
+
auth_params = {}
|
|
19
|
+
@_access_token = merchant_issued_jwt_credentials.access_token unless
|
|
20
|
+
merchant_issued_jwt_credentials.nil? || merchant_issued_jwt_credentials.access_token.nil?
|
|
21
|
+
auth_params[:Authorization] = "Bearer #{@_access_token}" unless @_access_token.nil?
|
|
22
|
+
|
|
23
|
+
super auth_params
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Data class for MerchantIssuedJwtCredentials.
|
|
28
|
+
class MerchantIssuedJwtCredentials
|
|
29
|
+
attr_reader :access_token
|
|
30
|
+
|
|
31
|
+
def initialize(access_token:)
|
|
32
|
+
raise ArgumentError, 'access_token cannot be nil' if access_token.nil?
|
|
33
|
+
|
|
34
|
+
@access_token = access_token
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def self.from_env
|
|
38
|
+
access_token = ENV['MERCHANT_ISSUED_JWT_ACCESS_TOKEN']
|
|
39
|
+
all_nil = [
|
|
40
|
+
access_token
|
|
41
|
+
].all?(&:nil?)
|
|
42
|
+
return nil if all_nil
|
|
43
|
+
|
|
44
|
+
new(access_token: access_token)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def clone_with(access_token: nil)
|
|
48
|
+
access_token ||= self.access_token
|
|
49
|
+
|
|
50
|
+
MerchantIssuedJwtCredentials.new(access_token: access_token)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# cell_point_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module CellPointApi
|
|
7
|
+
# HttpCallBack allows defining callables for pre and post API calls.
|
|
8
|
+
class HttpCallBack < CoreLibrary::HttpCallback
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# cell_point_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module CellPointApi
|
|
7
|
+
##
|
|
8
|
+
# ProxySettings encapsulates HTTP proxy configuration for Faraday,
|
|
9
|
+
# including optional basic authentication.
|
|
10
|
+
#
|
|
11
|
+
class ProxySettings < CoreLibrary::ProxySettings
|
|
12
|
+
def self.from_env
|
|
13
|
+
address = ENV['PROXY_ADDRESS']
|
|
14
|
+
port = ENV['PROXY_PORT']
|
|
15
|
+
username = ENV['PROXY_USERNAME']
|
|
16
|
+
password = ENV['PROXY_PASSWORD']
|
|
17
|
+
return nil if address.nil? || address.strip.empty?
|
|
18
|
+
|
|
19
|
+
new(address: address, port: port, username: username, password: password)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# cell_point_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module CellPointApi
|
|
7
|
+
# Initializes a new instance of RequestLoggingConfiguration.
|
|
8
|
+
class RequestLoggingConfiguration < CoreLibrary::ApiRequestLoggingConfiguration
|
|
9
|
+
# @param log_body [Boolean] Indicates whether the message body should be logged. Default is false.
|
|
10
|
+
# @param log_headers [Boolean] Indicates whether the message headers should be logged. Default is false.
|
|
11
|
+
# @param headers_to_exclude [Array<String>] Array of headers not displayed in logging. Default is an empty array.
|
|
12
|
+
# @param headers_to_include [Array<String>] Array of headers to be displayed in logging. Default is an empty array.
|
|
13
|
+
# @param headers_to_unmask [Array<String>] Array of headers which values are non-sensitive to display in logging.
|
|
14
|
+
# Default is an empty array.
|
|
15
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
|
16
|
+
headers_to_exclude: nil, headers_to_unmask: nil,
|
|
17
|
+
include_query_in_path: false)
|
|
18
|
+
super(
|
|
19
|
+
log_body,
|
|
20
|
+
log_headers,
|
|
21
|
+
headers_to_exclude,
|
|
22
|
+
headers_to_include,
|
|
23
|
+
headers_to_unmask,
|
|
24
|
+
include_query_in_path
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
|
29
|
+
headers_to_exclude: nil, headers_to_unmask: nil, include_query_in_path: nil)
|
|
30
|
+
log_body ||= self.log_body
|
|
31
|
+
log_headers ||= self.log_headers
|
|
32
|
+
headers_to_include ||= self.headers_to_include
|
|
33
|
+
headers_to_exclude ||= self.headers_to_exclude
|
|
34
|
+
headers_to_unmask ||= self.headers_to_unmask
|
|
35
|
+
include_query_in_path ||= self.include_query_in_path
|
|
36
|
+
|
|
37
|
+
RequestLoggingConfiguration.new(
|
|
38
|
+
log_body: log_body,
|
|
39
|
+
log_headers: log_headers,
|
|
40
|
+
headers_to_include: headers_to_include,
|
|
41
|
+
headers_to_exclude: headers_to_exclude,
|
|
42
|
+
headers_to_unmask: headers_to_unmask,
|
|
43
|
+
include_query_in_path: include_query_in_path
|
|
44
|
+
)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.from_env
|
|
48
|
+
log_body = ENV['REQUEST_LOG_BODY']
|
|
49
|
+
log_headers = ENV['REQUEST_LOG_HEADERS']
|
|
50
|
+
headers_to_include = ENV['REQUEST_HEADERS_TO_INCLUDE']
|
|
51
|
+
headers_to_exclude = ENV['REQUEST_HEADERS_TO_EXCLUDE']
|
|
52
|
+
headers_to_unmask = ENV['REQUEST_HEADERS_TO_UNMASK']
|
|
53
|
+
include_query_in_path = ENV['REQUEST_INCLUDE_QUERY_IN_PATH']
|
|
54
|
+
|
|
55
|
+
new(
|
|
56
|
+
log_body: log_body,
|
|
57
|
+
log_headers: log_headers,
|
|
58
|
+
headers_to_include: headers_to_include,
|
|
59
|
+
headers_to_exclude: headers_to_exclude,
|
|
60
|
+
headers_to_unmask: headers_to_unmask,
|
|
61
|
+
include_query_in_path: include_query_in_path
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.any_logging_configured?
|
|
66
|
+
%w[
|
|
67
|
+
REQUEST_LOG_BODY
|
|
68
|
+
REQUEST_LOG_HEADERS
|
|
69
|
+
REQUEST_HEADERS_TO_INCLUDE
|
|
70
|
+
REQUEST_HEADERS_TO_EXCLUDE
|
|
71
|
+
REQUEST_HEADERS_TO_UNMASK
|
|
72
|
+
REQUEST_INCLUDE_QUERY_IN_PATH
|
|
73
|
+
].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Initializes a new instance of ResponseLoggingConfiguration.
|
|
78
|
+
class ResponseLoggingConfiguration < CoreLibrary::ApiResponseLoggingConfiguration
|
|
79
|
+
def initialize(log_body: false, log_headers: false, headers_to_include: nil,
|
|
80
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
|
81
|
+
super(
|
|
82
|
+
log_body,
|
|
83
|
+
log_headers,
|
|
84
|
+
headers_to_exclude,
|
|
85
|
+
headers_to_include,
|
|
86
|
+
headers_to_unmask
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def clone_with(log_body: nil, log_headers: nil, headers_to_include: nil,
|
|
91
|
+
headers_to_exclude: nil, headers_to_unmask: nil)
|
|
92
|
+
log_body ||= self.log_body
|
|
93
|
+
log_headers ||= self.log_headers
|
|
94
|
+
headers_to_include ||= self.headers_to_include
|
|
95
|
+
headers_to_exclude ||= self.headers_to_exclude
|
|
96
|
+
headers_to_unmask ||= self.headers_to_unmask
|
|
97
|
+
|
|
98
|
+
ResponseLoggingConfiguration.new(
|
|
99
|
+
log_body: log_body,
|
|
100
|
+
log_headers: log_headers,
|
|
101
|
+
headers_to_include: headers_to_include,
|
|
102
|
+
headers_to_exclude: headers_to_exclude,
|
|
103
|
+
headers_to_unmask: headers_to_unmask
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def self.from_env
|
|
108
|
+
log_body = ENV['RESPONSE_LOG_BODY']
|
|
109
|
+
log_headers = ENV['RESPONSE_LOG_HEADERS']
|
|
110
|
+
headers_to_include = ENV['RESPONSE_HEADERS_TO_INCLUDE']
|
|
111
|
+
headers_to_exclude = ENV['RESPONSE_HEADERS_TO_EXCLUDE']
|
|
112
|
+
headers_to_unmask = ENV['RESPONSE_HEADERS_TO_UNMASK']
|
|
113
|
+
|
|
114
|
+
new(
|
|
115
|
+
log_body: log_body,
|
|
116
|
+
log_headers: log_headers,
|
|
117
|
+
headers_to_include: headers_to_include,
|
|
118
|
+
headers_to_exclude: headers_to_exclude,
|
|
119
|
+
headers_to_unmask: headers_to_unmask
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def self.any_logging_configured?
|
|
124
|
+
%w[
|
|
125
|
+
RESPONSE_LOG_BODY
|
|
126
|
+
RESPONSE_LOG_HEADERS
|
|
127
|
+
RESPONSE_HEADERS_TO_INCLUDE
|
|
128
|
+
RESPONSE_HEADERS_TO_EXCLUDE
|
|
129
|
+
RESPONSE_HEADERS_TO_UNMASK
|
|
130
|
+
].any? { |key| ENV.key?(key) && !ENV[key].nil? && !ENV[key].empty? }
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Initializes a new instance of LoggingConfiguration.
|
|
135
|
+
class LoggingConfiguration < CoreLibrary::ApiLoggingConfiguration
|
|
136
|
+
def initialize(logger: nil, log_level: nil, mask_sensitive_headers: true,
|
|
137
|
+
request_logging_config: nil,
|
|
138
|
+
response_logging_config: nil)
|
|
139
|
+
request_logging_config ||= RequestLoggingConfiguration.new
|
|
140
|
+
response_logging_config ||= ResponseLoggingConfiguration.new
|
|
141
|
+
super(
|
|
142
|
+
logger,
|
|
143
|
+
log_level,
|
|
144
|
+
request_logging_config,
|
|
145
|
+
response_logging_config,
|
|
146
|
+
mask_sensitive_headers
|
|
147
|
+
)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def clone_with(logger: nil, log_level: nil, mask_sensitive_headers: nil,
|
|
151
|
+
request_logging_config: nil, response_logging_config: nil)
|
|
152
|
+
logger ||= self.logger
|
|
153
|
+
log_level ||= self.log_level
|
|
154
|
+
mask_sensitive_headers ||= self.mask_sensitive_headers
|
|
155
|
+
request_logging_config ||= self.request_logging_config.clone
|
|
156
|
+
response_logging_config ||= self.response_logging_config.clone
|
|
157
|
+
|
|
158
|
+
LoggingConfiguration.new(
|
|
159
|
+
logger: logger,
|
|
160
|
+
log_level: log_level,
|
|
161
|
+
mask_sensitive_headers: mask_sensitive_headers,
|
|
162
|
+
request_logging_config: request_logging_config,
|
|
163
|
+
response_logging_config: response_logging_config
|
|
164
|
+
)
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
def self.from_env
|
|
168
|
+
log_level = ENV['LOG_LEVEL']
|
|
169
|
+
mask_sensitive_headers = ENV['MASK_SENSITIVE_HEADERS']
|
|
170
|
+
|
|
171
|
+
new(
|
|
172
|
+
log_level: log_level,
|
|
173
|
+
mask_sensitive_headers: mask_sensitive_headers,
|
|
174
|
+
request_logging_config: RequestLoggingConfiguration.from_env,
|
|
175
|
+
response_logging_config: ResponseLoggingConfiguration.from_env
|
|
176
|
+
)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def self.any_logging_configured?
|
|
180
|
+
RequestLoggingConfiguration.any_logging_configured? ||
|
|
181
|
+
ResponseLoggingConfiguration.any_logging_configured? ||
|
|
182
|
+
ENV.key?('LOG_LEVEL') ||
|
|
183
|
+
ENV.key?('MASK_SENSITIVE_HEADERS')
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# cell_point_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module CellPointApi
|
|
7
|
+
# Represents the generic logger facade
|
|
8
|
+
class AbstractLogger < Logger
|
|
9
|
+
# Logs a message with a specified log level and additional parameters.
|
|
10
|
+
# @param level [Symbol] The log level of the message.
|
|
11
|
+
# @param message [String] The message to log.
|
|
12
|
+
# @param params [Hash] Additional parameters to include in the log message.
|
|
13
|
+
def log(level, message, params)
|
|
14
|
+
raise NotImplementedError, 'This method needs to be implemented in a child class.'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# cell_point_api
|
|
2
|
+
#
|
|
3
|
+
# This file was automatically generated by APIMATIC v3.0 (
|
|
4
|
+
# https://www.apimatic.io ).
|
|
5
|
+
|
|
6
|
+
module CellPointApi
|
|
7
|
+
# Account information for the buyer.
|
|
8
|
+
class Account < BaseModel
|
|
9
|
+
SKIP = Object.new
|
|
10
|
+
private_constant :SKIP
|
|
11
|
+
|
|
12
|
+
# Username of the buyer.
|
|
13
|
+
# @return [String]
|
|
14
|
+
attr_accessor :username
|
|
15
|
+
|
|
16
|
+
# User email address
|
|
17
|
+
# @return [String]
|
|
18
|
+
attr_accessor :email_address
|
|
19
|
+
|
|
20
|
+
# User email address
|
|
21
|
+
# @return [AccountType]
|
|
22
|
+
attr_accessor :account_type
|
|
23
|
+
|
|
24
|
+
# User email address
|
|
25
|
+
# @return [AccountStatus]
|
|
26
|
+
attr_accessor :account_status
|
|
27
|
+
|
|
28
|
+
# Merchant defined level of the account.
|
|
29
|
+
# @return [String]
|
|
30
|
+
attr_accessor :account_level
|
|
31
|
+
|
|
32
|
+
# The shopper's date of birth.
|
|
33
|
+
# Format ISO-8601: YYYY-MM-DD
|
|
34
|
+
# @return [Date]
|
|
35
|
+
attr_accessor :date_of_birth
|
|
36
|
+
|
|
37
|
+
# Genders for individuals
|
|
38
|
+
# @return [Gender]
|
|
39
|
+
attr_accessor :gender
|
|
40
|
+
|
|
41
|
+
# Buyer's account history, used for fraud checks.
|
|
42
|
+
# @return [BuyerHistory]
|
|
43
|
+
attr_accessor :history
|
|
44
|
+
|
|
45
|
+
# If buyer has installed the merchant's mobile app.
|
|
46
|
+
# @return [TrueClass | FalseClass]
|
|
47
|
+
attr_accessor :is_mobile_app_installed
|
|
48
|
+
|
|
49
|
+
# Loyalty account information.
|
|
50
|
+
# @return [LoyaltyAccount]
|
|
51
|
+
attr_accessor :loyalty_account
|
|
52
|
+
|
|
53
|
+
# A mapping from model property names to API property names.
|
|
54
|
+
def self.names
|
|
55
|
+
@_hash = {} if @_hash.nil?
|
|
56
|
+
@_hash['username'] = 'username'
|
|
57
|
+
@_hash['email_address'] = 'emailAddress'
|
|
58
|
+
@_hash['account_type'] = 'accountType'
|
|
59
|
+
@_hash['account_status'] = 'accountStatus'
|
|
60
|
+
@_hash['account_level'] = 'accountLevel'
|
|
61
|
+
@_hash['date_of_birth'] = 'dateOfBirth'
|
|
62
|
+
@_hash['gender'] = 'gender'
|
|
63
|
+
@_hash['history'] = 'history'
|
|
64
|
+
@_hash['is_mobile_app_installed'] = 'isMobileAppInstalled'
|
|
65
|
+
@_hash['loyalty_account'] = 'loyaltyAccount'
|
|
66
|
+
@_hash
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# An array for optional fields
|
|
70
|
+
def self.optionals
|
|
71
|
+
%w[
|
|
72
|
+
account_type
|
|
73
|
+
account_status
|
|
74
|
+
account_level
|
|
75
|
+
date_of_birth
|
|
76
|
+
gender
|
|
77
|
+
history
|
|
78
|
+
is_mobile_app_installed
|
|
79
|
+
loyalty_account
|
|
80
|
+
]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# An array for nullable fields
|
|
84
|
+
def self.nullables
|
|
85
|
+
[]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def initialize(username:, email_address:, account_type: SKIP,
|
|
89
|
+
account_status: AccountStatus::ACTIVE, account_level: SKIP,
|
|
90
|
+
date_of_birth: SKIP, gender: SKIP, history: SKIP,
|
|
91
|
+
is_mobile_app_installed: SKIP, loyalty_account: SKIP,
|
|
92
|
+
additional_properties: nil)
|
|
93
|
+
# Add additional model properties to the instance
|
|
94
|
+
additional_properties = {} if additional_properties.nil?
|
|
95
|
+
|
|
96
|
+
@username = username
|
|
97
|
+
@email_address = email_address
|
|
98
|
+
@account_type = account_type unless account_type == SKIP
|
|
99
|
+
@account_status = account_status unless account_status == SKIP
|
|
100
|
+
@account_level = account_level unless account_level == SKIP
|
|
101
|
+
@date_of_birth = date_of_birth unless date_of_birth == SKIP
|
|
102
|
+
@gender = gender unless gender == SKIP
|
|
103
|
+
@history = history unless history == SKIP
|
|
104
|
+
@is_mobile_app_installed = is_mobile_app_installed unless is_mobile_app_installed == SKIP
|
|
105
|
+
@loyalty_account = loyalty_account unless loyalty_account == SKIP
|
|
106
|
+
@additional_properties = additional_properties
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Creates an instance of the object from a hash.
|
|
110
|
+
def self.from_hash(hash)
|
|
111
|
+
return nil unless hash
|
|
112
|
+
|
|
113
|
+
# Extract variables from the hash.
|
|
114
|
+
username = hash.key?('username') ? hash['username'] : nil
|
|
115
|
+
email_address = hash.key?('emailAddress') ? hash['emailAddress'] : nil
|
|
116
|
+
account_type = hash.key?('accountType') ? hash['accountType'] : SKIP
|
|
117
|
+
account_status = hash['accountStatus'] ||= AccountStatus::ACTIVE
|
|
118
|
+
account_level = hash.key?('accountLevel') ? hash['accountLevel'] : SKIP
|
|
119
|
+
date_of_birth = hash.key?('dateOfBirth') ? hash['dateOfBirth'] : SKIP
|
|
120
|
+
gender = hash.key?('gender') ? hash['gender'] : SKIP
|
|
121
|
+
history = BuyerHistory.from_hash(hash['history']) if hash['history']
|
|
122
|
+
is_mobile_app_installed =
|
|
123
|
+
hash.key?('isMobileAppInstalled') ? hash['isMobileAppInstalled'] : SKIP
|
|
124
|
+
loyalty_account = LoyaltyAccount.from_hash(hash['loyaltyAccount']) if hash['loyaltyAccount']
|
|
125
|
+
|
|
126
|
+
# Create a new hash for additional properties, removing known properties.
|
|
127
|
+
new_hash = hash.reject { |k, _| names.value?(k) }
|
|
128
|
+
|
|
129
|
+
additional_properties = APIHelper.get_additional_properties(
|
|
130
|
+
new_hash, proc { |value| value }
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Create object from extracted values.
|
|
134
|
+
Account.new(username: username,
|
|
135
|
+
email_address: email_address,
|
|
136
|
+
account_type: account_type,
|
|
137
|
+
account_status: account_status,
|
|
138
|
+
account_level: account_level,
|
|
139
|
+
date_of_birth: date_of_birth,
|
|
140
|
+
gender: gender,
|
|
141
|
+
history: history,
|
|
142
|
+
is_mobile_app_installed: is_mobile_app_installed,
|
|
143
|
+
loyalty_account: loyalty_account,
|
|
144
|
+
additional_properties: additional_properties)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Provides a human-readable string representation of the object.
|
|
148
|
+
def to_s
|
|
149
|
+
class_name = self.class.name.split('::').last
|
|
150
|
+
"<#{class_name} username: #{@username}, email_address: #{@email_address}, account_type:"\
|
|
151
|
+
" #{@account_type}, account_status: #{@account_status}, account_level: #{@account_level},"\
|
|
152
|
+
" date_of_birth: #{@date_of_birth}, gender: #{@gender}, history: #{@history},"\
|
|
153
|
+
" is_mobile_app_installed: #{@is_mobile_app_installed}, loyalty_account:"\
|
|
154
|
+
" #{@loyalty_account}, additional_properties: #{@additional_properties}>"
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Provides a debugging-friendly string with detailed object information.
|
|
158
|
+
def inspect
|
|
159
|
+
class_name = self.class.name.split('::').last
|
|
160
|
+
"<#{class_name} username: #{@username.inspect}, email_address: #{@email_address.inspect},"\
|
|
161
|
+
" account_type: #{@account_type.inspect}, account_status: #{@account_status.inspect},"\
|
|
162
|
+
" account_level: #{@account_level.inspect}, date_of_birth: #{@date_of_birth.inspect},"\
|
|
163
|
+
" gender: #{@gender.inspect}, history: #{@history.inspect}, is_mobile_app_installed:"\
|
|
164
|
+
" #{@is_mobile_app_installed.inspect}, loyalty_account: #{@loyalty_account.inspect},"\
|
|
165
|
+
" additional_properties: #{@additional_properties}>"
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|