require 'genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/interfaces' require 'genesis_ruby/api/constants/transactions/parameters/threeds/version2/sdk/ui_types' require 'genesis_ruby/errors/invalid_argument_error' module GenesisRuby module Api module Mixins module Requests module Financial module Threeds module Version2 # Mixin ThreedsV2 SDK module Sdk attr_reader :threeds_v2_sdk_interface, :threeds_v2_sdk_application_id, :threeds_v2_sdk_encrypted_data, :threeds_v2_sdk_ephemeral_public_key_pair, :threeds_v2_sdk_max_timeout, :threeds_v2_sdk_reference_number # SDK Interface types that the device of the consumer supports for displaying specific challenge # interfaces within the SDK def threeds_v2_sdk_interface=(value) allowed_interfaces = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::Sdk:: Interfaces.all allowed_options attribute: __method__, allowed: allowed_interfaces, value: value, allow_empty: true end # UI type that the device of the consumer supports for displaying specific challenge interface def threeds_v2_sdk_ui_types @threeds_v2_sdk_ui_types ||= [] end # UI type that the device of the consumer supports for displaying specific challenge interface def threeds_v2_sdk_ui_types=(value) ui_types = GenesisRuby::Api::Constants::Transactions::Parameters::Threeds::Version2::Sdk::UiTypes unless ui_types.valid?(value) raise InvalidArgumentError, format( 'Invalid value given for %{method}. Allowed values: %{allowed}', method: __method__, allowed: ui_types.all ) end threeds_v2_sdk_ui_types.push value.to_s.downcase end # Universally unique ID created upon all installations and updates of the 3DS Requester APP on # a Customer Device def threeds_v2_sdk_application_id=(value) limited_string attribute: __method__, value: value.to_s.empty? ? nil : value, max: 36 end # JWE Object as defined Section 6.2.2.1 containing data encrypted by the SDK for the DS to decrypt def threeds_v2_sdk_encrypted_data=(value) limited_string attribute: __method__, value: value.to_s.empty? ? nil : value, max: 64_000 end # Public key component of the ephemeral key pair generated by the 3DS SDK and used to # establish session keys between the 3DS SDK and ACS def threeds_v2_sdk_ephemeral_public_key_pair=(value) limited_string attribute: __method__, value: value.to_s.empty? ? nil : value, max: 256 end # Indicates the maximum amount of time (in minutes) for all exchanges def threeds_v2_sdk_max_timeout=(value) parse_int attribute: __method__, value: value, allow_empty: true return if @threeds_v2_sdk_max_timeout.nil? error_message = format( 'Invalid value given for %{attribute}, should be greater than or equal to 5.', attribute: __method__ ) raise InvalidArgumentError, error_message if @threeds_v2_sdk_max_timeout < 5 end # Identifies the vendor and version of the 3DS SDK that is integrated in a 3DS Requester App, # assigned by EMVCo when the 3DS SDK is approved def threeds_v2_sdk_reference_number=(value) limited_string attribute: __method__, value: value.to_s.empty? ? nil : value, max: 32 end protected # Request SDK Attributes structure def sdk_attributes { interface: threeds_v2_sdk_interface, ui_types: { ui_type: threeds_v2_sdk_ui_types }, application_id: threeds_v2_sdk_application_id, encrypted_data: threeds_v2_sdk_encrypted_data, ephemeral_public_key_pair: threeds_v2_sdk_ephemeral_public_key_pair, max_timeout: threeds_v2_sdk_max_timeout, reference_number: threeds_v2_sdk_reference_number } end end end end end end end end end