Skip to content

Contributing to the Supported NetSuite API

iloveitaly edited this page Feb 27, 2013 · 1 revision

Resources

  • [NetSuite Documentation & External Links](NetSuite Development Resources)
  • [Note about how fields and RecordRefs are handled](Fields and RecordRefs)
  • Miscellaneous Development Gotchas

Example

  • Please submit a pull request for any models or actions that you would like to be included. The API is quite large and so we will necessarily not cover all of it. Please ensure that all tests are passing before submitting a pull request and add test specs for any additional features you add.

  • Records should go into the lib/netsuite/records/ directory.

  • Actions should be placed in their respective subdirectory under lib/netsuite/actions.

  • Example:

    # lib/netsuite/actions/customer/add.rb
    
    module NetSuite
      module Actions
        module Customer
          class Add
    
            def initialize(attributes = {})
              @attributes = attributes
            end
    
            def self.call(attributes)
              new(attributes).call
            end
    
            def call
              response = NetSuite::Configuration.connection.request :add do
                soap.header =  NetSuite::Configuration.auth_header
                soap.body = {
                  :entityId    => @attributes[:entity_id],
                  :companyName => @attributes[:company_name],
                  :unsubscribe => @attributes[:unsubscribe]
                }
              end
              success = response.to_hash[:add_response][:write_response][:status][:@is_success] == 'true'
              body    = response.to_hash[:add_response][:write_response][:base_ref]
              NetSuite::Response.new(:success => success, :body => body)
            end
    
          end
        end
      end
    end
    
    response = NetSuite::Actions::Customer::Add.call(
      :entity_id    => 'Shutter Fly',
      :company_name => 'Shutter Fly, Inc.',
      :unsubscribe  => false
    )                 # => #<NetSuite::Response:0x1041f64b5>
    response.success? # => true
    response.body     # => { :internal_id => '979', :type => 'customer' }