Sha256: 93bc3eb47b18f87e9d5a2986b3becc1b046b1c1524db477824b653a7e1f18060

Contents?: true

Size: 903 Bytes

Versions: 8

Compression:

Stored size: 903 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module QuickBooksOnline
      module Serialization
        module Type
          class SerializeTransactionReferenceType < LedgerSync::Type::Value
            def cast_value(value:)
              return if value.nil?
              raise "List expected.  Given: #{value.class.name}" unless value.is_a?(Array)
              unless value.all?(LedgerSync::Resource)
                raise "Resources expected.  Given: #{value.map { |i| i.class.name }.join(', ')}"
              end

              value.map do |resource|
                {
                  'TxnId' => resource.ledger_id,
                  'TxnType' => Client.ledger_resource_type_for(
                    resource_class: resource.class
                  ).classify
                }
              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/serialize_transaction_reference_type.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb
ledger_sync-1.4.4 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb
ledger_sync-1.4.2 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb
ledger_sync-1.4.1 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb
ledger_sync-1.4.0 lib/ledger_sync/ledgers/quickbooks_online/serialization/type/serialize_transaction_reference_type.rb