Sha256: d1f5d69ace0c617ff7ec2cc94b70156ff1ab025cb959726d1652ae557eca97f2

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

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

9 entries across 9 versions & 1 rubygems

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