Class: NetSuite::Actions::Update
- Inherits:
-
Object
- Object
- NetSuite::Actions::Update
- Includes:
- Support::Requests
- Defined in:
- lib/netsuite/actions/update.rb
Defined Under Namespace
Modules: Support
Instance Method Summary collapse
-
#initialize(klass, attributes) ⇒ Update
constructor
A new instance of Update.
- #request ⇒ Object
-
#request_body ⇒ Object
<platformMsgs:update> <platformMsgs:record internalId=“980” xsi:type=“listRel:Customer”> <listRel:companyName>Shutter Fly Corporation</listRel:companyName> </platformMsgs:record> </platformMsgs:update>.
- #response_body ⇒ Object
- #response_hash ⇒ Object
- #success? ⇒ Boolean
- #updated_record ⇒ Object
Methods included from Support::Requests
Constructor Details
#initialize(klass, attributes) ⇒ Update
Returns a new instance of Update.
6 7 8 9 |
# File 'lib/netsuite/actions/update.rb', line 6 def initialize(klass, attributes) @klass = klass @attributes = attributes end |
Instance Method Details
#request ⇒ Object
11 12 13 |
# File 'lib/netsuite/actions/update.rb', line 11 def request NetSuite::Configuration.connection.call :update, :message => request_body end |
#request_body ⇒ Object
<platformMsgs:update>
<platformMsgs:record internalId="980" xsi:type="listRel:Customer">
<listRel:companyName>Shutter Fly Corporation</listRel:companyName>
</platformMsgs:record>
</platformMsgs:update>
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/netsuite/actions/update.rb', line 20 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 ⇒ Object
47 48 49 |
# File 'lib/netsuite/actions/update.rb', line 47 def response_body @response_body ||= response_hash[:base_ref] end |
#response_hash ⇒ Object
51 52 53 |
# File 'lib/netsuite/actions/update.rb', line 51 def response_hash @response_hash ||= @response.to_hash[:update_response][:write_response] end |
#success? ⇒ Boolean
43 44 45 |
# File 'lib/netsuite/actions/update.rb', line 43 def success? @success ||= response_hash[:status][:@is_success] == 'true' end |
#updated_record ⇒ Object
39 40 41 |
# File 'lib/netsuite/actions/update.rb', line 39 def updated_record @updated_record ||= @klass.new(@attributes) end |