Class: NetSuite::Actions::Update
- Inherits:
-
AbstractAction
- Object
- AbstractAction
- 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
- #action_name ⇒ Object
- #errors ⇒ Object
-
#initialize(klass, attributes) ⇒ Update
constructor
A new instance of Update.
-
#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
Methods inherited from AbstractAction
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
#action_name ⇒ Object
68 69 70 |
# File 'lib/netsuite/actions/update.rb', line 68 def action_name :update end |
#errors ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/netsuite/actions/update.rb', line 60 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_body ⇒ Object
<platformMsgs:update>
<platformMsgs:record internalId="980" xsi:type="listRel:Customer">
<listRel:companyName>Shutter Fly Corporation</listRel:companyName>
</platformMsgs:record>
</platformMsgs:update>
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/netsuite/actions/update.rb', line 19 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
46 47 48 |
# File 'lib/netsuite/actions/update.rb', line 46 def response_body @response_body ||= response_hash[:base_ref] end |
#response_errors ⇒ Object
50 51 52 53 54 |
# File 'lib/netsuite/actions/update.rb', line 50 def response_errors if response_hash[:status] && response_hash[:status][:status_detail] @response_errors ||= errors end end |
#success? ⇒ Boolean
42 43 44 |
# File 'lib/netsuite/actions/update.rb', line 42 def success? @success ||= response_hash[:status][:@is_success] == 'true' end |
#updated_record ⇒ Object
38 39 40 |
# File 'lib/netsuite/actions/update.rb', line 38 def updated_record @updated_record ||= @klass.new(@attributes) end |