Sha256: 5e8c23791257d79bbef7f3a521396a13ce38b0114dda5936c44755bada0d3ccc

Contents?: true

Size: 1.12 KB

Versions: 13

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

require_relative '../reference/serializer'

module LedgerSync
  module QuickBooksOnline
    class Department
      class Serializer < QuickBooksOnline::Serializer
        id

        attribute :Name
        attribute :Active
        attribute :SubDepartment
        attribute :FullyQualifiedName

        references_one 'ParentRef',
                       resource_attribute: :Parent,
                       serializer: Reference::Serializer

        # Sending "ParentRef": {"value": null} results in QBO API crash
        # This patches serialized hash to exclude it unless we don't set value
        def serialize(args = {})
          deep_merge_unmapped_values = args.fetch(:deep_merge_unmapped_values, {})
          only_changes = args.fetch(:only_changes, false)
          resource = args.fetch(:resource)

          ret = super(only_changes: only_changes, resource: resource)

          return ret unless deep_merge_unmapped_values.any?

          deep_merge_if_not_mapped(
            current_hash: ret,
            hash_to_search: deep_merge_unmapped_values
          )
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
ledger_sync-quickbooks_online-2.0.0 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-1.0.1 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-1.0.0 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.4.0 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.3.1 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.3.0 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.2.6 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.2.5 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.2.4 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.2.2 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.2.1 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.2.0 lib/ledger_sync/quickbooks_online/department/serializer.rb
ledger_sync-quickbooks_online-0.1.1 lib/ledger_sync/quickbooks_online/department/serializer.rb