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 Attribute Summary collapse
-
#response_hash ⇒ Object
readonly
Returns the value of attribute response_hash.
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(klass, attributes) ⇒ Update
constructor
A new instance of Update.
- #request(credentials = {}) ⇒ 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_errors ⇒ Object
- #success? ⇒ Boolean
- #updated_record ⇒ Object
Methods included from Support::Requests
Constructor Details
#initialize(klass, attributes) ⇒ Update
Returns a new instance of Update.
9 10 11 12 |
# File 'lib/netsuite/actions/update.rb', line 9 def initialize(klass, attributes) @klass = klass @attributes = attributes end |
Instance Attribute Details
#response_hash ⇒ Object (readonly)
Returns the value of attribute response_hash.
7 8 9 |
# File 'lib/netsuite/actions/update.rb', line 7 def response_hash @response_hash end |
Instance Method Details
#errors ⇒ Object
64 65 66 67 68 69 70 |
# 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 = {}) ⇒ Object
14 15 16 |
# File 'lib/netsuite/actions/update.rb', line 14 def request(credentials={}) NetSuite::Configuration.connection({}, credentials).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>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# 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 ⇒ Object
50 51 52 |
# File 'lib/netsuite/actions/update.rb', line 50 def response_body @response_body ||= response_hash[:base_ref] end |
#response_errors ⇒ Object
54 55 56 57 58 |
# 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? ⇒ Boolean
46 47 48 |
# File 'lib/netsuite/actions/update.rb', line 46 def success? @success ||= response_hash[:status][:@is_success] == 'true' end |
#updated_record ⇒ Object
42 43 44 |
# File 'lib/netsuite/actions/update.rb', line 42 def updated_record @updated_record ||= @klass.new(@attributes) end |