module NetSuite::Configuration
Public Instance Methods
account(account = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 275 def account(account = nil) if account self.account = account else attributes[:account] end end
account=(account)
click to toggle source
# File lib/netsuite/configuration.rb, line 271 def account=(account) attributes[:account] = account end
api_version(version = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 81 def api_version(version = nil) if version self.api_version = version else attributes[:api_version] ||= '2015_1' end end
api_version=(version)
click to toggle source
# File lib/netsuite/configuration.rb, line 89 def api_version=(version) if attributes[:api_version] != version attributes[:wsdl] = nil attributes[:wsdl_domain] = nil end attributes[:api_version] = version end
attributes()
click to toggle source
# File lib/netsuite/configuration.rb, line 13 def attributes @attributes ||= {} end
auth_header(credentials={})
click to toggle source
# File lib/netsuite/configuration.rb, line 183 def auth_header(credentials={}) if !credentials[:consumer_key].blank? || !consumer_key.blank? token_auth(credentials) else user_auth(credentials) end end
cache_wsdl(client)
click to toggle source
# File lib/netsuite/configuration.rb, line 69 def cache_wsdl(client) # NOTE the Savon::Client doesn't pull the wsdl content upon # instantiation; it pulls it when it recieves the #call method. # If we force it to pull the wsdl here, it will duplicate the call later. # So, we stash the entire client and fetch just the wsdl from it after # it completes its call # For reference, see: # https://github.com/savonrb/savon/blob/d64925d3add33fa5531577ce9e3a28a7a93618b1/lib/savon/client.rb#L35-L37 # https://github.com/savonrb/savon/blob/d64925d3add33fa5531577ce9e3a28a7a93618b1/lib/savon/operation.rb#L22 wsdl_cache[wsdl] ||= client end
cached_wsdl()
click to toggle source
# File lib/netsuite/configuration.rb, line 60 def cached_wsdl cached = wsdl_cache.fetch(wsdl, nil) if cached.is_a? String cached elsif cached.is_a? Savon::Client wsdl_cache[wsdl] = cached.instance_eval { @wsdl.xml } end end
clear_wsdl_cache()
click to toggle source
# File lib/netsuite/configuration.rb, line 56 def clear_wsdl_cache @wsdl_cache = {} end
connection(params={}, credentials={})
click to toggle source
# File lib/netsuite/configuration.rb, line 17 def connection(params={}, credentials={}) client = Savon.client({ wsdl: cached_wsdl || wsdl, endpoint: endpoint, read_timeout: read_timeout, open_timeout: open_timeout, namespaces: namespaces, soap_header: auth_header(credentials).update(soap_header), pretty_print_xml: true, filters: filters, logger: logger, log_level: log_level, log: !silent, # turn off logging entirely if configured }.update(params)) cache_wsdl(client) return client end
consumer_key(consumer_key = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 287 def consumer_key(consumer_key = nil) if consumer_key self.consumer_key = consumer_key else attributes[:consumer_key] end end
consumer_key=(consumer_key)
click to toggle source
# File lib/netsuite/configuration.rb, line 283 def consumer_key=(consumer_key) attributes[:consumer_key] = consumer_key end
consumer_secret(consumer_secret = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 299 def consumer_secret(consumer_secret = nil) if consumer_secret self.consumer_secret = consumer_secret else attributes[:consumer_secret] end end
consumer_secret=(consumer_secret)
click to toggle source
# File lib/netsuite/configuration.rb, line 295 def consumer_secret=(consumer_secret) attributes[:consumer_secret] = consumer_secret end
email(email = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 251 def email(email = nil) if email self.email = email else attributes[:email] end end
email=(email)
click to toggle source
# File lib/netsuite/configuration.rb, line 247 def email=(email) attributes[:email] = email end
endpoint(endpoint=nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 102 def endpoint(endpoint=nil) if endpoint self.endpoint = endpoint else attributes[:endpoint] end end
endpoint=(endpoint)
click to toggle source
# File lib/netsuite/configuration.rb, line 98 def endpoint=(endpoint) attributes[:endpoint] = endpoint end
filters(list = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 35 def filters(list = nil) if list self.filters = list else attributes[:filters] ||= [ :password, :email, :consumerKey, :token ] end end
filters=(list)
click to toggle source
# File lib/netsuite/configuration.rb, line 48 def filters=(list) attributes[:filters] = list end
log(path = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 359 def log(path = nil) self.log = path if path attributes[:log] end
log=(path)
click to toggle source
# File lib/netsuite/configuration.rb, line 355 def log=(path) attributes[:log] = path end
log_level(value = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 388 def log_level(value = nil) self.log_level = value if value attributes[:log_level] || :debug end
log_level=(value)
click to toggle source
# File lib/netsuite/configuration.rb, line 394 def log_level=(value) attributes[:log_level] = value end
logger(value = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 364 def logger(value = nil) if value.nil? # if passed a IO object (like StringIO) `empty?` won't exist valid_log = log && !(log.respond_to?(:empty?) && log.empty?) attributes[:logger] ||= ::Logger.new(valid_log ? log : $stdout) else attributes[:logger] = value end end
logger=(value)
click to toggle source
# File lib/netsuite/configuration.rb, line 375 def logger=(value) attributes[:logger] = value end
namespaces()
click to toggle source
# File lib/netsuite/configuration.rb, line 210 def namespaces { 'xmlns:platformMsgs' => "urn:messages_#{api_version}.platform.webservices.netsuite.com", 'xmlns:platformCore' => "urn:core_#{api_version}.platform.webservices.netsuite.com", 'xmlns:platformCommon' => "urn:common_#{api_version}.platform.webservices.netsuite.com", 'xmlns:listRel' => "urn:relationships_#{api_version}.lists.webservices.netsuite.com", 'xmlns:tranSales' => "urn:sales_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:tranPurch' => "urn:purchases_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:actSched' => "urn:scheduling_#{api_version}.activities.webservices.netsuite.com", 'xmlns:setupCustom' => "urn:customization_#{api_version}.setup.webservices.netsuite.com", 'xmlns:listAcct' => "urn:accounting_#{api_version}.lists.webservices.netsuite.com", 'xmlns:tranBank' => "urn:bank_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:tranCust' => "urn:customers_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:tranEmp' => "urn:employees_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:tranInvt' => "urn:inventory_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:listSupport' => "urn:support_#{api_version}.lists.webservices.netsuite.com", 'xmlns:tranGeneral' => "urn:general_#{api_version}.transactions.webservices.netsuite.com", 'xmlns:commGeneral' => "urn:communication_#{api_version}.general.webservices.netsuite.com", 'xmlns:listMkt' => "urn:marketing_#{api_version}.lists.webservices.netsuite.com", 'xmlns:listWebsite' => "urn:website_#{api_version}.lists.webservices.netsuite.com", 'xmlns:fileCabinet' => "urn:filecabinet_#{api_version}.documents.webservices.netsuite.com", 'xmlns:listEmp' => "urn:employees_#{api_version}.lists.webservices.netsuite.com" } end
open_timeout(timeout = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 347 def open_timeout(timeout = nil) if timeout self.open_timeout = timeout else attributes[:open_timeout] end end
open_timeout=(timeout)
click to toggle source
# File lib/netsuite/configuration.rb, line 343 def open_timeout=(timeout) attributes[:open_timeout] = timeout end
password(password = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 263 def password(password = nil) if password self.password = password else attributes[:password] end end
password=(password)
click to toggle source
# File lib/netsuite/configuration.rb, line 259 def password=(password) attributes[:password] = password end
read_timeout(timeout = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 335 def read_timeout(timeout = nil) if timeout self.read_timeout = timeout else attributes[:read_timeout] ||= 60 end end
read_timeout=(timeout)
click to toggle source
# File lib/netsuite/configuration.rb, line 331 def read_timeout=(timeout) attributes[:read_timeout] = timeout end
reset!()
click to toggle source
# File lib/netsuite/configuration.rb, line 5 def reset! NetSuite::Utilities.clear_cache! clear_wsdl_cache attributes.clear end
role(role = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 239 def role(role = nil) if role self.role = role else attributes[:role] ||= '3' end end
role=(role)
click to toggle source
# File lib/netsuite/configuration.rb, line 235 def role=(role) attributes[:role] = role end
sandbox(flag = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 119 def sandbox(flag = nil) if flag.nil? attributes[:sandbox] ||= false else self.sandbox = flag end end
sandbox=(flag)
click to toggle source
# File lib/netsuite/configuration.rb, line 110 def sandbox=(flag) if attributes[:sandbox] != flag attributes[:wsdl] = nil attributes[:wsdl_domain] = nil end attributes[:sandbox] = flag end
sandbox?()
click to toggle source
# File lib/netsuite/configuration.rb, line 127 def sandbox? !!sandbox end
silent(value=nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 379 def silent(value=nil) self.silent = value if !value.nil? attributes[:silent] end
silent=(value)
click to toggle source
# File lib/netsuite/configuration.rb, line 384 def silent=(value) attributes[:silent] ||= value end
soap_header(headers = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 175 def soap_header(headers = nil) if headers self.soap_header = headers else attributes[:soap_header] ||= {} end end
soap_header=(headers)
click to toggle source
# File lib/netsuite/configuration.rb, line 171 def soap_header=(headers) attributes[:soap_header] = headers end
token_auth(credentials)
click to toggle source
# File lib/netsuite/configuration.rb, line 200 def token_auth(credentials) NetSuite::Passports::Token.new( credentials[:account] || account, credentials[:consumer_key] || consumer_key, credentials[:consumer_secret] || consumer_secret, credentials[:token_id] || token_id, credentials[:token_secret] || token_secret ).passport end
token_id(token_id = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 311 def token_id(token_id = nil) if token_id self.token_id = token_id else attributes[:token_id] end end
token_id=(token_id)
click to toggle source
# File lib/netsuite/configuration.rb, line 307 def token_id=(token_id) attributes[:token_id] = token_id end
token_secret(token_secret = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 323 def token_secret(token_secret = nil) if token_secret self.token_secret = token_secret else attributes[:token_secret] end end
token_secret=(token_secret)
click to toggle source
# File lib/netsuite/configuration.rb, line 319 def token_secret=(token_secret) attributes[:token_secret] = token_secret end
user_auth(credentials)
click to toggle source
# File lib/netsuite/configuration.rb, line 191 def user_auth(credentials) NetSuite::Passports::User.new( credentials[:account] || account, credentials[:email] || email, credentials[:password] || password, credentials[:role] || role ).passport end
wsdl(wsdl = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 135 def wsdl(wsdl = nil) if wsdl self.wsdl = wsdl else attributes[:wsdl] ||= begin if sandbox "https://webservices.sandbox.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl" else "https://#{wsdl_domain}/wsdl/v#{api_version}_0/netsuite.wsdl" end end end end
wsdl=(wsdl)
click to toggle source
# File lib/netsuite/configuration.rb, line 131 def wsdl=(wsdl) attributes[:wsdl] = wsdl end
wsdl_cache()
click to toggle source
# File lib/netsuite/configuration.rb, line 52 def wsdl_cache @wsdl_cache ||= {} end
wsdl_domain(wsdl_domain = nil)
click to toggle source
# File lib/netsuite/configuration.rb, line 149 def wsdl_domain(wsdl_domain = nil) if wsdl_domain self.wsdl_domain = wsdl_domain else # if sandbox, this parameter is ignored if sandbox 'webservices.sandbox.netsuite.com' else attributes[:wsdl_domain] ||= 'webservices.netsuite.com' end end end
wsdl_domain=(wsdl_domain)
click to toggle source
# File lib/netsuite/configuration.rb, line 162 def wsdl_domain=(wsdl_domain) if attributes[:wsdl_domain] != wsdl_domain # reset full wsdl url to ensure it's regenerated with the updated `wsdl_domain` next time it's needed attributes[:wsdl] = nil end attributes[:wsdl_domain] = wsdl_domain end