netsuite 0.9.0 → 0.9.2

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: 5aad2f60c62b40aaa3e86460dc81283d470a3293d1568fe41d78e431b3d6ec61
4
+ data.tar.gz: 411b9bbfaa28f9c76ad886245afe83334758d5b3b360d70e405bd1897a0c1a53
5
5
  SHA512:
6
- metadata.gz: 0df38ba22afe3361daace766b033e947f20962ab0ac6d0f336e706b2bbd06bfae091478c856ce9b33ff18f28f07a3e796a774d1a78a1fc6766348538b89afb0a
7
- data.tar.gz: c3021d78e3718dd30332accc69de70e3f88df394e33648a49eb995d4d9a5177ad669c5fdb269485a75cd29c13a186c5b863e84a83dfee8eb88ea7c7ba4c9765e
6
+ metadata.gz: 72ace4cda9656efd8592ed824ccb788c136aac912c5d9ec2fac38b817f00658979a29dae19c7a298108be49c9d1c386598a7476e05a61a25a05d18a53232c930
7
+ data.tar.gz: 3fb702a8c3cca1c6896603769027022136b38af973820ae7f098d68f8ec0e4f07f45175d4b4cfd5fb8b189079f7a5ba5255becf166d0640bee5d067430ac3fe4
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
@@ -240,6 +240,7 @@ module NetSuite
240
240
  'UA' => '_ukraine',
241
241
  'AE' => '_unitedArabEmirates',
242
242
  'GB' => '_unitedKingdom',
243
+ 'UK' => '_unitedKingdom',
243
244
  'US' => '_unitedStates',
244
245
  'UY' => '_uruguay',
245
246
  'UM' => '_uSMinorOutlyingIslands',
@@ -280,12 +281,7 @@ module NetSuite
280
281
  end
281
282
 
282
283
  def iso_to_netsuite
283
- # NOTE GB country code changed on 2016_1
284
- if NetSuite::Configuration.api_version <= "2015_2"
285
- ISO_TO_NETSUITE.merge({ 'GB' => '_unitedKingdomGB' })
286
- else
287
- ISO_TO_NETSUITE
288
- end
284
+ ISO_TO_NETSUITE
289
285
  end
290
286
 
291
287
  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.2'
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,8 +20,8 @@ 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
- gem.add_development_dependency 'rspec', '~> 3.11.0'
25
+ gem.add_development_dependency 'rspec', '~> 3.12.0'
26
26
  gem.add_development_dependency 'rake', '~> 12.3.3'
27
27
  end
@@ -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
@@ -134,16 +134,6 @@ describe NetSuite::Records::Address do
134
134
  expect(addressbook.country.to_record).to eql ""
135
135
  expect(addressbook.to_record["platformCommon:country"]).to eql ""
136
136
  end
137
-
138
- it 'changes the netsuite identifier based on the current API version' do
139
- NetSuite::Configuration.api_version = '2015_1'
140
- addressbook = NetSuite::Records::Address.new country: "GB"
141
- expect(addressbook.to_record["platformCommon:country"]).to eql "_unitedKingdomGB"
142
- NetSuite::Configuration.api_version = '2018_1'
143
-
144
- addressbook = NetSuite::Records::Address.new country: "GB"
145
- expect(addressbook.to_record["platformCommon:country"]).to eql "_unitedKingdom"
146
- end
147
137
  end
148
138
 
149
139
  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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moran
8
8
  - Michael Bianco
9
- autorequire:
9
+ - Chris Gunther
10
+ autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2022-07-11 00:00:00.000000000 Z
13
+ date: 2022-12-23 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,20 +29,23 @@ 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
31
38
  requirements:
32
39
  - - "~>"
33
40
  - !ruby/object:Gem::Version
34
- version: 3.11.0
41
+ version: 3.12.0
35
42
  type: :development
36
43
  prerelease: false
37
44
  version_requirements: !ruby/object:Gem::Requirement
38
45
  requirements:
39
46
  - - "~>"
40
47
  - !ruby/object:Gem::Version
41
- version: 3.11.0
48
+ version: 3.12.0
42
49
  - !ruby/object:Gem::Dependency
43
50
  name: rake
44
51
  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: []
@@ -616,7 +624,7 @@ metadata:
616
624
  changelog_uri: https://github.com/netsweet/netsuite/blob/master/HISTORY.md
617
625
  mailing_list_uri: http://opensuite-slackin.herokuapp.com
618
626
  rubygems_mfa_required: 'true'
619
- post_install_message:
627
+ post_install_message:
620
628
  rdoc_options: []
621
629
  require_paths:
622
630
  - lib
@@ -631,8 +639,8 @@ 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
635
- signing_key:
642
+ rubygems_version: 3.1.6
643
+ signing_key:
636
644
  specification_version: 4
637
645
  summary: NetSuite SuiteTalk API (SOAP) Wrapper
638
646
  test_files: