Sha256: a8ce5e6a31560d2cd67f1dbcff4bbebfafe8b56382c649c38d748fe950742365

Contents?: true

Size: 1.16 KB

Versions: 5

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module LedgerSync
  module Adaptors
    module NetSuiteSOAP
      module Subsidiary
        module Operations
          class Create < NetSuiteSOAP::Operation::Create
            class Contract < LedgerSync::Adaptors::Contract
              params do
                required(:external_id).filled(:string)
                required(:ledger_id).value(:nil)
                required(:name).filled(:string)
                required(:state).filled(:string)
              end
            end

            private

            def operate
              netsuite_resource = ::NetSuite::Records::Subsidiary.new(
                external_id: resource.external_id,
                name: resource.name,
                state: resource.state
              )

              return netsuite_failure(netsuite_resource: netsuite_resource) unless netsuite_resource.add

              resource.name = netsuite_resource.name
              resource.ledger_id = netsuite_resource.internal_id

              success(
                resource: resource,
                response: netsuite_resource
              )
            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/subsidiary/operations/create.rb
ledger_sync-1.3.4 lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/create.rb
ledger_sync-1.3.3 lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/create.rb
ledger_sync-1.3.2 lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/create.rb
ledger_sync-1.3.1 lib/ledger_sync/adaptors/netsuite_soap/subsidiary/operations/create.rb