Sha256: 9ac2b577d7f91d022aa4506b3b131c98312e5c81b19a127dacb78bc75a5fffd3

Contents?: true

Size: 860 Bytes

Versions: 8

Compression:

Stored size: 860 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module QuickBooksOnline
      module Serialization
        module Type
          class DeserializeTransactionReferenceType < LedgerSync::Type::Value
            def cast_value(value:)
              return if value.nil?

              raise "Unknown value type.  Array expected.  Given: #{value.class.name}" unless value.is_a?(Array)
              return if value.empty?

              value.map do |item|
                resource_class = Client.resource_from_ledger_type(type: item['TxnType'])

                raise "Unknown QuickBooks Online resource type: #{item['TxnType']}" if resource_class.blank?

                resource_class.new(
                  ledger_id: item['TxnId']
                )
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ledger_sync-1.6.0 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb
ledger_sync-1.4.4 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb
ledger_sync-1.4.2 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb
ledger_sync-1.4.1 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb
ledger_sync-1.4.0 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/deserialize_transaction_reference_type.rb