class NetSuite::Actions::Update

Attributes

response_hash[R]

Public Class Methods

new(klass, attributes) click to toggle source
# File lib/netsuite/actions/update.rb, line 9
def initialize(klass, attributes)
  @klass      = klass
  @attributes = attributes
end

Public Instance Methods

errors() click to toggle source
# File lib/netsuite/actions/update.rb, line 64
def errors
  error_obj = response_hash[:status][:status_detail]
  error_obj = [error_obj] if error_obj.class == Hash
  error_obj.map do |error|
    NetSuite::Error.new(error)
  end
end
request(credentials={}) click to toggle source
# File lib/netsuite/actions/update.rb, line 14
def request(credentials={})
  NetSuite::Configuration.connection({}, credentials).call :update, :message => request_body
end
request_body() click to toggle source

<platformMsgs:update>

<platformMsgs:record internalId="980" xsi:type="listRel:Customer">
  <listRel:companyName>Shutter Fly Corporation</listRel:companyName>
</platformMsgs:record>

</platformMsgs:update>

# File lib/netsuite/actions/update.rb, line 23
def request_body
  hash = {
    'platformMsgs:record' => {
      :content! => updated_record.to_record,
      '@xsi:type' => updated_record.record_type
    }
  }

  if updated_record.respond_to?(:internal_id) && updated_record.internal_id
    hash['platformMsgs:record']['@platformMsgs:internalId'] = updated_record.internal_id
  end

  if updated_record.respond_to?(:external_id) && updated_record.external_id
    hash['platformMsgs:record']['@platformMsgs:externalId'] = updated_record.external_id
  end

  hash
end
response_body() click to toggle source
# File lib/netsuite/actions/update.rb, line 50
def response_body
  @response_body ||= response_hash[:base_ref]
end
response_errors() click to toggle source
# File lib/netsuite/actions/update.rb, line 54
def response_errors
  if response_hash[:status] && response_hash[:status][:status_detail]
    @response_errors ||= errors
  end
end
success?() click to toggle source
# File lib/netsuite/actions/update.rb, line 46
def success?
  @success ||= response_hash[:status][:@is_success] == 'true'
end
updated_record() click to toggle source
# File lib/netsuite/actions/update.rb, line 42
def updated_record
  @updated_record ||= @klass.new(@attributes)
end