Sha256: 23f49ae191c72b7b2357d3b50398728e9c519d899d1ee795255a4a7c6ec20d5d

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module LedgerSync
  module Ledgers
    module NetSuiteSOAP
      class Customer
        module Operations
          class Find < NetSuiteSOAP::Operation::Find
            class Contract < LedgerSync::Ledgers::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

9 entries across 9 versions & 1 rubygems

Version Path
ledger_sync-1.7.0 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.6.0 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.5.2 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.5.1 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.5.0 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.4.4 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.4.2 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.4.1 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb
ledger_sync-1.4.0 lib/ledger_sync/ledgers/netsuite_soap/customer/operations/find.rb