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 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/netsuite/actions/update.rb', line 11 def request api_version = NetSuite::Configuration.api_version NetSuite::Configuration.connection( namespaces: { 'xmlns:platformMsgs' => "urn:messages_#{api_version}.platform.webservices.netsuite.com", 'xmlns:platformCore' => "urn:core_#{api_version}.platform.webservices.netsuite.com", 'xmlns:listRel' => "urn:relationships_#{api_version}.lists.webservices.netsuite.com", 'xmlns:tranSales' => "urn:sales_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:platformCommon' => "urn:common_#{api_version}.platform.webservices.netsuite.com", 'xmlns:listAcct' => "urn:accounting_#{api_version}.lists.webservices.netsuite.com", 'xmlns:actSched' => "urn:scheduling_#{api_version}.activities.webservices.netsuite.com", 'xmlns:tranCust' => "urn:customers_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:setupCustom' => "urn:customization_#{api_version}.setup.webservices.netsuite.com", }, ).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>
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/netsuite/actions/update.rb', line 34 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
61 62 63 |
# File 'lib/netsuite/actions/update.rb', line 61 def response_body @response_body ||= response_hash[:base_ref] end |
#response_hash ⇒ Object
65 66 67 |
# File 'lib/netsuite/actions/update.rb', line 65 def response_hash @response_hash ||= @response.to_hash[:update_response][:write_response] end |
#success? ⇒ Boolean
57 58 59 |
# File 'lib/netsuite/actions/update.rb', line 57 def success? @success ||= response_hash[:status][:@is_success] == 'true' end |
#updated_record ⇒ Object
53 54 55 |
# File 'lib/netsuite/actions/update.rb', line 53 def updated_record @updated_record ||= @klass.new(@attributes) end |