netsuite 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53e37d7468526bab26109064a50e3d393735e7fbb0758b56867de985e3230170
4
- data.tar.gz: 318ed153297d54f2d19c821677e5d8bfffe89d7f688ea31aa324f93e1293f411
3
+ metadata.gz: 3429c5cb6575fd1e62738eaf1270a0c585d82bc302975e435491af2a8a5dd7b5
4
+ data.tar.gz: 41a481e39865f46c5a0b8d61c3ab44e4c547ccfb8cc2de4c9621634ec331eb2e
5
5
  SHA512:
6
- metadata.gz: 0df38ba22afe3361daace766b033e947f20962ab0ac6d0f336e706b2bbd06bfae091478c856ce9b33ff18f28f07a3e796a774d1a78a1fc6766348538b89afb0a
7
- data.tar.gz: c3021d78e3718dd30332accc69de70e3f88df394e33648a49eb995d4d9a5177ad669c5fdb269485a75cd29c13a186c5b863e84a83dfee8eb88ea7c7ba4c9765e
6
+ metadata.gz: df1a9202d4ccdfaff26031b7f1ae957403d374e90115f063ac107e0f59fc890a4b254bc559e06eb87a2768575827bde20917bf00ae4986e52ad48acf0043c45f
7
+ data.tar.gz: 07de35d4a530d8decc1344a0ed6cdf1d198260bd3ae84dae45b00e2324837172062fc071c0f3a05bf685423e8a0b4da910e865e7cc00f878098ec125c7dcc5c7
data/Gemfile CHANGED
@@ -11,3 +11,10 @@ if ENV.fetch('BUNDLE_TZINFO', 'false') == 'true'
11
11
  # optional dependency for more accurate timezone conversion
12
12
  gem 'tzinfo', '>= 1.2.5'
13
13
  end
14
+
15
+ if RUBY_VERSION >= '3.1.0'
16
+ # Savon v2.13 adds a dependency on mail, which has an implicit dependency on
17
+ # net-smtp. Ruby 3.1 removed net-smtp as a default gem. mail v2.8.0.rc1 is the
18
+ # first to make that dependency explicit to support Ruby 3.1.
19
+ gem 'mail', '>= 2.8.0.rc1'
20
+ end
data/HISTORY.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
 
4
4
  ### Added
5
+ * Add `Configuration#multi_tenant!` for opting into multi-tentant support where configuration/caching is per-thread (#556)
6
+
5
7
  ### Fixed
8
+ * Avoid Savon version `2.13.0` to prevent generating invalid envelopes. (#558, #563)
9
+
6
10
  ### Breaking Changes
7
11
 
8
12
  ## 0.9.0
data/README.md CHANGED
@@ -159,6 +159,32 @@ NetSuite.configure do
159
159
  end
160
160
  ```
161
161
 
162
+ ### Multi-Tenancy
163
+
164
+ If you're interacting with multiple NetSuite accounts, each in separate threads, you can enable multi-tenancy to prevent your configuration and caches from being shared between threads.
165
+
166
+ From your main thread, you'd want to enable multi-tenancy:
167
+
168
+ ```ruby
169
+ NetSuite.configure do
170
+ multi_tentant!
171
+ end
172
+ ```
173
+
174
+ Note that `multi_tenant!` is a special configuration option which is _not_ effected by `reset!`.
175
+
176
+ Then in each child thread, you'd perform any configuration specific to the NetSuite account you're interacting with for that thread, all of which will be specific to that thread only:
177
+
178
+ ```ruby
179
+ NetSuite.configure do
180
+ reset!
181
+
182
+ account ENV['NETSUITE_ACCOUNT']
183
+
184
+ # The rest of your usual configuration...
185
+ end
186
+ ```
187
+
162
188
  # Usage
163
189
 
164
190
  ## CRUD Operations
@@ -11,7 +11,11 @@ module NetSuite
11
11
  end
12
12
 
13
13
  def attributes
14
- Thread.current[:netsuite_gem_attributes] ||= {}
14
+ if multi_tenant?
15
+ Thread.current[:netsuite_gem_attributes] ||= {}
16
+ else
17
+ @attributes ||= {}
18
+ end
15
19
  end
16
20
 
17
21
  def connection(params={}, credentials={})
@@ -51,11 +55,19 @@ module NetSuite
51
55
  end
52
56
 
53
57
  def wsdl_cache
54
- Thread.current[:netsuite_gem_wsdl_cache] ||= {}
58
+ if multi_tenant?
59
+ Thread.current[:netsuite_gem_wsdl_cache] ||= {}
60
+ else
61
+ @wsdl_cache ||= {}
62
+ end
55
63
  end
56
64
 
57
65
  def clear_wsdl_cache
58
- Thread.current[:netsuite_gem_wsdl_cache] = {}
66
+ if multi_tenant?
67
+ Thread.current[:netsuite_gem_wsdl_cache] = {}
68
+ else
69
+ @wsdl_cache = {}
70
+ end
59
71
  end
60
72
 
61
73
  def cached_wsdl
@@ -83,7 +95,7 @@ module NetSuite
83
95
  if version
84
96
  self.api_version = version
85
97
  else
86
- attributes[:api_version] ||= '2015_1'
98
+ attributes[:api_version] ||= '2016_2'
87
99
  end
88
100
  end
89
101
 
@@ -407,5 +419,13 @@ module NetSuite
407
419
  attributes[:proxy]
408
420
  end
409
421
  end
422
+
423
+ def multi_tenant!
424
+ @multi_tenant = true
425
+ end
426
+
427
+ def multi_tenant?
428
+ @multi_tenant
429
+ end
410
430
  end
411
431
  end
@@ -7,18 +7,31 @@ module NetSuite
7
7
  # TODO need structured logger for various statements
8
8
 
9
9
  def clear_cache!
10
- Thread.current[:netsuite_gem_netsuite_get_record_cache] = {}
11
- Thread.current[:netsuite_gem_netsuite_find_record_cache] = {}
10
+ if NetSuite::Configuration.multi_tenant?
11
+ Thread.current[:netsuite_gem_netsuite_get_record_cache] = {}
12
+ Thread.current[:netsuite_gem_netsuite_find_record_cache] = {}
13
+ else
14
+ @netsuite_get_record_cache = {}
15
+ @netsuite_find_record_cache = {}
16
+ end
12
17
 
13
18
  DataCenter.clear_cache!
14
19
  end
15
20
 
16
21
  def netsuite_get_record_cache
17
- Thread.current[:netsuite_gem_netsuite_get_record_cache] ||= {}
22
+ if NetSuite::Configuration.multi_tenant?
23
+ Thread.current[:netsuite_gem_netsuite_get_record_cache] ||= {}
24
+ else
25
+ @netsuite_get_record_cache ||= {}
26
+ end
18
27
  end
19
28
 
20
29
  def netsuite_find_record_cache
21
- Thread.current[:netsuite_gem_netsuite_find_record_cache] ||= {}
30
+ if NetSuite::Configuration.multi_tenant?
31
+ Thread.current[:netsuite_gem_netsuite_find_record_cache] ||= {}
32
+ else
33
+ @netsuite_find_record_cache ||= {}
34
+ end
22
35
  end
23
36
 
24
37
  def append_memo(ns_record, added_memo, opts = {})
@@ -112,6 +125,8 @@ module NetSuite
112
125
  exceptions_to_retry << OpenSSL::SSL::SSLErrorWaitReadable if defined?(OpenSSL::SSL::SSLErrorWaitReadable)
113
126
 
114
127
  # depends on the http library chosen
128
+ exceptions_to_retry << HTTPI::SSLError if defined?(HTTPI::SSLError)
129
+ exceptions_to_retry << HTTPI::TimeoutError if defined?(HTTPI::TimeoutError)
115
130
  exceptions_to_retry << HTTPClient::TimeoutError if defined?(HTTPClient::TimeoutError)
116
131
  exceptions_to_retry << HTTPClient::ConnectTimeoutError if defined?(HTTPClient::ConnectTimeoutError)
117
132
  exceptions_to_retry << HTTPClient::ReceiveTimeoutError if defined?(HTTPClient::ReceiveTimeoutError)
@@ -1,3 +1,3 @@
1
1
  module NetSuite
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
data/netsuite.gemspec CHANGED
@@ -3,8 +3,8 @@ require File.expand_path('../lib/netsuite/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.licenses = ['MIT']
6
- gem.authors = ['Ryan Moran', 'Michael Bianco']
7
- gem.email = ['ryan.moran@gmail.com', 'mike@mikebian.co']
6
+ gem.authors = ['Ryan Moran', 'Michael Bianco', 'Chris Gunther']
7
+ gem.email = ['ryan.moran@gmail.com', 'mike@mikebian.co', 'chris@room118solutions.com']
8
8
  gem.description = %q{NetSuite SuiteTalk API Wrapper}
9
9
  gem.summary = %q{NetSuite SuiteTalk API (SOAP) Wrapper}
10
10
  gem.homepage = 'https://github.com/NetSweet/netsuite'
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
20
20
  gem.metadata['mailing_list_uri'] = 'http://opensuite-slackin.herokuapp.com'
21
21
  gem.metadata['rubygems_mfa_required'] = 'true'
22
22
 
23
- gem.add_dependency 'savon', '>= 2.3.0'
23
+ gem.add_dependency 'savon', '>= 2.3.0', '!= 2.13.0'
24
24
 
25
25
  gem.add_development_dependency 'rspec', '~> 3.11.0'
26
26
  gem.add_development_dependency 'rake', '~> 12.3.3'
@@ -15,18 +15,42 @@ describe NetSuite::Configuration do
15
15
  expect(config.attributes).to be_empty
16
16
  end
17
17
 
18
- it 'ensures that attributes are not shared between threads' do
18
+ it 'treats attributes as shared/global in default single tenant mode' do
19
19
  config.attributes[:blah] = 'something'
20
20
  expect(config.attributes[:blah]).to eq('something')
21
21
 
22
22
  thread = Thread.new {
23
+ expect(config.attributes[:blah]).to eq('something')
24
+
23
25
  config.attributes[:blah] = 'something_else'
24
26
  expect(config.attributes[:blah]).to eq('something_else')
25
27
  }
26
28
 
27
29
  thread.join
28
30
 
29
- expect(config.attributes[:blah]).to eq('something')
31
+ expect(config.attributes[:blah]).to eq('something_else')
32
+ end
33
+
34
+ it 'treats attributes as thread-local in multi-tenant mode, which each thread starting with empty attributes' do
35
+ begin
36
+ config.multi_tenant!
37
+
38
+ config.attributes[:blah] = 'something'
39
+ expect(config.attributes[:blah]).to eq('something')
40
+
41
+ thread = Thread.new {
42
+ expect(config.attributes[:blah]).to be_nil
43
+
44
+ config.attributes[:blah] = 'something_else'
45
+ expect(config.attributes[:blah]).to eq('something_else')
46
+ }
47
+
48
+ thread.join
49
+
50
+ expect(config.attributes[:blah]).to eq('something')
51
+ ensure
52
+ config.instance_variable_set(:@multi_tenant, false)
53
+ end
30
54
  end
31
55
  end
32
56
 
@@ -101,7 +125,7 @@ describe NetSuite::Configuration do
101
125
 
102
126
  context 'when the wsdl has not been set' do
103
127
  it 'returns a path to the WSDL to use for the API' do
104
- expect(config.wsdl).to eq("https://webservices.netsuite.com/wsdl/v2015_1_0/netsuite.wsdl")
128
+ expect(config.wsdl).to eq("https://webservices.netsuite.com/wsdl/v2016_2_0/netsuite.wsdl")
105
129
  end
106
130
  end
107
131
 
@@ -351,8 +375,8 @@ describe NetSuite::Configuration do
351
375
 
352
376
  describe '#api_version' do
353
377
  context 'when no api_version is defined' do
354
- it 'defaults to 2015_1' do
355
- expect(config.api_version).to eq('2015_1')
378
+ it 'defaults to 2016_2' do
379
+ expect(config.api_version).to eq('2016_2')
356
380
  end
357
381
  end
358
382
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moran
8
8
  - Michael Bianco
9
+ - Chris Gunther
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2022-07-11 00:00:00.000000000 Z
13
+ date: 2022-10-20 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: savon
@@ -18,6 +19,9 @@ dependencies:
18
19
  - - ">="
19
20
  - !ruby/object:Gem::Version
20
21
  version: 2.3.0
22
+ - - "!="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.13.0
21
25
  type: :runtime
22
26
  prerelease: false
23
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -25,6 +29,9 @@ dependencies:
25
29
  - - ">="
26
30
  - !ruby/object:Gem::Version
27
31
  version: 2.3.0
32
+ - - "!="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.13.0
28
35
  - !ruby/object:Gem::Dependency
29
36
  name: rspec
30
37
  requirement: !ruby/object:Gem::Requirement
@@ -57,6 +64,7 @@ description: NetSuite SuiteTalk API Wrapper
57
64
  email:
58
65
  - ryan.moran@gmail.com
59
66
  - mike@mikebian.co
67
+ - chris@room118solutions.com
60
68
  executables: []
61
69
  extensions: []
62
70
  extra_rdoc_files: []
@@ -631,7 +639,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
631
639
  - !ruby/object:Gem::Version
632
640
  version: '0'
633
641
  requirements: []
634
- rubygems_version: 3.3.11
642
+ rubygems_version: 3.1.6
635
643
  signing_key:
636
644
  specification_version: 4
637
645
  summary: NetSuite SuiteTalk API (SOAP) Wrapper