Sha256: 372aa209e875377d47fb1ff206fb3727ae070304036fa9416033bdbdbef0ed9c

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

module NetSuite
  module Actions
    class Add
      include SavonSupport

      def initialize(obj = nil)
        @obj = obj
      end

      private

      def request
        connection.request :platformMsgs, :add do
          soap.namespaces['xmlns:platformMsgs'] = 'urn:messages_2011_2.platform.webservices.netsuite.com'
          soap.namespaces['xmlns:platformCore'] = 'urn:core_2011_2.platform.webservices.netsuite.com'
          soap.namespaces['xmlns:listRel']      = 'urn:relationships_2011_2.lists.webservices.netsuite.com'
          soap.header = auth_header
          soap.body   = request_body
        end
      end

      # <soap:Body>
      #   <platformMsgs:add>
      #     <platformMsgs:record xsi:type="listRel:Customer">
      #       <listRel:entityId>Shutter Fly</listRel:entityId>
      #       <listRel:companyName>Shutter Fly, Inc</listRel:companyName>
      #     </platformMsgs:record>
      #   </platformMsgs:add>
      # </soap:Body>
      def request_body
        {
          'platformMsgs:record' => @obj.to_record,
          :attributes! => {
            'platformMsgs:record' => {
              'xsi:type' => @obj.record_type
            }
          }
        }
      end

      def success?
        @success ||= response_hash[:status][:@is_success] == 'true'
      end

      def response_body
        @response_body ||= response_hash[:base_ref]
      end

      def response_hash
        @response_hash ||= @response.to_hash[:add_response][:write_response]
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
netsuite-0.0.10 lib/netsuite/actions/add.rb
netsuite-0.0.9 lib/netsuite/actions/add.rb
netsuite-0.0.8 lib/netsuite/actions/add.rb
netsuite-0.0.7 lib/netsuite/actions/add.rb
netsuite-0.0.6 lib/netsuite/actions/add.rb
netsuite-0.0.5 lib/netsuite/actions/add.rb