Sha256: 025f182fb693b0da4236b43e35535ea7f3a663518d5a57e500dbfcb87deb578d

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module LedgerSync
  module Adaptors
    module NetSuiteSOAP
      module Customer
        module Operations
          class Find < NetSuiteSOAP::Operation::Find
            class Contract < LedgerSync::Adaptors::Contract
              params do
                optional(:external_id).maybe(:string)
                required(:ledger_id).filled(:string)
                optional(:email).maybe(:string)
                optional(:name).maybe(:string)
                optional(:phone_number).maybe(:string)
                required(:subsidiary).maybe(:hash, Types::Reference)
              end
            end

            private

            def operate
              customer = ::NetSuite::Records::Customer.get(
                internal_id: resource.ledger_id
              )

              resource.email = customer.email
              resource.external_id = customer.external_id
              resource.external_id = customer.internal_id
              resource.name = if customer.is_person
                                "#{customer.first_name} #{customer.last_name}"
                              else
                                customer.company_name
                              end
              resource.phone_number = customer.phone

              resource.ledger_id = customer.internal_id

              success(
                resource: resource,
                response: customer
              )
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ledger_sync-1.3.5 lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb
ledger_sync-1.3.4 lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb
ledger_sync-1.3.3 lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb
ledger_sync-1.3.2 lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb
ledger_sync-1.3.1 lib/ledger_sync/adaptors/netsuite_soap/customer/operations/find.rb