Module: NetSuite::Configuration

Extended by:
Configuration
Included in:
Configuration
Defined in:
lib/netsuite/configuration.rb

Instance Method Summary collapse

Instance Method Details

#account(account = nil) ⇒ Object



139
140
141
142
143
144
145
146
147
# File 'lib/netsuite/configuration.rb', line 139

def ( = nil)
  if 
    self. = 
  else
    attributes[:account] ||
    raise(ConfigurationError,
      '#account is a required configuration value. Please set it by calling NetSuite::Configuration.account = 1234')
  end
end

#account=(account) ⇒ Object



135
136
137
# File 'lib/netsuite/configuration.rb', line 135

def account=()
  attributes[:account] = 
end

#api_version(version = nil) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/netsuite/configuration.rb', line 25

def api_version(version = nil)
  if version
    self.api_version = version
  else
    attributes[:api_version] ||= '2011_2'
  end
end

#api_version=(version) ⇒ Object



33
34
35
# File 'lib/netsuite/configuration.rb', line 33

def api_version=(version)
  attributes[:api_version] = version
end

#attributesObject



9
10
11
# File 'lib/netsuite/configuration.rb', line 9

def attributes
  @attributes ||= {}
end

#auth_headerObject



68
69
70
71
72
73
74
75
76
77
# File 'lib/netsuite/configuration.rb', line 68

def auth_header
  attributes[:auth_header] ||= {
    'platformMsgs:passport' => {
      'platformCore:email'    => email,
      'platformCore:password' => password,
      'platformCore:account'  => .to_s,
      'platformCore:role'     => { :'@type' => 'role', :@internalId => role }
    }
  }
end

#connection(params = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/netsuite/configuration.rb', line 13

def connection(params = {})
  Savon.client({
    wsdl: wsdl,
    read_timeout: read_timeout,
    namespaces: namespaces,
    soap_header: auth_header,
    pretty_print_xml: true,
    logger: logger,
    log_level: log_level,
  }.merge(params))
end

#email(email = nil) ⇒ Object



111
112
113
114
115
116
117
118
119
# File 'lib/netsuite/configuration.rb', line 111

def email(email = nil)
  if email
    self.email = email
  else
    attributes[:email] ||
    raise(ConfigurationError,
      '#email is a required configuration value. Please set it by calling NetSuite::Configuration.email = "[email protected]"')
  end
end

#email=(email) ⇒ Object



107
108
109
# File 'lib/netsuite/configuration.rb', line 107

def email=(email)
  attributes[:email] = email
end

#log(path = nil) ⇒ Object



165
166
167
168
# File 'lib/netsuite/configuration.rb', line 165

def log(path = nil)
  self.log = path if path
  attributes[:log]
end

#log=(path) ⇒ Object



161
162
163
# File 'lib/netsuite/configuration.rb', line 161

def log=(path)
  attributes[:log] = path
end

#log_level(value = nil) ⇒ Object



178
179
180
181
# File 'lib/netsuite/configuration.rb', line 178

def log_level(value = nil)
  self.log_level = value || :debug
  attributes[:log_level]
end

#log_level=(value) ⇒ Object



183
184
185
# File 'lib/netsuite/configuration.rb', line 183

def log_level=(value)
  attributes[:log_level] ||= value
end

#logger(value = nil) ⇒ Object



170
171
172
173
174
175
176
# File 'lib/netsuite/configuration.rb', line 170

def logger(value = nil)
  attributes[:logger] = if value.nil?
    ::Logger.new((log && !log.empty?) ? log : $stdout)
  else
    value
  end
end

#namespacesObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/netsuite/configuration.rb', line 79

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: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:tranCust'       => "urn:customers_#{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",
  }
end

#password(password = nil) ⇒ Object



125
126
127
128
129
130
131
132
133
# File 'lib/netsuite/configuration.rb', line 125

def password(password = nil)
  if password
    self.password = password
  else
    attributes[:password] ||
    raise(ConfigurationError,
      '#password is a required configuration value. Please set it by calling NetSuite::Configuration.password = "my_pass"')
  end
end

#password=(password) ⇒ Object



121
122
123
# File 'lib/netsuite/configuration.rb', line 121

def password=(password)
  attributes[:password] = password
end

#read_timeout(timeout = nil) ⇒ Object



153
154
155
156
157
158
159
# File 'lib/netsuite/configuration.rb', line 153

def read_timeout(timeout = nil)
  if timeout
    self.read_timeout = timeout
  else
    attributes[:read_timeout] ||= 60
  end
end

#read_timeout=(timeout) ⇒ Object



149
150
151
# File 'lib/netsuite/configuration.rb', line 149

def read_timeout=(timeout)
  attributes[:read_timeout] = timeout
end

#reset!Object



5
6
7
# File 'lib/netsuite/configuration.rb', line 5

def reset!
  attributes.clear
end

#role(role = nil) ⇒ Object



99
100
101
102
103
104
105
# File 'lib/netsuite/configuration.rb', line 99

def role(role = nil)
  if role
    self.role = role
  else
    attributes[:role] ||= '3'
  end
end

#role=(role) ⇒ Object



95
96
97
# File 'lib/netsuite/configuration.rb', line 95

def role=(role)
  attributes[:role] = role
end

#sandbox(flag = nil) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/netsuite/configuration.rb', line 41

def sandbox(flag = nil)
  if flag.nil?
    attributes[:flag] ||= false
  else
    self.sandbox = flag
  end
end

#sandbox=(flag) ⇒ Object



37
38
39
# File 'lib/netsuite/configuration.rb', line 37

def sandbox=(flag)
  attributes[:flag] = flag
end

#wsdl(wsdl = nil) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/netsuite/configuration.rb', line 53

def wsdl(wsdl = nil)
  if wsdl
    self.wsdl = wsdl
  else
    if sandbox
      wsdl_path = "https://webservices.sandbox.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl"
    else
      wsdl_path = File.expand_path("../../../wsdl/#{api_version}.wsdl", __FILE__)
      wsdl_path = "https://webservices.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl" unless File.exists? wsdl_path
    end

    attributes[:wsdl] ||= wsdl_path
  end
end

#wsdl=(wsdl) ⇒ Object



49
50
51
# File 'lib/netsuite/configuration.rb', line 49

def wsdl=(wsdl)
  attributes[:wsdl] = wsdl
end