netsuite 0.7.9 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile +7 -2
  5. data/README.md +164 -61
  6. data/circle.yml +33 -13
  7. data/lib/netsuite.rb +55 -19
  8. data/lib/netsuite/actions/login.rb +20 -1
  9. data/lib/netsuite/actions/search.rb +1 -6
  10. data/lib/netsuite/actions/update.rb +6 -2
  11. data/lib/netsuite/actions/update_list.rb +109 -0
  12. data/lib/netsuite/actions/upsert.rb +2 -0
  13. data/lib/netsuite/configuration.rb +21 -4
  14. data/lib/netsuite/errors.rb +3 -0
  15. data/lib/netsuite/records/assembly_build.rb +39 -0
  16. data/lib/netsuite/records/assembly_component.rb +28 -0
  17. data/lib/netsuite/records/assembly_component_list.rb +12 -0
  18. data/lib/netsuite/records/assembly_item.rb +1 -0
  19. data/lib/netsuite/records/assembly_unbuild.rb +40 -0
  20. data/lib/netsuite/records/bin_number.rb +18 -0
  21. data/lib/netsuite/records/bin_number_list.rb +1 -20
  22. data/lib/netsuite/records/bin_transfer.rb +38 -0
  23. data/lib/netsuite/records/bin_transfer_inventory.rb +20 -0
  24. data/lib/netsuite/records/bin_transfer_inventory_list.rb +10 -0
  25. data/lib/netsuite/records/cash_refund.rb +101 -3
  26. data/lib/netsuite/records/cash_refund_item.rb +1 -1
  27. data/lib/netsuite/records/cash_sale.rb +1 -0
  28. data/lib/netsuite/records/classification.rb +5 -2
  29. data/lib/netsuite/records/contact.rb +2 -1
  30. data/lib/netsuite/records/contact_addressbook.rb +64 -0
  31. data/lib/netsuite/records/contact_addressbook_list.rb +11 -0
  32. data/lib/netsuite/records/credit_memo.rb +1 -0
  33. data/lib/netsuite/records/currency_rate.rb +4 -3
  34. data/lib/netsuite/records/custom_field_list.rb +16 -3
  35. data/lib/netsuite/records/custom_record.rb +3 -3
  36. data/lib/netsuite/records/custom_record_ref.rb +1 -0
  37. data/lib/netsuite/records/customer.rb +5 -4
  38. data/lib/netsuite/records/customer_credit_cards.rb +36 -0
  39. data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
  40. data/lib/netsuite/records/customer_deposit.rb +6 -2
  41. data/lib/netsuite/records/customer_deposit_apply.rb +17 -0
  42. data/lib/netsuite/records/customer_deposit_apply_list.rb +12 -0
  43. data/lib/netsuite/records/customer_payment.rb +1 -0
  44. data/lib/netsuite/records/customer_sales_team.rb +24 -0
  45. data/lib/netsuite/records/customer_sales_team_list.rb +9 -0
  46. data/lib/netsuite/records/customer_status.rb +29 -0
  47. data/lib/netsuite/records/customer_subscription.rb +18 -0
  48. data/lib/netsuite/records/customer_subscriptions_list.rb +10 -0
  49. data/lib/netsuite/records/deposit_other.rb +0 -10
  50. data/lib/netsuite/records/employee.rb +3 -2
  51. data/lib/netsuite/records/entity_custom_field.rb +53 -0
  52. data/lib/netsuite/records/estimate.rb +42 -0
  53. data/lib/netsuite/records/estimate_item.rb +40 -0
  54. data/lib/netsuite/records/estimate_item_list.rb +11 -0
  55. data/lib/netsuite/records/inbound_shipment.rb +33 -0
  56. data/lib/netsuite/records/inbound_shipment_item.rb +39 -0
  57. data/lib/netsuite/records/inbound_shipment_item_list.rb +11 -0
  58. data/lib/netsuite/records/inter_company_journal_entry.rb +48 -0
  59. data/lib/netsuite/records/inter_company_journal_entry_line.rb +28 -0
  60. data/lib/netsuite/records/inter_company_journal_entry_line_list.rb +14 -0
  61. data/lib/netsuite/records/inventory_adjustment.rb +1 -1
  62. data/lib/netsuite/records/inventory_adjustment_inventory.rb +2 -2
  63. data/lib/netsuite/records/inventory_item.rb +2 -2
  64. data/lib/netsuite/records/inventory_number.rb +35 -0
  65. data/lib/netsuite/records/inventory_number_locations.rb +16 -0
  66. data/lib/netsuite/records/inventory_number_locations_list.rb +10 -0
  67. data/lib/netsuite/records/inventory_transfer.rb +2 -2
  68. data/lib/netsuite/records/inventory_transfer_inventory_list.rb +0 -2
  69. data/lib/netsuite/records/invoice.rb +4 -4
  70. data/lib/netsuite/records/item_fulfillment.rb +2 -1
  71. data/lib/netsuite/records/job.rb +2 -1
  72. data/lib/netsuite/records/lot_numbered_assembly_item.rb +64 -0
  73. data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
  74. data/lib/netsuite/records/matrix_option_list.rb +12 -4
  75. data/lib/netsuite/records/message.rb +30 -0
  76. data/lib/netsuite/records/non_inventory_resale_item.rb +3 -2
  77. data/lib/netsuite/records/non_inventory_sale_item.rb +2 -1
  78. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  79. data/lib/netsuite/records/partner.rb +1 -1
  80. data/lib/netsuite/records/price.rb +17 -0
  81. data/lib/netsuite/records/price_level.rb +26 -0
  82. data/lib/netsuite/records/price_list.rb +9 -0
  83. data/lib/netsuite/records/pricing.rb +20 -0
  84. data/lib/netsuite/records/pricing_matrix.rb +2 -2
  85. data/lib/netsuite/records/promotions.rb +26 -0
  86. data/lib/netsuite/records/promotions_list.rb +9 -0
  87. data/lib/netsuite/records/return_authorization.rb +3 -2
  88. data/lib/netsuite/records/return_authorization_item.rb +43 -0
  89. data/lib/netsuite/records/return_authorization_item_list.rb +11 -0
  90. data/lib/netsuite/records/sales_order.rb +1 -0
  91. data/lib/netsuite/records/sales_order_item.rb +12 -5
  92. data/lib/netsuite/records/sales_role.rb +26 -0
  93. data/lib/netsuite/records/sales_tax_item.rb +3 -1
  94. data/lib/netsuite/records/serialized_assembly_item.rb +239 -0
  95. data/lib/netsuite/records/serialized_inventory_item.rb +2 -2
  96. data/lib/netsuite/records/serialized_inventory_item_location.rb +37 -0
  97. data/lib/netsuite/records/serialized_inventory_item_locations_list.rb +10 -0
  98. data/lib/netsuite/records/serialized_inventory_item_numbers.rb +15 -0
  99. data/lib/netsuite/records/serialized_inventory_item_numbers_list.rb +10 -0
  100. data/lib/netsuite/records/service_resale_item.rb +1 -1
  101. data/lib/netsuite/records/service_sale_item.rb +2 -1
  102. data/lib/netsuite/records/subsidiary.rb +1 -0
  103. data/lib/netsuite/records/support_case.rb +1 -1
  104. data/lib/netsuite/records/support_case_type.rb +26 -0
  105. data/lib/netsuite/records/task.rb +2 -1
  106. data/lib/netsuite/records/tax_group.rb +3 -1
  107. data/lib/netsuite/records/transaction_body_custom_field.rb +61 -0
  108. data/lib/netsuite/records/transaction_column_custom_field.rb +59 -0
  109. data/lib/netsuite/records/transfer_order_item.rb +2 -2
  110. data/lib/netsuite/records/vendor.rb +1 -0
  111. data/lib/netsuite/records/vendor_bill.rb +2 -1
  112. data/lib/netsuite/records/vendor_credit.rb +2 -0
  113. data/lib/netsuite/records/work_order.rb +8 -0
  114. data/lib/netsuite/support/actions.rb +2 -0
  115. data/lib/netsuite/support/country.rb +27 -14
  116. data/lib/netsuite/support/search_result.rb +20 -5
  117. data/lib/netsuite/utilities.rb +100 -43
  118. data/lib/netsuite/version.rb +2 -2
  119. data/netsuite.gemspec +5 -4
  120. data/spec/netsuite/actions/login_spec.rb +23 -0
  121. data/spec/netsuite/actions/update_list_spec.rb +107 -0
  122. data/spec/netsuite/actions/update_spec.rb +42 -0
  123. data/spec/netsuite/configuration_spec.rb +79 -6
  124. data/spec/netsuite/records/address_spec.rb +10 -0
  125. data/spec/netsuite/records/basic_record_spec.rb +18 -1
  126. data/spec/netsuite/records/bin_number_spec.rb +23 -0
  127. data/spec/netsuite/records/classification_spec.rb +10 -1
  128. data/spec/netsuite/records/custom_field_list_spec.rb +46 -5
  129. data/spec/netsuite/records/custom_record_spec.rb +1 -1
  130. data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
  131. data/spec/netsuite/records/customer_sales_team_list_spec.rb +41 -0
  132. data/spec/netsuite/records/customer_spec.rb +44 -2
  133. data/spec/netsuite/records/customer_subscription_spec.rb +41 -0
  134. data/spec/netsuite/records/customer_subscriptions_list_spec.rb +19 -0
  135. data/spec/netsuite/records/employee_spec.rb +2 -2
  136. data/spec/netsuite/records/entity_custom_field_spec.rb +34 -0
  137. data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
  138. data/spec/netsuite/records/estimate_item_spec.rb +40 -0
  139. data/spec/netsuite/records/estimate_spec.rb +216 -0
  140. data/spec/netsuite/records/inter_company_journal_entry_line_list_spec.rb +26 -0
  141. data/spec/netsuite/records/inter_company_journal_entry_line_spec.rb +60 -0
  142. data/spec/netsuite/records/inter_company_journal_entry_spec.rb +156 -0
  143. data/spec/netsuite/records/inventory_item_spec.rb +57 -0
  144. data/spec/netsuite/records/inventory_transfer_spec.rb +21 -0
  145. data/spec/netsuite/records/invoice_spec.rb +4 -4
  146. data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
  147. data/spec/netsuite/records/message_spec.rb +49 -0
  148. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
  149. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
  150. data/spec/netsuite/records/partner_spec.rb +141 -0
  151. data/spec/netsuite/records/price_level_spec.rb +16 -0
  152. data/spec/netsuite/records/pricing_matrix_spec.rb +15 -13
  153. data/spec/netsuite/records/return_authorization_item_list_spec.rb +26 -0
  154. data/spec/netsuite/records/return_authorization_item_spec.rb +43 -0
  155. data/spec/netsuite/records/sales_order_item_spec.rb +11 -5
  156. data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
  157. data/spec/netsuite/records/support_case_type_spec.rb +22 -0
  158. data/spec/netsuite/records/transaction_body_custom_field_spec.rb +32 -0
  159. data/spec/netsuite/records/transaction_column_custom_field_spec.rb +32 -0
  160. data/spec/netsuite/records/vendor_credit_spec.rb +29 -0
  161. data/spec/netsuite/support/search_result_spec.rb +24 -0
  162. data/spec/netsuite/utilities_spec.rb +50 -0
  163. data/spec/spec_helper.rb +5 -4
  164. data/spec/support/fixtures/update_list/update_list_items.xml +22 -0
  165. data/spec/support/fixtures/update_list/update_list_one_item.xml +18 -0
  166. data/spec/support/fixtures/update_list/update_list_with_errors.xml +32 -0
  167. metadata +123 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 37636c6c1899441452fd3042cf52037b76680616
4
- data.tar.gz: 15c8900ac424109bdece121e2abbc3902a47bf7e
2
+ SHA256:
3
+ metadata.gz: 3c52f30c1f82b68e1ac2e078d81eed79f6c34ec0cc5937dd4251a53cb9a5a5c0
4
+ data.tar.gz: 4208277a164ec0b92520cef24b19367538788ecce870cd37f683ddb9fb85143e
5
5
  SHA512:
6
- metadata.gz: 08d79d1b7ee99dde3b063afab044f47a4d21e2628d15d9bd0119fc81de3fca087e6d5c85b882e5ae6b844e66e9016cfebd204b61cd0656e9b09c02c6880e23e1
7
- data.tar.gz: df7df5ffb7fd5a7815241ef70ac3d29ff46d07d9f26c770e079e663a2450f45e33f535a603d8dfb1221d091297b902472c2c66ba9404d3cc880faaa5341e8e7e
6
+ metadata.gz: bd8c7a34e1ecced72b398715f17978677bc87021e0bc9581449299f918b51993770d956eb3553775c1631ef16c8e488e6ffe682d9575665d81434106635f7e53
7
+ data.tar.gz: f40134f2aaf8824e9b51f9dba00a8a4d9b3b1e935df0d0d07f100018becf8180f6b603f63e52331e65877bbeb135de491fed75a9c5af0928e7409eedbc2f62b4
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  vendor/
19
+ .tags*
@@ -1 +1 @@
1
- 2.3.0
1
+ 2.6.6
data/Gemfile CHANGED
@@ -2,10 +2,15 @@ source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
4
  gem 'simplecov', :require => false
5
+ gem 'rspec_junit_formatter'
5
6
 
6
7
  gem 'pry-nav'
7
8
  gem 'pry-rescue'
8
9
 
10
+ # optional dependency for more accurate timezone conversion
11
+ gem 'tzinfo', '1.2.5'
12
+ # gem 'tzinfo', '2.0.0'
13
+
9
14
  # required for CircleCI to build properly with ruby 1.9.3
10
- gem 'json', '~> 1.8.3'
11
- gem 'rack', '~> 1.6.4'
15
+ gem 'json', '~> 2.3.0'
16
+ gem 'rack', '~> 2.1.4'
data/README.md CHANGED
@@ -1,20 +1,52 @@
1
- [![Circle CI](https://circleci.com/gh/NetSweet/netsuite/tree/master.svg?style=svg)](https://circleci.com/gh/NetSweet/netsuite/tree/master)
2
- [![Slack Status](https://opensuite-slackin.herokuapp.com/badge.svg)](http://opensuite-slackin.herokuapp.com)
3
- [![Gem Version](https://badge.fury.io/rb/netsuite.svg)](http://badge.fury.io/rb/netsuite)
4
- [![Dependency Status](https://gemnasium.com/roidrage/lograge.svg)](https://gemnasium.com/netsweet/netsuite)
1
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
+ **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4
+
5
+ - [NetSuite SuiteTalk API Ruby Gem](#netsuite-suitetalk-api-ruby-gem)
6
+ - [Help & Support](#help--support)
7
+ - [Testing](#testing)
8
+ - [Installation](#installation)
9
+ - [Configuration](#configuration)
10
+ - [Token based Authentication](#token-based-authentication)
11
+ - [Usage](#usage)
12
+ - [CRUD Operations](#crud-operations)
13
+ - [Custom Records & Fields](#custom-records--fields)
14
+ - [Searching](#searching)
15
+ - [Non-standard Operations](#non-standard-operations)
16
+ - [About SuiteSync](#about-suitesync)
17
+
18
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
19
+
20
+ [![Circle CI](https://circleci.com/gh/NetSweet/netsuite/tree/master.svg?style=svg)](https://circleci.com/gh/NetSweet/netsuite/tree/master)
21
+ [![Slack Status](https://opensuite-slackin.herokuapp.com/badge.svg)](http://opensuite-slackin.herokuapp.com)
22
+ [![Gem Version](https://badge.fury.io/rb/netsuite.svg)](http://badge.fury.io/rb/netsuite)
23
+
24
+ # NetSuite SuiteTalk API Ruby Gem
25
+
26
+ * 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.
5
29
 
6
- # NetSuite Ruby SuiteTalk Gem
30
+ # Help & Support
7
31
 
8
- * This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API. Wow, that is a mouthful.
9
- * The gem does not cover the entire API, only the subset that we have found useful to cover so far.
10
- * Extending the wrapper is pretty simple, check out recent commits for an example of how to add support for additional records.
11
- * NetSuite development is overall a pretty poor experience. We have a list of [NetSuite Development Resources](https://github.com/NetSweet/netsuite/wiki/NetSuite-Development-Resources) that might make things a bit less painful.
32
+ 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.
12
33
 
13
- # Help & Support
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.
14
35
 
15
- Join the [slack channel](http://opensuite-slackin.herokuapp.com) for help with any NetSuite issues.
36
+ There is some additional helpful resources for NetSuite development [listed here](https://dashboard.suitesync.io/docs/resources#netsuite).
16
37
 
17
- ## Installation
38
+ # Testing
39
+
40
+ Before contributing a patch make sure all existing tests pass.
41
+
42
+ ```
43
+ git clone git://github.com/NetSweet/netsuite.git
44
+ cd netsuite
45
+ bundle
46
+ bundle exec rspec
47
+ ```
48
+
49
+ # Installation
18
50
 
19
51
  Add this line to your application's Gemfile:
20
52
 
@@ -22,57 +54,92 @@ Add this line to your application's Gemfile:
22
54
  gem 'netsuite'
23
55
  ```
24
56
 
57
+ If you'd like more accurate time conversion support, include the `tzinfo` gem.
58
+
25
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.
26
60
 
27
- ## Testing
28
- Before contributing a patch make sure all existing tests pass.
61
+ ## Configuration
29
62
 
63
+ 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/)
64
+
65
+ For most use-cases, the following configuration will be sufficient:
66
+
67
+ ```ruby
68
+ NetSuite.configure do
69
+ reset!
70
+
71
+ account 'TSTDRV1576318'
72
+ api_version '2018_2'
73
+
74
+ email 'email@example.com'
75
+ password 'password'
76
+ role 10
77
+
78
+ # use `NetSuite::Utilities.data_center_url('TSTDRV1576318')` to retrieve the URL
79
+ # you'll want to do this in a background process and strip the protocol out of the return string
80
+ wsdl_domain 'tstdrv1576318.suitetalk.api.netsuite.com'
81
+ end
30
82
  ```
31
- git clone git://github.com/NetSweet/netsuite.git
32
- cd netsuite
33
- bundle
34
- bundle exec rspec
35
- ```
36
- ## Usage
37
83
 
38
- ### Configuration
84
+ 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.
39
85
 
40
- Not sure how to find your account id? Search for "web service preferences" in the NetSuite global search.
86
+ Here's the various options that are are available for configuration:
41
87
 
42
88
  ```ruby
43
89
  NetSuite.configure do
44
90
  reset!
45
91
 
46
- # optional, defaults to 2011_2
47
- api_version '2012_1'
92
+ api_version '2018_2'
48
93
 
49
94
  # optionally specify full wsdl URL (to switch to sandbox, for example)
50
95
  wsdl "https://webservices.sandbox.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl"
51
96
 
52
97
  # if your datacenter is being switched, you'll have to manually set your wsdl location
53
- wsdl "https://webservices.na2.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl"
98
+ wsdl "https://webservices.na2.netsuite.com/wsdl/v#{api_version}_0/netsuite.wsdl"
54
99
 
55
- # or specify the sandbox flag if you don't want to deal with specifying a full URL
56
- sandbox true
100
+ # or specify the wsdl_domain if you want to specify the datacenter and let the configuration
101
+ # construct the full wsdl location - e.g. "https://#{wsdl_domain}/wsdl/v#{api_version}_0/netsuite.wsdl"
102
+ wsdl_domain "webservices.na2.netsuite.com"
57
103
 
58
104
  # often the netsuite servers will hang which would cause a timeout exception to be raised
59
- # if you don't mind waiting (e.g. processing NS via DJ), increasing the timeout should fix the issue
60
- read_timeout 100000
105
+ # if you don't mind waiting (e.g. processing NS via a background worker), increasing the timeout should fix the issue
106
+ read_timeout 100_000
61
107
 
62
108
  # you can specify a file or file descriptor to send the log output to (defaults to STDOUT)
109
+ # If using within a Rails app, consider setting to `Rails.logger` to leverage existing
110
+ # application-level log configuration
63
111
  log File.join(Rails.root, 'log/netsuite.log')
64
112
 
65
- # login information
66
- email 'email@domain.com'
67
- password 'password'
113
+ # Defaults to :debug level logging for Savon API calls. Decrease the verbosity
114
+ # by setting log_level to `:info`, for example
115
+ # log_level :debug
116
+
117
+ # password-based login information
118
+ email 'email@domain.com'
119
+ password 'password'
68
120
  account '12345'
69
- role 1111
121
+ role 1111
122
+
123
+ # optional, ensures that read-only fields don't cause API errors
124
+ soap_header 'platformMsgs:preferences' => {
125
+ 'platformMsgs:ignoreReadOnlyFields' => true,
126
+ }
70
127
  end
71
128
  ```
72
129
 
73
- There is a [convenience method](https://github.com/NetSweet/netsuite/blob/56fe7fae92908a2e3d6812ecc56516f773cacd45/lib/netsuite.rb#L180) to configure NetSuite based on ENV variables.
130
+ If you'd like to use a API endpoints greater than 2015_1 you'll need to specify an application ID:
74
131
 
75
- OAuth credentials are also supported:
132
+ ```
133
+ NetSuite::Configuration.soap_header = {
134
+ 'platformMsgs:ApplicationInfo' => {
135
+ 'platformMsgs:applicationId' => 'your-netsuite-app-id'
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### Token based Authentication
141
+
142
+ 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/).
76
143
 
77
144
  ```ruby
78
145
  NetSuite.configure do
@@ -84,15 +151,15 @@ NetSuite.configure do
84
151
  consumer_secret ENV['NETSUITE_CONSUMER_SECRET']
85
152
  token_id ENV['NETSUITE_TOKEN_ID']
86
153
  token_secret ENV['NETSUITE_TOKEN_SECRET']
87
-
154
+
88
155
  # oauth does not work with API versions less than 2015_2
89
- api_version '2015_2'
156
+ api_version '2016_2'
90
157
  end
91
158
  ```
92
159
 
93
- ### Examples
160
+ # Usage
94
161
 
95
- #### CRUD Operations
162
+ ## CRUD Operations
96
163
 
97
164
  ```ruby
98
165
  # get a customer
@@ -100,7 +167,8 @@ customer = NetSuite::Records::Customer.get(:internal_id => 4)
100
167
  customer.is_person
101
168
 
102
169
  # or
103
- NetSuite::Records::Customer.get(4).is_person
170
+ NetSuite::Records::Customer.get(4)
171
+
104
172
 
105
173
  # get a list of customers
106
174
  customers = NetSuite::Records::Customer.get_list(:list => [4, 5, 6])
@@ -120,19 +188,37 @@ task.add
120
188
  # this will only work on OS X, open a browser to the record that was just created
121
189
  `open https://system.sandbox.netsuite.com/app/crm/calendar/task.nl?id=#{invoice.internal_id}`
122
190
 
123
- task.update :message => 'New Message'
191
+ # update a field on a record
192
+ task.update(message: 'New Message')
124
193
 
194
+ # delete a record
125
195
  task.delete
126
196
 
197
+ # refresh/reload a record (helpful after adding the record for the first time)
198
+ task.reload
199
+
127
200
  # using get_select_value with a standard record
128
201
  NetSuite::Records::BaseRefList.get_select_value(
129
202
  recordType: 'serviceSaleItem',
130
203
  field: 'taxSchedule'
131
204
  )
132
205
 
206
+ # get options for a custom sublist field (i.e. transaction column fields)
207
+ NetSuite::Records::BaseRefList.get_select_value(
208
+ field: 'custcol69_2',
209
+ sublist: 'itemList',
210
+ recordType: 'salesOrder'
211
+ )
212
+
213
+ # output names of options available for a custom field
214
+ options = NetSuite::Records::BaseRefList.get_select_value(
215
+ field: 'custbody_order_source',
216
+ recordType: 'invoice'
217
+ )
218
+ options.base_refs.map(&:name)
133
219
  ```
134
220
 
135
- #### Custom Records & Fields
221
+ ## Custom Records & Fields
136
222
 
137
223
  ```ruby
138
224
  # updating a custom field list on a record
@@ -183,7 +269,7 @@ NetSuite::Records::BaseRefList.get_select_value(
183
269
  )
184
270
  ```
185
271
 
186
- #### Searching
272
+ ## Searching
187
273
 
188
274
  ```ruby
189
275
  # basic search
@@ -199,6 +285,10 @@ search = NetSuite::Records::Customer.search({
199
285
 
200
286
  `open https://system.netsuite.com/app/common/entity/custjob.nl?id=#{search.results.first.internal_id}`
201
287
 
288
+ # find the avalara tax item. Some records don't support search.
289
+ all_sales_taxes = NetSuite::Utilities.backoff { NetSuite::Records::SalesTaxItem.get_all }
290
+ ns_tax_code = all_sales_taxes.detect { |st| st.item_id == 'AVATAX' }
291
+
202
292
  # searching for custom records
203
293
  NetSuite::Records::CustomRecord.search(
204
294
  basic: [
@@ -251,15 +341,14 @@ NetSuite::Records::Customer.search({
251
341
  ]
252
342
  }).results
253
343
 
254
- # advanced search from scratch
255
- NetSuite::Records::Transaction.search({
344
+ NetSuite::Records::SalesOrder.search({
256
345
  criteria: {
257
346
  basic: [
347
+ # NOTE do not search for more than one transaction type at a time!
258
348
  {
259
349
  field: 'type',
260
350
  operator: 'anyOf',
261
- type: 'SearchEnumMultiSelectField',
262
- value: [ "_invoice", "_salesOrder" ]
351
+ value: [ "_invoice"]
263
352
  },
264
353
  {
265
354
  field: 'tranDate',
@@ -267,10 +356,7 @@ NetSuite::Records::Transaction.search({
267
356
  # this is needed for date range search requests, for date requests with a single param type is not needed
268
357
  type: 'SearchDateField',
269
358
  value: [
270
- # the following format is equivilent to ISO 8601
271
- # Date.parse("1/1/2012").strftime("%Y-%m-%dT%H:%M:%S%z"),
272
- # Date.parse("30/07/2013").strftime("%Y-%m-%dT%H:%M:%S%z")
273
-
359
+ # NetSuite requires iso8601 time format
274
360
  # need to require the time library for this to work
275
361
  Time.parse("01/01/2012").iso8601,
276
362
  Time.parse("30/07/2013").iso8601,
@@ -337,10 +423,33 @@ NetSuite::Records::Transaction.search({
337
423
  },
338
424
 
339
425
  preferences: {
340
- page_size: 10
426
+ page_size: 10,
427
+
428
+ # only returning body fields increases performance!
429
+ body_fields_only: true
341
430
  }
342
431
  }).results
343
432
 
433
+ # Search for SalesOrder records with a "Pending Approval" status using the TransactionStatus enum value.
434
+ # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_2/schema/enum/transactionstatus.html
435
+
436
+ NetSuite::Records::SalesOrder.search(
437
+ criteria: {
438
+ basic: [
439
+ {
440
+ field: 'type',
441
+ operator: 'anyOf',
442
+ value: ['_salesOrder'],
443
+ },
444
+ {
445
+ field: 'status',
446
+ operator: 'anyOf',
447
+ value: ['_salesOrderPendingApproval'],
448
+ },
449
+ ],
450
+ },
451
+ )
452
+
344
453
  NetSuite::Records::ItemFulfillment.search({
345
454
  criteria: {
346
455
  basic: [
@@ -464,7 +573,7 @@ deposit.payment = 20
464
573
  deposit.add
465
574
  ```
466
575
 
467
- #### Non-standard Operations
576
+ ## Non-standard Operations
468
577
 
469
578
  ```ruby
470
579
  # making a call that hasn't been implemented yet
@@ -485,12 +594,6 @@ states = NetSuite::Configuration.connection.call(:get_all, message: {
485
594
  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] } }
486
595
  ```
487
596
 
488
- #### 2015_2 ApplicationId Support
597
+ # About SuiteSync
489
598
 
490
- ```ruby
491
- NetSuite::Configuration.soap_header = {
492
- 'platformMsgs:ApplicationInfo' => {
493
- 'platformMsgs:applicationId' => 'your-netsuite-app-id'
494
- }
495
- }
496
- ```
599
+ [SuiteSync, the Stripe-NetSuite integration](http://suitesync.io) uses this gem and funds the majority of it's development and maintenance.
data/circle.yml CHANGED
@@ -1,16 +1,36 @@
1
- # https://leonid.shevtsov.me/post/multiple-rubies-on-circleci/
1
+ version: 2.1
2
2
 
3
- machine:
4
- environment:
5
- RUBY_VERSIONS: 2.0.0,2.1.10,2.2.5,2.3.1,2.4.0
3
+ orbs:
4
+ # orbs are basically bundles of pre-written build scripts that work for common cases
5
+ # https://github.com/CircleCI-Public/ruby-orb
6
+ ruby: circleci/ruby@1.1
6
7
 
7
- dependencies:
8
- override:
9
- - rvm get head
10
- - rvm install $RUBY_VERSIONS
11
- - rvm $RUBY_VERSIONS --verbose do gem install bundler
12
- - rvm $RUBY_VERSIONS --verbose do bundle install
8
+ jobs:
9
+ # skipping build step because Gemfile.lock is not included in the source
10
+ # this makes the bundler caching step a noop
11
+ test:
12
+ parameters:
13
+ ruby-version:
14
+ type: string
15
+ docker:
16
+ - image: cimg/ruby:<< parameters.ruby-version >>
17
+ steps:
18
+ - checkout
19
+ - ruby/install-deps:
20
+ bundler-version: '1.17.2'
21
+ with-cache: false
22
+ - ruby/rspec-test
13
23
 
14
- test:
15
- override:
16
- - rvm $RUBY_VERSIONS --verbose do bundle exec rspec spec
24
+ # strangely, there seems to be very little documentation about exactly how martix builds work.
25
+ # By defining a param inside your job definition, Circle CI will automatically spawn a job for
26
+ # unique param value passed via `matrix`. Neat!
27
+ # https://circleci.com/blog/circleci-matrix-jobs/
28
+ workflows:
29
+ build_and_test:
30
+ jobs:
31
+ - test:
32
+ matrix:
33
+ parameters:
34
+ # https://github.com/CircleCI-Public/cimg-ruby
35
+ # only supports the last three ruby versions
36
+ ruby-version: ["2.5", "2.6", "2.7"]
@@ -58,6 +58,7 @@ module NetSuite
58
58
  autoload :GetSelectValue, 'netsuite/actions/get_select_value'
59
59
  autoload :Initialize, 'netsuite/actions/initialize'
60
60
  autoload :Update, 'netsuite/actions/update'
61
+ autoload :UpdateList, 'netsuite/actions/update_list'
61
62
  autoload :Upsert, 'netsuite/actions/upsert'
62
63
  autoload :UpsertList, 'netsuite/actions/upsert_list'
63
64
  autoload :Search, 'netsuite/actions/search'
@@ -66,6 +67,10 @@ module NetSuite
66
67
 
67
68
  module Records
68
69
  autoload :AssemblyItem, 'netsuite/records/assembly_item'
70
+ autoload :AssemblyBuild, 'netsuite/records/assembly_build'
71
+ autoload :AssemblyComponent, 'netsuite/records/assembly_component'
72
+ autoload :AssemblyComponentList, 'netsuite/records/assembly_component_list'
73
+ autoload :AssemblyUnbuild, 'netsuite/records/assembly_unbuild'
69
74
  autoload :Account, 'netsuite/records/account'
70
75
  autoload :AccountingPeriod, 'netsuite/records/accounting_period'
71
76
  autoload :Address, 'netsuite/records/address'
@@ -76,7 +81,12 @@ module NetSuite
76
81
  autoload :BillingScheduleMilestoneList, 'netsuite/records/billing_schedule_milestone_list'
77
82
  autoload :BillingScheduleRecurrence, 'netsuite/records/billing_schedule_recurrence'
78
83
  autoload :BillingScheduleRecurrenceList, 'netsuite/records/billing_schedule_recurrence_list'
84
+ autoload :Bin, 'netsuite/records/bin'
85
+ autoload :BinNumber, 'netsuite/records/bin_number'
79
86
  autoload :BinNumberList, 'netsuite/records/bin_number_list'
87
+ autoload :BinTransfer, 'netsuite/records/bin_transfer'
88
+ autoload :BinTransferInventory, 'netsuite/records/bin_transfer_inventory'
89
+ autoload :BinTransferInventoryList, 'netsuite/records/bin_transfer_inventory_list'
80
90
  autoload :CashSale, 'netsuite/records/cash_sale'
81
91
  autoload :CashSaleItem, 'netsuite/records/cash_sale_item'
82
92
  autoload :CashSaleItemList, 'netsuite/records/cash_sale_item_list'
@@ -102,21 +112,33 @@ module NetSuite
102
112
  autoload :CustomerAddressbook, 'netsuite/records/customer_addressbook'
103
113
  autoload :CustomerAddressbookList, 'netsuite/records/customer_addressbook_list'
104
114
  autoload :CustomerCategory, 'netsuite/records/customer_category'
115
+ autoload :CustomerCreditCards, 'netsuite/records/customer_credit_cards'
116
+ autoload :CustomerCreditCardsList, 'netsuite/records/customer_credit_cards_list'
105
117
  autoload :CustomerCurrency, 'netsuite/records/customer_currency'
106
118
  autoload :CustomerCurrencyList, 'netsuite/records/customer_currency_list'
107
119
  autoload :CustomerDeposit, 'netsuite/records/customer_deposit'
120
+ autoload :CustomerDepositApplyList, 'netsuite/records/customer_deposit_apply_list'
121
+ autoload :CustomerDepositApply, 'netsuite/records/customer_deposit_apply'
108
122
  autoload :CustomerPartnersList, 'netsuite/records/customer_partners_list'
109
123
  autoload :CustomerPayment, 'netsuite/records/customer_payment'
110
124
  autoload :CustomerPaymentApply, 'netsuite/records/customer_payment_apply'
111
125
  autoload :CustomerPaymentApplyList, 'netsuite/records/customer_payment_apply_list'
126
+ autoload :CustomerPartner, 'netsuite/records/customer_partner'
112
127
  autoload :CustomerRefund, 'netsuite/records/customer_refund'
113
128
  autoload :CustomerRefundApply, 'netsuite/records/customer_refund_apply'
114
129
  autoload :CustomerRefundApplyList, 'netsuite/records/customer_refund_apply_list'
115
130
  autoload :CustomerRefundDeposit, 'netsuite/records/customer_refund_deposit'
116
131
  autoload :CustomerRefundDepositList, 'netsuite/records/customer_refund_deposit_list'
132
+ autoload :CustomerSubscription, 'netsuite/records/customer_subscription'
133
+ autoload :CustomerSubscriptionsList, 'netsuite/records/customer_subscriptions_list'
134
+ autoload :CustomerStatus, 'netsuite/records/customer_status'
117
135
  autoload :CustomerPartner, 'netsuite/records/customer_partner'
136
+ autoload :CustomerSalesTeam, 'netsuite/records/customer_sales_team'
137
+ autoload :CustomerSalesTeamList, 'netsuite/records/customer_sales_team_list'
118
138
  autoload :ContactList, 'netsuite/records/contact_list'
119
139
  autoload :Contact, 'netsuite/records/contact'
140
+ autoload :ContactAddressbook, 'netsuite/records/contact_addressbook'
141
+ autoload :ContactAddressbookList, 'netsuite/records/contact_addressbook_list'
120
142
  autoload :ContactRole, 'netsuite/records/contact_role'
121
143
  autoload :ContactAccessRoles, 'netsuite/records/contact_access_roles'
122
144
  autoload :ContactAccessRolesList, 'netsuite/records/contact_access_roles_list'
@@ -135,12 +157,22 @@ module NetSuite
135
157
  autoload :DiscountItem, 'netsuite/records/discount_item'
136
158
  autoload :Duration, 'netsuite/records/duration'
137
159
  autoload :Employee, 'netsuite/records/employee'
160
+ autoload :EntityCustomField, 'netsuite/records/entity_custom_field'
161
+ autoload :Estimate, 'netsuite/records/estimate'
162
+ autoload :EstimateItem, 'netsuite/records/estimate_item'
163
+ autoload :EstimateItemList, 'netsuite/records/estimate_item_list'
138
164
  autoload :File, 'netsuite/records/file'
139
165
  autoload :GiftCertificate, 'netsuite/records/gift_certificate'
140
166
  autoload :GiftCertificateItem, 'netsuite/records/gift_certificate_item'
141
167
  autoload :GiftCertRedemption, 'netsuite/records/gift_cert_redemption'
142
168
  autoload :GiftCertRedemptionList, 'netsuite/records/gift_cert_redemption_list'
143
169
  autoload :Folder, 'netsuite/records/folder'
170
+ autoload :InboundShipment, 'netsuite/records/inbound_shipment'
171
+ autoload :InboundShipmentItem, 'netsuite/records/inbound_shipment_item'
172
+ autoload :InboundShipmentItemList, 'netsuite/records/inbound_shipment_item_list'
173
+ autoload :InterCompanyJournalEntry, 'netsuite/records/inter_company_journal_entry'
174
+ autoload :InterCompanyJournalEntryLine, 'netsuite/records/inter_company_journal_entry_line'
175
+ autoload :InterCompanyJournalEntryLineList, 'netsuite/records/inter_company_journal_entry_line_list'
144
176
  autoload :InventoryAdjustment, 'netsuite/records/inventory_adjustment'
145
177
  autoload :InventoryAdjustmentInventory, 'netsuite/records/inventory_adjustment_inventory'
146
178
  autoload :InventoryAdjustmentInventoryList, 'netsuite/records/inventory_adjustment_inventory_list'
@@ -148,6 +180,9 @@ module NetSuite
148
180
  autoload :InventoryAssignmentList, 'netsuite/records/inventory_assignment_list'
149
181
  autoload :InventoryDetail, 'netsuite/records/inventory_detail'
150
182
  autoload :InventoryItem, 'netsuite/records/inventory_item'
183
+ autoload :InventoryNumber, 'netsuite/records/inventory_number'
184
+ autoload :InventoryNumberLocations, 'netsuite/records/inventory_number_locations'
185
+ autoload :InventoryNumberLocationsList, 'netsuite/records/inventory_number_locations_list'
151
186
  autoload :InventoryTransfer, 'netsuite/records/inventory_transfer'
152
187
  autoload :InventoryTransferInventory, 'netsuite/records/inventory_transfer_inventory'
153
188
  autoload :InventoryTransferInventoryList, 'netsuite/records/inventory_transfer_inventory_list'
@@ -175,8 +210,11 @@ module NetSuite
175
210
  autoload :KitItem, 'netsuite/records/kit_item'
176
211
  autoload :Location, 'netsuite/records/location'
177
212
  autoload :LocationsList, 'netsuite/records/locations_list'
213
+ autoload :LotNumberedAssemblyItem, 'netsuite/records/lot_numbered_assembly_item'
214
+ autoload :LotNumberedInventoryItem, 'netsuite/records/lot_numbered_inventory_item'
178
215
  autoload :MatrixOptionList, 'netsuite/records/matrix_option_list'
179
216
  autoload :MemberList, 'netsuite/records/member_list'
217
+ autoload :Message, 'netsuite/records/message'
180
218
  autoload :NonInventorySaleItem, 'netsuite/records/non_inventory_sale_item'
181
219
  autoload :NonInventoryPurchaseItem, 'netsuite/records/non_inventory_purchase_item'
182
220
  autoload :NonInventoryResaleItem, 'netsuite/records/non_inventory_resale_item'
@@ -191,8 +229,14 @@ module NetSuite
191
229
  autoload :PaymentMethod, 'netsuite/records/payment_method'
192
230
  autoload :PayrollItem, 'netsuite/records/payroll_item'
193
231
  autoload :PhoneCall, 'netsuite/records/phone_call'
232
+ autoload :Price, 'netsuite/records/price'
233
+ autoload :PriceLevel, 'netsuite/records/price_level'
234
+ autoload :PriceList, 'netsuite/records/price_list'
235
+ autoload :Pricing, 'netsuite/records/pricing'
194
236
  autoload :PricingMatrix, 'netsuite/records/pricing_matrix'
195
237
  autoload :PromotionCode, 'netsuite/records/promotion_code'
238
+ autoload :PromotionsList, 'netsuite/records/promotions_list'
239
+ autoload :Promotions, 'netsuite/records/promotions'
196
240
  autoload :PurchaseOrder, 'netsuite/records/purchase_order'
197
241
  autoload :PurchaseOrderItemList, 'netsuite/records/purchase_order_item_list'
198
242
  autoload :PurchaseOrderItem, 'netsuite/records/purchase_order_item'
@@ -203,24 +247,35 @@ module NetSuite
203
247
  autoload :RevRecSchedule, 'netsuite/records/rev_rec_schedule'
204
248
  autoload :RoleList, 'netsuite/records/role_list'
205
249
  autoload :ReturnAuthorization, 'netsuite/records/return_authorization'
250
+ autoload :ReturnAuthorizationItem, 'netsuite/records/return_authorization_item'
251
+ autoload :ReturnAuthorizationItemList, 'netsuite/records/return_authorization_item_list'
206
252
  autoload :SalesOrder, 'netsuite/records/sales_order'
207
253
  autoload :SalesOrderShipGroupList, 'netsuite/records/sales_order_ship_group_list'
208
254
  autoload :SalesOrderItem, 'netsuite/records/sales_order_item'
209
255
  autoload :SalesOrderItemList, 'netsuite/records/sales_order_item_list'
256
+ autoload :SalesRole, 'netsuite/records/sales_role'
210
257
  autoload :SalesTaxItem, 'netsuite/records/sales_tax_item'
211
258
  autoload :ServiceResaleItem, 'netsuite/records/service_resale_item'
212
259
  autoload :ServiceSaleItem, 'netsuite/records/service_sale_item'
260
+ autoload :SerializedAssemblyItem, 'netsuite/records/serialized_assembly_item'
213
261
  autoload :SerializedInventoryItem, 'netsuite/records/serialized_inventory_item'
262
+ autoload :SerializedInventoryItemNumbers, 'netsuite/records/serialized_inventory_item_numbers'
263
+ autoload :SerializedInventoryItemNumbersList, 'netsuite/records/serialized_inventory_item_numbers_list'
264
+ autoload :SerializedInventoryItemLocation, 'netsuite/records/serialized_inventory_item_location'
265
+ autoload :SerializedInventoryItemLocationsList, 'netsuite/records/serialized_inventory_item_locations_list'
214
266
  autoload :ShipAddress, 'netsuite/records/ship_address'
215
267
  autoload :SiteCategory, 'netsuite/records/site_category'
216
268
  autoload :Subsidiary, 'netsuite/records/subsidiary'
217
269
  autoload :SubtotalItem, 'netsuite/records/subtotal_item'
218
270
  autoload :SupportCase, 'netsuite/records/support_case'
271
+ autoload :SupportCaseType, 'netsuite/records/support_case_type'
219
272
  autoload :TaxType, 'netsuite/records/tax_type'
220
273
  autoload :TaxGroup, 'netsuite/records/tax_group'
221
274
  autoload :Task, 'netsuite/records/task'
222
275
  autoload :Term, 'netsuite/records/term'
223
276
  autoload :TimeBill, 'netsuite/records/time_bill'
277
+ autoload :TransactionBodyCustomField, 'netsuite/records/transaction_body_custom_field'
278
+ autoload :TransactionColumnCustomField, 'netsuite/records/transaction_column_custom_field'
224
279
  autoload :TransactionShipGroup, 'netsuite/records/transaction_ship_group'
225
280
  autoload :TransferOrder, 'netsuite/records/transfer_order'
226
281
  autoload :TransferOrderItemList, 'netsuite/records/transfer_order_item_list'
@@ -262,23 +317,4 @@ module NetSuite
262
317
  NetSuite::Configuration.instance_eval(&block)
263
318
  end
264
319
 
265
- def self.configure_from_env(&block)
266
- NetSuite.configure do
267
- reset!
268
-
269
- email ENV['NETSUITE_EMAIL'] unless ENV['NETSUITE_EMAIL'].nil?
270
- password ENV['NETSUITE_PASSWORD'] unless ENV['NETSUITE_PASSWORD'].nil?
271
- account ENV['NETSUITE_ACCOUNT'] unless ENV['NETSUITE_ACCOUNT'].nil?
272
- role ENV['NETSUITE_ROLE'] unless ENV['NETSUITE_ROLE'].nil?
273
- api_version ENV['NETSUITE_API'] unless ENV['NETSUITE_API'].nil?
274
- sandbox (ENV['NETSUITE_PRODUCTION'].nil? || ENV['NETSUITE_PRODUCTION'] != 'true')
275
- wsdl ENV['NETSUITE_WSDL'] unless ENV['NETSUITE_WSDL'].nil?
276
- silent (!ENV['NETSUITE_SILENT'].nil? && ENV['NETSUITE_SILENT'] == 'true')
277
-
278
- read_timeout 100_000
279
- end
280
-
281
- self.configure(&block) if block
282
- end
283
-
284
320
  end