Sha256: 850f69837e708e3de0fe430e4a552d759c96c3fedf65fff58ab12b2f6864f995
Contents?: true
Size: 1.98 KB
Versions: 1
Compression:
Stored size: 1.98 KB
Contents
# frozen_string_literal: true require 'ledger_sync/adaptors/quickbooks_online/account/mapping' module LedgerSync module Adaptors module QuickBooksOnline module Account module Operations class Update < Operation::Update class Contract < LedgerSync::Adaptors::Contract params do required(:ledger_id).filled(:string) required(:name).filled(:string) required(:classification).filled(:string) required(:account_type).filled(:string) required(:account_sub_type).filled(:string) required(:number).maybe(:integer) required(:currency).maybe(:string) required(:description).maybe(:string) required(:active).maybe(:bool) end end private def operate ledger_resource_data = adaptor.find( resource: 'account', id: resource.ledger_id ) response = adaptor.post( resource: 'account', payload: merge_into(from: local_resource_data, to: ledger_resource_data) ) resource.ledger_id = response.dig('Id') success(response: response) end def local_resource_data { 'Name' => resource.name, 'Classification' => Mapping::ACCOUNT_CLASSIFICATIONS[resource.classification], 'AccountType' => Mapping::ACCOUNT_TYPES[resource.account_type], 'AccountSubType' => Mapping::ACCOUNT_SUB_TYPES[resource.account_sub_type], 'AcctNum' => resource.number, 'CurrencyRef' => { 'value' => resource.currency, }, 'Description' => resource.description, 'Active' => resource.active } end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ledger_sync-1.1.1 | lib/ledger_sync/adaptors/quickbooks_online/account/operations/update.rb |