netsuite 0.8.4 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/main.yml +20 -0
  3. data/.gitignore +1 -0
  4. data/.ruby-version +1 -1
  5. data/.tool-versions +1 -0
  6. data/Gemfile +2 -5
  7. data/HISTORY.md +26 -0
  8. data/README.md +72 -29
  9. data/Rakefile +1 -1
  10. data/lib/netsuite.rb +13 -19
  11. data/lib/netsuite/actions/login.rb +10 -2
  12. data/lib/netsuite/actions/upsert.rb +2 -0
  13. data/lib/netsuite/configuration.rb +34 -4
  14. data/lib/netsuite/records/accounting_period.rb +2 -2
  15. data/lib/netsuite/records/classification.rb +4 -1
  16. data/lib/netsuite/records/contact.rb +1 -1
  17. data/lib/netsuite/records/cost_category.rb +28 -0
  18. data/lib/netsuite/records/credit_memo.rb +1 -1
  19. data/lib/netsuite/records/custom_field_list.rb +9 -3
  20. data/lib/netsuite/records/custom_record.rb +1 -1
  21. data/lib/netsuite/records/customer.rb +2 -1
  22. data/lib/netsuite/records/customer_credit_cards.rb +36 -0
  23. data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
  24. data/lib/netsuite/records/customer_deposit.rb +5 -5
  25. data/lib/netsuite/records/customer_payment.rb +6 -2
  26. data/lib/netsuite/records/customer_payment_credit.rb +17 -0
  27. data/lib/netsuite/records/customer_payment_credit_list.rb +12 -0
  28. data/lib/netsuite/records/employee.rb +1 -1
  29. data/lib/netsuite/records/estimate.rb +42 -0
  30. data/lib/netsuite/records/estimate_item.rb +40 -0
  31. data/lib/netsuite/records/estimate_item_list.rb +11 -0
  32. data/lib/netsuite/records/inventory_item.rb +62 -1
  33. data/lib/netsuite/records/invoice.rb +94 -1
  34. data/lib/netsuite/records/item_fulfillment.rb +1 -1
  35. data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
  36. data/lib/netsuite/records/matrix_option_list.rb +12 -4
  37. data/lib/netsuite/records/message.rb +30 -0
  38. data/lib/netsuite/records/non_inventory_resale_item.rb +1 -0
  39. data/lib/netsuite/records/non_inventory_sale_item.rb +1 -1
  40. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  41. data/lib/netsuite/records/partner.rb +7 -5
  42. data/lib/netsuite/records/serialized_assembly_item.rb +3 -1
  43. data/lib/netsuite/records/service_resale_item.rb +1 -1
  44. data/lib/netsuite/records/support_case_type.rb +26 -0
  45. data/lib/netsuite/records/tax_group.rb +2 -2
  46. data/lib/netsuite/records/vendor.rb +2 -1
  47. data/lib/netsuite/records/vendor_currency.rb +26 -0
  48. data/lib/netsuite/records/vendor_currency_list.rb +9 -0
  49. data/lib/netsuite/support/fields.rb +16 -0
  50. data/lib/netsuite/support/records.rb +1 -1
  51. data/lib/netsuite/support/search_result.rb +36 -6
  52. data/lib/netsuite/utilities.rb +18 -6
  53. data/lib/netsuite/version.rb +1 -1
  54. data/netsuite.gemspec +5 -3
  55. data/spec/netsuite/actions/search_spec.rb +22 -0
  56. data/spec/netsuite/configuration_spec.rb +111 -6
  57. data/spec/netsuite/records/basic_record_spec.rb +9 -1
  58. data/spec/netsuite/records/classification_spec.rb +10 -1
  59. data/spec/netsuite/records/cost_category_spec.rb +105 -0
  60. data/spec/netsuite/records/custom_field_list_spec.rb +46 -6
  61. data/spec/netsuite/records/custom_record_spec.rb +1 -1
  62. data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
  63. data/spec/netsuite/records/customer_payment_credit_list_spec.rb +26 -0
  64. data/spec/netsuite/records/customer_payment_spec.rb +1 -6
  65. data/spec/netsuite/records/customer_spec.rb +22 -1
  66. data/spec/netsuite/records/employee_spec.rb +2 -2
  67. data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
  68. data/spec/netsuite/records/estimate_item_spec.rb +40 -0
  69. data/spec/netsuite/records/estimate_spec.rb +216 -0
  70. data/spec/netsuite/records/inventory_item_spec.rb +65 -0
  71. data/spec/netsuite/records/invoice_spec.rb +94 -0
  72. data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
  73. data/spec/netsuite/records/message_spec.rb +49 -0
  74. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
  75. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
  76. data/spec/netsuite/records/partner_spec.rb +143 -0
  77. data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
  78. data/spec/netsuite/records/support_case_type_spec.rb +22 -0
  79. data/spec/netsuite/records/vendor_spec.rb +1 -1
  80. data/spec/netsuite/support/search_result_spec.rb +24 -0
  81. data/spec/netsuite/utilities_spec.rb +20 -15
  82. data/spec/support/fixtures/custom_fields/multi_select.xml +47 -0
  83. data/spec/support/fixtures/search/saved_search_item.xml +55 -0
  84. data/spec/support/fixtures/search/saved_search_joined_custom_customer.xml +15 -1
  85. data/spec/support/search_only_field_matcher.rb +7 -0
  86. metadata +77 -12
  87. data/circle.yml +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4706d84cf53e7897cc7f420a4af5c22230f764d0
4
- data.tar.gz: a0e4db30c9a0288633a73988b7bd74916a3dbc20
2
+ SHA256:
3
+ metadata.gz: acf21d9a2b7a9ee0eedee971c7ebd1af50c05c28a1a5a03dea740fc1eb22529c
4
+ data.tar.gz: 6b740ed5e9b8d76926d63ca2895d0370b11b0c0656bd2581f15b9133f7d7edec
5
5
  SHA512:
6
- metadata.gz: 2afc60b0287c25b4a9cb4d271a363da58c5089ee0eb60d10d6f2334b06ac1bd1bbd902fce592034f53f0fe0a600147184a51668b3bf7c903513d3a1c1e310069
7
- data.tar.gz: 5dadd1b9eae507ff201e01f3ab7f2d49e6e6a930d5ec1825fcc7ee2dd8087b71025a9e66700aa491b598a61606085b2c37a1f2f6f29457ade3693fe2809db925
6
+ metadata.gz: 2a7d9f98b1574b63a6da20d65376e1edb936f8d16d44019871b8d7e2e7f1354956eac101d038f756bc8a2256977c6afbd0742c7f7badbd6ec89a8165fdde77f8
7
+ data.tar.gz: 6a268c38ec15d63e50f5c713363b7cf9f8b5faf67b1a4f40c4cdadc8728a27b1d2928d36debab70db278b26d36661d5e908ba04a3235464f0b23487ac1c6b91c
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby-version: [2.7, 2.6, 2.5, 2.4, 2.3, 2.2, 2.1]
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Set up Ruby ${{ matrix.ruby-version }}
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby-version }}
17
+ - name: Install dependencies
18
+ run: bundle install
19
+ - name: Run tests
20
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  vendor/
19
+ .tags*
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.7.3
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.3
data/Gemfile CHANGED
@@ -7,8 +7,5 @@ gem 'pry-nav'
7
7
  gem 'pry-rescue'
8
8
 
9
9
  # optional dependency for more accurate timezone conversion
10
- gem 'tzinfo'
11
-
12
- # required for CircleCI to build properly with ruby 1.9.3
13
- gem 'json', '~> 1.8.3'
14
- gem 'rack', '~> 1.6.4'
10
+ gem 'tzinfo', '1.2.5'
11
+ # gem 'tzinfo', '2.0.0'
data/HISTORY.md ADDED
@@ -0,0 +1,26 @@
1
+ ## Unreleased
2
+
3
+ ### Added
4
+
5
+ *
6
+ *
7
+
8
+ ### Fixed
9
+
10
+ *
11
+ *
12
+
13
+ ## 0.8.8
14
+
15
+ ### Added
16
+
17
+ * Adding serialized assembly item to get_item
18
+ * Add CostCategory record (#482)
19
+ * Introduce search only fields (#483)
20
+
21
+ ### Fixed
22
+
23
+ * Fix accessing custom field values returned in advanced search results (#480)
24
+ * Fixing bug where single-selection custom multi select fields would incorrectly be parsed 3377c971d0cb727d81f4b4bc6e30edfbdfaccfd1
25
+ * Fixed some field definitions on serialized assembly item
26
+ * Properly extract external_id from advanced search results (#478)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
2
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
- **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
3
+ **Table of Contents**
4
4
 
5
5
  - [NetSuite SuiteTalk API Ruby Gem](#netsuite-suitetalk-api-ruby-gem)
6
6
  - [Help & Support](#help--support)
@@ -13,35 +13,33 @@
13
13
  - [Custom Records & Fields](#custom-records--fields)
14
14
  - [Searching](#searching)
15
15
  - [Non-standard Operations](#non-standard-operations)
16
- - [About SuiteSync](#about-suitesync)
17
16
 
18
17
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
19
18
 
20
- [![Circle CI](https://circleci.com/gh/NetSweet/netsuite/tree/master.svg?style=svg)](https://circleci.com/gh/NetSweet/netsuite/tree/master)
19
+ [![Ruby](https://github.com/NetSweet/netsuite/actions/workflows/main.yml/badge.svg)](https://github.com/NetSweet/netsuite/actions/workflows/main.yml)
21
20
  [![Slack Status](https://opensuite-slackin.herokuapp.com/badge.svg)](http://opensuite-slackin.herokuapp.com)
22
21
  [![Gem Version](https://badge.fury.io/rb/netsuite.svg)](http://badge.fury.io/rb/netsuite)
23
22
 
24
23
  # NetSuite SuiteTalk API Ruby Gem
25
24
 
26
25
  * This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API.
27
- * The gem does not cover the entire API, only the subset contributors have used so far.
28
- * NetSuite is a complex system. There's a lot to learn and sparse resources available to learn from. Here's a list of [NetSuite Development Resources](https://github.com/NetSweet/netsuite/wiki/NetSuite-Development-Resources) that might make things a bit less painful.
26
+ * The gem does not cover the entire API, only the subset contributors have used so far. Please submit a PR for any functionality that's missing!
27
+ * NetSuite is a complex system. There's a lot to learn and sparse resources available to learn from. Here's a list of [NetSuite Development Resources](https://github.com/NetSweet/netsuite/wiki/NetSuite-Development-Resources).
29
28
 
30
29
  # Help & Support
31
30
 
32
31
  Join the [slack channel](http://opensuite-slackin.herokuapp.com) for help with any NetSuite issues. Please do not post usage questions as issues in GitHub.
33
32
 
34
- Messages in the Slack ground are [archived here](https://suitechat.slackarchive.io). Search the archives to see if your question has been answered before.
35
-
36
33
  There is some additional helpful resources for NetSuite development [listed here](https://dashboard.suitesync.io/docs/resources#netsuite).
37
34
 
38
35
  # Testing
39
36
 
40
37
  Before contributing a patch make sure all existing tests pass.
41
38
 
42
- ```
39
+ ```shell
43
40
  git clone git://github.com/NetSweet/netsuite.git
44
41
  cd netsuite
42
+
45
43
  bundle
46
44
  bundle exec rspec
47
45
  ```
@@ -56,18 +54,56 @@ gem 'netsuite'
56
54
 
57
55
  If you'd like more accurate time conversion support, include the `tzinfo` gem.
58
56
 
59
- This gem is built for ruby 1.9.x+, checkout the [1-8-stable](https://github.com/NetSweet/netsuite/tree/1-8-stable) branch for ruby 1.8.x support.
57
+ This gem is built for ruby 2.6.x+, but should work on older versions down to 1.9. There's a [1-8-stable](https://github.com/NetSweet/netsuite/tree/1-8-stable) branch for ruby 1.8.x support.
60
58
 
61
59
  ## Configuration
62
60
 
63
- Not sure how to find your account id? Search for "web service preferences" in the NetSuite global search.
61
+ The most important thing you'll need is your NetSuite account ID. Not sure how to find your account id? [Here's a guide.](http://mikebian.co/find-netsuite-web-services-account-number/)
62
+
63
+ How you connect to NetSuite has changed a lot over the years and differs between API versions. For instance:
64
+
65
+ * Older API versions (~2015) allowed authentication via username and password
66
+ * Newever API versions (> 2016) still allowed for username and password authentication, but required an application ID
67
+ * "OAuth", which requires four separate keys to be manually generated, was supported sometime after 2015
68
+ * API versions greater than 2018_2 require `endpoint` to be set directly ([more info](https://github.com/NetSweet/netsuite/pull/473))
69
+
70
+ Here's an example connection configuration. You don't want to actually use username + password config; token based authentication is detailed below in a separate section:
71
+
72
+ ```ruby
73
+ NetSuite.configure do
74
+ reset!
75
+
76
+ # production & sandbox account numbers will differ
77
+ account 'TSTDRV1576318'
78
+ api_version '2018_2'
79
+
80
+ # password-based login information
81
+ # in most cases you should use token based authentication instead
82
+ email 'email@example.com'
83
+ password 'password'
84
+ role 10
85
+
86
+ # recent API versions require a account-specific endpoint o be set
87
+ # use `NetSuite::Utilities.data_center_url('TSTDRV1576318')` to retrieve wsdl URL
88
+ # you'll want to do this in a background process and strip the protocol out of the return string
89
+ wsdl_domain 'tstdrv1576318.suitetalk.api.netsuite.com'
90
+
91
+ # the endpoint indicated in the > 2018_2 wsdl is invalid
92
+ # you must set the endpoint directly
93
+ # https://github.com/NetSweet/netsuite/pull/473
94
+ endpoint "https://#{wsdl_domain}/services/NetSuitePort_#{api_version}"
95
+ end
96
+ ```
97
+
98
+ The `wsdl_domain` configuration is most important. Note that if you use `wsdl` or other configuration options below, you'll want to look at the configuration source to understand more about how the different options interact with each other. Some of the configuration options will mutate the state of other options.
99
+
100
+ Here's the various options that are are available for configuration:
64
101
 
65
102
  ```ruby
66
103
  NetSuite.configure do
67
104
  reset!
68
105
 
69
- # optional, defaults to 2011_2
70
- api_version '2012_1'
106
+ api_version '2018_2'
71
107
 
72
108
  # optionally specify full wsdl URL (to switch to sandbox, for example)
73
109
  wsdl "https://webservices.sandbox.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl"
@@ -79,21 +115,25 @@ NetSuite.configure do
79
115
  # construct the full wsdl location - e.g. "https://#{wsdl_domain}/wsdl/v#{api_version}_0/netsuite.wsdl"
80
116
  wsdl_domain "webservices.na2.netsuite.com"
81
117
 
82
- # or specify the sandbox flag if you don't want to deal with specifying a full URL
83
- sandbox true
84
-
85
118
  # often the netsuite servers will hang which would cause a timeout exception to be raised
86
- # if you don't mind waiting (e.g. processing NS via DJ), increasing the timeout should fix the issue
87
- read_timeout 100000
119
+ # if you don't mind waiting (e.g. processing NS via a background worker), increasing the timeout should fix the issue
120
+ read_timeout 100_000
88
121
 
89
122
  # you can specify a file or file descriptor to send the log output to (defaults to STDOUT)
123
+ # If using within a Rails app, consider setting to `Rails.logger` to leverage existing
124
+ # application-level log configuration
90
125
  log File.join(Rails.root, 'log/netsuite.log')
91
126
 
92
- # login information
93
- email 'email@domain.com'
94
- password 'password'
127
+ # Defaults to :debug level logging for Savon API calls. Decrease the verbosity
128
+ # by setting log_level to `:info`, for example
129
+ # log_level :debug
130
+
131
+ # password-based login information
132
+ # in most cases you should use token based authentication instead
133
+ email 'email@domain.com'
134
+ password 'password'
95
135
  account '12345'
96
- role 1111
136
+ role 1111
97
137
 
98
138
  # optional, ensures that read-only fields don't cause API errors
99
139
  soap_header 'platformMsgs:preferences' => {
@@ -102,9 +142,9 @@ NetSuite.configure do
102
142
  end
103
143
  ```
104
144
 
105
- If you'd like to use a API endpoints greater than 2015_1 you'll need to specify an application ID:
145
+ If are using username + password authentication (which you shouldn't be!) *and* you'd like to use a API endpoints greater than 2015_1 you'll need to specify an application ID:
106
146
 
107
- ```
147
+ ```ruby
108
148
  NetSuite::Configuration.soap_header = {
109
149
  'platformMsgs:ApplicationInfo' => {
110
150
  'platformMsgs:applicationId' => 'your-netsuite-app-id'
@@ -114,7 +154,7 @@ NetSuite::Configuration.soap_header = {
114
154
 
115
155
  ### Token based Authentication
116
156
 
117
- OAuth credentials are also supported. [Learn more about how to set up token based authentication here](http://mikebian.co/using-netsuites-token-based-authentication-with-suitetalk/).
157
+ OAuth credentials are supported and the recommended authentication approach. [Learn more about how to set up token based authentication here](http://mikebian.co/using-netsuites-token-based-authentication-with-suitetalk/).
118
158
 
119
159
  ```ruby
120
160
  NetSuite.configure do
@@ -129,6 +169,11 @@ NetSuite.configure do
129
169
 
130
170
  # oauth does not work with API versions less than 2015_2
131
171
  api_version '2016_2'
172
+
173
+ # the endpoint indicated in the > 2018_2 wsdl is invalid
174
+ # you must set the endpoint directly
175
+ # https://github.com/NetSweet/netsuite/pull/473
176
+ endpoint "https://#{wsdl_domain}/services/NetSuitePort_#{api_version}"
132
177
  end
133
178
  ```
134
179
 
@@ -390,7 +435,9 @@ NetSuite::Records::SalesOrder.search({
390
435
  'tranSales:itemJoin' => [
391
436
  'platformCommon:customFieldList' => [
392
437
  'platformCore:customField/' => {
393
- '@internalId' => 'custitem_apcategoryforsales',
438
+ '@scriptId' => 'custitem_apcategoryforsales',
439
+ # Or, for API versions 2013.1 and older:
440
+ # '@internalId' => 'custitem_apcategoryforsales',
394
441
  '@xsi:type' => "platformCore:SearchColumnSelectCustomField"
395
442
  }
396
443
  ]
@@ -568,7 +615,3 @@ states = NetSuite::Configuration.connection.call(:get_all, message: {
568
615
  })
569
616
  states.to_array.first[:get_all_response][:get_all_result][:record_list][:record].map { |r| { country: r[:country], abbr: r[:shortname], name: r[:full_name] } }
570
617
  ```
571
-
572
- # About SuiteSync
573
-
574
- [SuiteSync, the Stripe-NetSuite integration](http://suitesync.io) uses this gem and funds the majority of it's development and maintenance.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ task :default => :spec
7
7
 
8
8
  desc 'Run specs'
9
9
  RSpec::Core::RakeTask.new do |t|
10
- t.pattern = './spec/**/*_spec.rb'
10
+ # t.pattern = './spec/**/*_spec.rb'
11
11
  end
12
12
 
13
13
  desc 'Generate code coverage'
data/lib/netsuite.rb CHANGED
@@ -95,6 +95,7 @@ module NetSuite
95
95
  autoload :CashRefundItemList, 'netsuite/records/cash_refund_item_list'
96
96
  autoload :Campaign, 'netsuite/records/campaign'
97
97
  autoload :Classification, 'netsuite/records/classification'
98
+ autoload :CostCategory, 'netsuite/records/cost_category'
98
99
  autoload :CreditMemo, 'netsuite/records/credit_memo'
99
100
  autoload :CreditMemoApply, 'netsuite/records/credit_memo_apply'
100
101
  autoload :CreditMemoApplyList, 'netsuite/records/credit_memo_apply_list'
@@ -112,6 +113,8 @@ module NetSuite
112
113
  autoload :CustomerAddressbook, 'netsuite/records/customer_addressbook'
113
114
  autoload :CustomerAddressbookList, 'netsuite/records/customer_addressbook_list'
114
115
  autoload :CustomerCategory, 'netsuite/records/customer_category'
116
+ autoload :CustomerCreditCards, 'netsuite/records/customer_credit_cards'
117
+ autoload :CustomerCreditCardsList, 'netsuite/records/customer_credit_cards_list'
115
118
  autoload :CustomerCurrency, 'netsuite/records/customer_currency'
116
119
  autoload :CustomerCurrencyList, 'netsuite/records/customer_currency_list'
117
120
  autoload :CustomerDeposit, 'netsuite/records/customer_deposit'
@@ -121,6 +124,8 @@ module NetSuite
121
124
  autoload :CustomerPayment, 'netsuite/records/customer_payment'
122
125
  autoload :CustomerPaymentApply, 'netsuite/records/customer_payment_apply'
123
126
  autoload :CustomerPaymentApplyList, 'netsuite/records/customer_payment_apply_list'
127
+ autoload :CustomerPaymentCredit, 'netsuite/records/customer_payment_credit'
128
+ autoload :CustomerPaymentCreditList, 'netsuite/records/customer_payment_credit_list'
124
129
  autoload :CustomerPartner, 'netsuite/records/customer_partner'
125
130
  autoload :CustomerRefund, 'netsuite/records/customer_refund'
126
131
  autoload :CustomerRefundApply, 'netsuite/records/customer_refund_apply'
@@ -156,6 +161,9 @@ module NetSuite
156
161
  autoload :Duration, 'netsuite/records/duration'
157
162
  autoload :Employee, 'netsuite/records/employee'
158
163
  autoload :EntityCustomField, 'netsuite/records/entity_custom_field'
164
+ autoload :Estimate, 'netsuite/records/estimate'
165
+ autoload :EstimateItem, 'netsuite/records/estimate_item'
166
+ autoload :EstimateItemList, 'netsuite/records/estimate_item_list'
159
167
  autoload :File, 'netsuite/records/file'
160
168
  autoload :GiftCertificate, 'netsuite/records/gift_certificate'
161
169
  autoload :GiftCertificateItem, 'netsuite/records/gift_certificate_item'
@@ -206,8 +214,10 @@ module NetSuite
206
214
  autoload :Location, 'netsuite/records/location'
207
215
  autoload :LocationsList, 'netsuite/records/locations_list'
208
216
  autoload :LotNumberedAssemblyItem, 'netsuite/records/lot_numbered_assembly_item'
217
+ autoload :LotNumberedInventoryItem, 'netsuite/records/lot_numbered_inventory_item'
209
218
  autoload :MatrixOptionList, 'netsuite/records/matrix_option_list'
210
219
  autoload :MemberList, 'netsuite/records/member_list'
220
+ autoload :Message, 'netsuite/records/message'
211
221
  autoload :NonInventorySaleItem, 'netsuite/records/non_inventory_sale_item'
212
222
  autoload :NonInventoryPurchaseItem, 'netsuite/records/non_inventory_purchase_item'
213
223
  autoload :NonInventoryResaleItem, 'netsuite/records/non_inventory_resale_item'
@@ -261,6 +271,7 @@ module NetSuite
261
271
  autoload :Subsidiary, 'netsuite/records/subsidiary'
262
272
  autoload :SubtotalItem, 'netsuite/records/subtotal_item'
263
273
  autoload :SupportCase, 'netsuite/records/support_case'
274
+ autoload :SupportCaseType, 'netsuite/records/support_case_type'
264
275
  autoload :TaxType, 'netsuite/records/tax_type'
265
276
  autoload :TaxGroup, 'netsuite/records/tax_group'
266
277
  autoload :Task, 'netsuite/records/task'
@@ -289,6 +300,8 @@ module NetSuite
289
300
  autoload :VendorCreditItemList, 'netsuite/records/vendor_credit_item_list'
290
301
  autoload :VendorCreditExpense, 'netsuite/records/vendor_credit_expense'
291
302
  autoload :VendorCreditExpenseList, 'netsuite/records/vendor_credit_expense_list'
303
+ autoload :VendorCurrencyList, 'netsuite/records/vendor_currency_list'
304
+ autoload :VendorCurrency, 'netsuite/records/vendor_currency'
292
305
  autoload :VendorReturnAuthorization, 'netsuite/records/vendor_return_authorization'
293
306
  autoload :VendorReturnAuthorizationItem, 'netsuite/records/vendor_return_authorization_item'
294
307
  autoload :VendorReturnAuthorizationItemList, 'netsuite/records/vendor_return_authorization_item_list'
@@ -309,23 +322,4 @@ module NetSuite
309
322
  NetSuite::Configuration.instance_eval(&block)
310
323
  end
311
324
 
312
- def self.configure_from_env(&block)
313
- NetSuite.configure do
314
- reset!
315
-
316
- email ENV['NETSUITE_EMAIL'] unless ENV['NETSUITE_EMAIL'].nil?
317
- password ENV['NETSUITE_PASSWORD'] unless ENV['NETSUITE_PASSWORD'].nil?
318
- account ENV['NETSUITE_ACCOUNT'] unless ENV['NETSUITE_ACCOUNT'].nil?
319
- role ENV['NETSUITE_ROLE'] unless ENV['NETSUITE_ROLE'].nil?
320
- api_version ENV['NETSUITE_API'] unless ENV['NETSUITE_API'].nil?
321
- sandbox (ENV['NETSUITE_PRODUCTION'].nil? || ENV['NETSUITE_PRODUCTION'] != 'true')
322
- wsdl ENV['NETSUITE_WSDL'] unless ENV['NETSUITE_WSDL'].nil?
323
- silent (!ENV['NETSUITE_SILENT'].nil? && ENV['NETSUITE_SILENT'] == 'true')
324
-
325
- read_timeout 100_000
326
- end
327
-
328
- self.configure(&block) if block
329
- end
330
-
331
325
  end
@@ -28,6 +28,14 @@ module NetSuite
28
28
  # </platformCore:wsRoleList>
29
29
 
30
30
  def self.call(credentials)
31
+
32
+ soap_header = {}
33
+ if !credentials[:application_id].nil? && !credentials[:application_id].empty?
34
+ soap_header = NetSuite::Configuration.soap_header.dup
35
+ soap_header['platformMsgs:ApplicationInfo'] ||= {}
36
+ soap_header['platformMsgs:ApplicationInfo']['platformMsgs:applicationId'] = credentials[:application_id]
37
+ end
38
+
31
39
  passport = NetSuite::Configuration.auth_header.dup
32
40
 
33
41
 
@@ -39,13 +47,13 @@ module NetSuite
39
47
  if passport['platformMsgs:tokenPassport']
40
48
  passport['platformMsgs:passport']['platformCore:account'] ||= passport['platformMsgs:tokenPassport']['platformCore:account']
41
49
  end
42
-
50
+
43
51
  passport['platformMsgs:passport']['platformCore:account'] = credentials[:account] if !credentials[:account].nil?
44
52
 
45
53
  passport.delete('platformMsgs:tokenPassport')
46
54
 
47
55
  begin
48
- response = NetSuite::Configuration.connection(soap_header: {}).call :login, message: passport
56
+ response = NetSuite::Configuration.connection(soap_header: soap_header).call :login, message: passport
49
57
  rescue Savon::SOAPFault => e
50
58
  error_details = e.to_hash[:fault]
51
59
 
@@ -37,6 +37,8 @@ module NetSuite
37
37
  hash['platformMsgs:record']['@platformMsgs:externalId'] = @object.external_id
38
38
  end
39
39
 
40
+ # setting the internal ID on upsert will result in `CANT_SET_INTERNALID`
41
+
40
42
  hash
41
43
  end
42
44
 
@@ -17,7 +17,9 @@ module NetSuite
17
17
  def connection(params={}, credentials={})
18
18
  client = Savon.client({
19
19
  wsdl: cached_wsdl || wsdl,
20
+ endpoint: endpoint,
20
21
  read_timeout: read_timeout,
22
+ open_timeout: open_timeout,
21
23
  namespaces: namespaces,
22
24
  soap_header: auth_header(credentials).update(soap_header),
23
25
  pretty_print_xml: true,
@@ -93,6 +95,18 @@ module NetSuite
93
95
  attributes[:api_version] = version
94
96
  end
95
97
 
98
+ def endpoint=(endpoint)
99
+ attributes[:endpoint] = endpoint
100
+ end
101
+
102
+ def endpoint(endpoint=nil)
103
+ if endpoint
104
+ self.endpoint = endpoint
105
+ else
106
+ attributes[:endpoint]
107
+ end
108
+ end
109
+
96
110
  def sandbox=(flag)
97
111
  if attributes[:sandbox] != flag
98
112
  attributes[:wsdl] = nil
@@ -326,6 +340,18 @@ module NetSuite
326
340
  end
327
341
  end
328
342
 
343
+ def open_timeout=(timeout)
344
+ attributes[:open_timeout] = timeout
345
+ end
346
+
347
+ def open_timeout(timeout = nil)
348
+ if timeout
349
+ self.open_timeout = timeout
350
+ else
351
+ attributes[:open_timeout]
352
+ end
353
+ end
354
+
329
355
  def log=(path)
330
356
  attributes[:log] = path
331
357
  end
@@ -337,7 +363,10 @@ module NetSuite
337
363
 
338
364
  def logger(value = nil)
339
365
  if value.nil?
340
- attributes[:logger] ||= ::Logger.new((log && !log.empty?) ? log : $stdout)
366
+ # if passed a IO object (like StringIO) `empty?` won't exist
367
+ valid_log = log && !(log.respond_to?(:empty?) && log.empty?)
368
+
369
+ attributes[:logger] ||= ::Logger.new(valid_log ? log : $stdout)
341
370
  else
342
371
  attributes[:logger] = value
343
372
  end
@@ -357,12 +386,13 @@ module NetSuite
357
386
  end
358
387
 
359
388
  def log_level(value = nil)
360
- self.log_level = value || :debug
361
- attributes[:log_level]
389
+ self.log_level = value if value
390
+
391
+ attributes[:log_level] || :debug
362
392
  end
363
393
 
364
394
  def log_level=(value)
365
- attributes[:log_level] ||= value
395
+ attributes[:log_level] = value
366
396
  end
367
397
  end
368
398
  end