Sha256: 0c9d4c67a8029b9b5d162dd0cc59436f52eb60eab0d6e9627172ab9052b08872

Contents?: true

Size: 640 Bytes

Versions: 3

Compression:

Stored size: 640 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)

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

          def valid_classes
            [
              Hash
            ]
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ledger_sync-1.4.2 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb
ledger_sync-1.4.1 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb
ledger_sync-1.4.0 lib/ledger_sync/ledgers/netsuite/type/deserializer_entity_type.rb