Sha256: 73f069edec19af81c15045148482a8db265f3c899b9087479bd851be576a935e

Contents?: true

Size: 619 Bytes

Versions: 5

Compression:

Stored size: 619 Bytes

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module NetSuite
      class Type
        class DeserializerEntityType < LedgerSync::Type::Value
          private

          def cast_value(args = {})
            value = args.fetch(:value)

            return if value.nil?

            resource = value.fetch('links').first.fetch('href').include?('vendor') ? Vendor : Customer
            resource.new(
              ledger_id: value['id']
            )
          end

          def valid_classes
            [
              Hash
            ]
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ledger_sync-1.6.0 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb
ledger_sync-1.4.4 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb