However, NaHi's http-access2 library already provides cookie management (even persistence if needed). After installing visnu's gem it's simply a matter of turning off the SSLConfig#verify_mode and everything works flawlessly. The final test code:
require 'rubygems'Everything said and done, this has been a good learning experience. But more than anything it has exposed one of the Ruby community's greatest weaknesses: documentation. I've known this since the beginning of my Ruby days (2004) and have grown accustomed to reading code. Nevertheless, that takes time, and usually more time than scanning decently-documented APIs. The other side of this story is that I understand the Japanese/English language barrier which may intimidate or otherwise prevent library maintainers from providing more documentation. In the end, Ruby is a community-driven language, which is not sponsored by massive corporate dollars (cough, Java, cough, .Net) and its beginnings have solid Japanese roots. Here's to hoping that documentation improves as more libraries become available and the language matures. In the mean time, thank goodness for Google, mailing lists, blogs and IRC. I believe that documentation practices exhibited by 37Signals and the Rails community are the guiding example, they're not perfect, but the situation continues to progress.
require_gem 'soap4r'
require 'defaultDriver' #generated by soap4r
require 'pp'
driver = NetSuitePortType.new
driver.wiredump_dev = STDOUT
driver.proxy.streamhandler.client.ssl_config.verify_mode = nil
passport = Passport.new
passport.email = '123123123@123123123.com'
passport.password = '123123123'
passport.account ="123123"
passport.role = RecordRef.new
passport.role.xmlattr_internalId = '123123123'
driver.login(LoginRequest.new(passport))
record = RecordRef.new()
record.xmlattr_internalId = '123123123'
record.xmlattr_type = RecordType::Customer
pp driver.get(GetRequest.new(record))
3 comments:
Thanks for the posts on Netsuite and Ruby -- we are investigating Netsuite right now (with php, meh) but seeing that Ruby works OK with it brings a smile to my face.
Glad to hear it, Jim! Our CRM application is almost complete and we've had our fair share of pain when dealing with NetSuite's API. I may write up a rant after we release to describe our pain points--mostly due to their erroneous documentation, missing features and typically-lengthy response time to API bugs.
Thanks for the post. I would love to hear those pain points, we're currently investigating their service for inventory and financials. Ever few lines of NetSuite documentation i read a voice in my head asks 'where is the rest api, seriously'!
Post a Comment