Sha256: 47a57d2558cbfeb1f331d8c146602bde787ee80609980b06fd3a4d2c07b41968

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

module LedgerSync
  module Adaptors
    module QuickBooksOnline
      module Product
        module Operations
          class Upsert < Operation::Upsert
            class Contract < LedgerSync::Adaptors::Contract
              params do
                required(:ledger_id).maybe(:string)
                required(:ledger_id).maybe(:string)
                optional(:description).maybe(:string)
                required(:name).filled(:string)
              end
            end

            private

            def build
              op =  if qbo_item?
                      Update.new(adaptor: adaptor, resource: resource)
                    else
                      Create.new(adaptor: adaptor, resource: resource)
                    end

              add_root_operation(op)
            end

            def find_result
              @find_result ||= Find.new(
                adaptor: adaptor,
                resource: resource
              ).perform
            end

            def qbo_item?
              find_result.success?
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ledger_sync-1.0.3 lib/ledger_sync/adaptors/quickbooks_online/product/operations/upsert.rb
ledger_sync-1.0.2 lib/ledger_sync/adaptors/quickbooks_online/product/operations/upsert.rb
ledger_sync-1.0.0 lib/ledger_sync/adaptors/quickbooks_online/product/operations/upsert.rb