Class: NetSuite::Actions::Initialize

Inherits:
AbstractAction show all
Includes:
Support::Requests
Defined in:
lib/netsuite/actions/initialize.rb

Defined Under Namespace

Modules: Support

Instance Method Summary collapse

Methods included from Support::Requests

#call, included

Methods inherited from AbstractAction

#request

Constructor Details

#initialize(klass, object) ⇒ Initialize

Returns a new instance of Initialize.



7
8
9
10
# File 'lib/netsuite/actions/initialize.rb', line 7

def initialize(klass, object)
  @klass  = klass
  @object = object
end

Instance Method Details

#action_nameObject



55
56
57
# File 'lib/netsuite/actions/initialize.rb', line 55

def action_name
  :initialize
end

#request_bodyObject

<platformMsgs:initializeRecord>

<platformCore:type>invoice</platformCore:type>
<platformCore:reference internalId="1513" type="salesOrder">
  <platformCore:name>1511</platformCore:name>
</platformCore:reference>

</platformMsgs:initializeRecord>



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/netsuite/actions/initialize.rb', line 18

def request_body
  {
    'platformMsgs:initializeRecord' => {
      'platformCore:type'      => NetSuite::Support::Records.netsuite_type(@klass),
      'platformCore:reference' => {},
      :attributes!             => {
        'platformCore:reference' => {
          'internalId' => @object.internal_id,
          :type        => NetSuite::Support::Records.netsuite_type(@object)
        }
      }
    }
  }
end

#request_optionsObject



45
46
47
48
49
50
51
52
53
# File 'lib/netsuite/actions/initialize.rb', line 45

def request_options
  {
    namespaces: {
      'xmlns:platformMsgs'    => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
      'xmlns:platformCore'    => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
      'xmlns:platformCoreTyp' => "urn:types.core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
    }
  }
end

#response_bodyObject



41
42
43
# File 'lib/netsuite/actions/initialize.rb', line 41

def response_body
  @response_body ||= response_hash[:record]
end

#response_hashObject



33
34
35
# File 'lib/netsuite/actions/initialize.rb', line 33

def response_hash
  @response_hash ||= @response.to_hash[:initialize_response][:read_response]
end

#success?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/netsuite/actions/initialize.rb', line 37

def success?
  @success ||= response_hash[:status][:@is_success] == 'true'
end