Class: LedgerSync::Ledgers::QuickBooksOnline::Department::Serializer

Inherits:
Serializer show all
Defined in:
lib/ledger_sync/ledgers/quickbooks_online/department/serializer.rb

Instance Method Summary collapse

Methods inherited from Serializer

amount, date, id

Methods inherited from Serializer

attribute, attribute_class, attributes, references_many, references_one, serializer_from

Methods included from Serialization::Mixin

included

Instance Method Details

#serialize(args = {}) ⇒ Object

Sending “ParentRef”: null results in QBO API crash This patches serialized hash to exclude it unless we don’t set value



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ledger_sync/ledgers/quickbooks_online/department/serializer.rb', line 31

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