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



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

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



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

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

#api_version(version = nil) ⇒ Object



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

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

#api_version=(version) ⇒ Object



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

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



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

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

#connection(params = {}) ⇒ Object



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

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

#email(email = nil) ⇒ Object



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

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



93
94
95
# File 'lib/netsuite/configuration.rb', line 93

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

#log(path = nil) ⇒ Object



151
152
153
154
# File 'lib/netsuite/configuration.rb', line 151

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

#log=(path) ⇒ Object



147
148
149
# File 'lib/netsuite/configuration.rb', line 147

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

#loggerObject



156
157
158
# File 'lib/netsuite/configuration.rb', line 156

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

#password(password = nil) ⇒ Object



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

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



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

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

#read_timeout(timeout = nil) ⇒ Object



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

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

#read_timeout=(timeout) ⇒ Object



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

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



85
86
87
88
89
90
91
# File 'lib/netsuite/configuration.rb', line 85

def role(role = nil)
  if role
    self.role = role
  else 
    attributes[:role] ||= NetSuite::Records::RecordRef.new(:internal_id => '3', :type => 'role')
  end
end

#role=(role) ⇒ Object



81
82
83
# File 'lib/netsuite/configuration.rb', line 81

def role=(role)
  attributes[:role] = NetSuite::Records::RecordRef.new(:internal_id => role, :type => 'role')
end

#sandbox(flag = nil) ⇒ Object



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

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

#sandbox=(flag) ⇒ Object



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

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

#wsdl(wsdl = nil) ⇒ Object



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

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



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

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