Permalink
Browse files

Merge pull request #1 from TalentTech/master

Authentication with role and GetSelectValue
  • Loading branch information...
vjebelev committed Jul 15, 2012
2 parents 6aa9be6 + e944db0 commit a684ac361b765865abc7b3edc196b8247b5bf267
Showing with 32 additions and 5 deletions.
  1. +1 −1 lib/netsuite_client.rb
  2. +13 −1 lib/netsuite_client/client.rb
  3. +1 −1 netsuite_client.gemspec
  4. +17 −2 test/netsuite_client_test.rb
View
@@ -5,7 +5,7 @@
require 'netsuite_client/symbol'
require 'rubygems'
-gem 'soap4r'
+gem 'soap4r-ruby1.9'
DEFAULT_NS_WSDL_VERSION = '2011_2'
if ENV['FORCE_NS_WSDL_VERSION']
@@ -37,7 +37,12 @@ def initialize(config = {})
@config = config
@driver = NetSuitePortType.new(@config[:endpoint_url] || NetSuitePortType::DefaultEndpointUrl)
- @driver.headerhandler.add(PassportHeaderHandler.new(:email => @config[:email], :password => @config[:password], :account => @config[:account_id]))
+
+ if @config[:role]
+ role = {:internalID => config[:role]}
+ end
+
+ @driver.headerhandler.add(PassportHeaderHandler.new(:email => @config[:email], :password => @config[:password], :account => @config[:account_id], :role => role))
@driver.headerhandler.add(PreferencesHeaderHandler.new)
@driver.headerhandler.add(SearchPreferencesHeaderHandler.new)
end
@@ -123,6 +128,13 @@ def delete(ref)
NetsuiteResult.new(res.writeResponse)
end
+ def get_select_value(klass, field)
+ fieldDescription = GetSelectValueFieldDescription.new
+ fieldDescription.recordType = constantize(klass)
+ fieldDescription.field = field
+ res = @driver.getSelectValue(:fieldDescription => fieldDescription, :pageIndex => 1).getSelectValueResult
+ res.status.xmlattr_isSuccess ? res.baseRefList : nil
+ end
# Get the full result set (possibly across multiple pages).
def full_basic_search(basic)
View
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
s.summary = %q{Ruby soap4r-based Netsuite client.}
s.test_files = ["test/netsuite_client_test.rb", "test/test_helper.rb"]
- s.add_dependency 'soap4r'
+ s.add_dependency 'soap4r-ruby1.9'
end
@@ -11,8 +11,8 @@ def setup
exit(-1)
end
- @client = NetsuiteClient.new(:account_id => ENV['NS_ACCOUNT_ID'], :email => ENV['NS_EMAIL'], :password => ENV['NS_PASSWORD'], :endpoint_url => ENV['NS_ENDPOINT_URL'])
- #@client.debug = true
+ @client = NetsuiteClient.new(:account_id => ENV['NS_ACCOUNT_ID'], :email => ENV['NS_EMAIL'], :password => ENV['NS_PASSWORD'], :role => ENV['NS_ROLE'], :endpoint_url => ENV['NS_ENDPOINT_URL'])
+ # @client.debug = true
end
def test_init
@@ -37,6 +37,21 @@ def test_get_all
assert records.all? {|r| r.class.to_s == 'NetSuite::SOAP::Currency'}
end
+ def test_get_select_value
+ values = @client.get_select_value('RecordType::SupportCase', 'origin')
+ assert values.count > 0
+ assert values.find {|value| value.name == "Web"}
+ end
+
+ def test_add
+ support_case = SupportCase.new
+ support_case.title = 'title'
+ support_case.incomingMessage = 'description'
+ support_case.email = 'test@example.com'
+ res = @client.add(support_case)
+ assert res.success?
+ end
+
# inventory item tests are currently disabled
# FIXME: 2011_2 requires cogs and asset accounts
# def test_add_inventory_item

0 comments on commit a684ac3

Please sign in to comment.