Sha256: b0e6cae115ddd36518d10f3c9f2313e3716bb3e9bd817d5597784ca635a54c4f

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

module NetSuite
  module Actions
    class Get
      include SavonSupport

      def initialize(id, klass)
        @id    = id
        @klass = klass
      end

      private

      def request
        connection.request :platformMsgs, :get 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.header = auth_header
          soap.body   = request_body
        end
      end

      def soap_type
        @klass.to_s.split('::').last.lower_camelcase
      end

      # <soap:Body>
      #   <platformMsgs:get>
      #     <platformMsgs:baseRef internalId="983" type="customer" xsi:type="platformCore:RecordRef">
      #       <platformCore:name/>
      #     </platformMsgs:baseRef>
      #   </platformMsgs:get>
      # </soap:Body>
      def request_body
        {
          'platformMsgs:baseRef' => {},
          :attributes! => {
            'platformMsgs:baseRef' => {
              :internalId => @id,
              :type       => soap_type,
              'xsi:type'  => 'platformCore:RecordRef'
            }
          }
        }
      end

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

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

      def response_hash
        @response_hash = @response[:get_response][:read_response]
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
netsuite-0.0.10 lib/netsuite/actions/get.rb
netsuite-0.0.9 lib/netsuite/actions/get.rb
netsuite-0.0.8 lib/netsuite/actions/get.rb