Sha256: 96f0eadd5650d5e04479d9bd3a45fe53652f6bbcbf29333d889f3c61ca5719f1

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# typed: true
# frozen_string_literal: true

module EML
  module UK
    class Model
      class Transaction
        FIELDS = %w[
          acceptor_code
          acceptor_location
          activity
          amount
          auth_id
          authorization_request_id
          currency
          eml_id
          expiration_minutes
          location
          merchant_category_code
          merchant_country
          notes
          original_transaction_date
          pos_transaction_time
          reason
          result
          retrieval_reference_number
          system_transaction_id
          timestamp
          transaction_amount
          transaction_currency
          user
        ].freeze
        private_constant :FIELDS

        FIELDS.each { |field| __send__(:attr_reader, :"#{field}") }

        def initialize(response)
          FIELDS.each do |field|
            value = field_value(field, response[field])
            instance_variable_set(:"@#{field}", value)
          end
        end

        private

        def field_value(field, raw_value)
          if field.include?("time")
            EML::UK::ParseDate.(raw_value)
          else
            raw_value
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eml-1.0.0 lib/eml/uk/model/transaction.rb