netsuite 0.8.0 → 0.8.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
  SHA1:
3
- metadata.gz: c8c286d33279948996df71637831759f30d28a50
4
- data.tar.gz: c3dc58125830de21646b4fcaf905b8c25dd6793e
3
+ metadata.gz: d4bb44590fe53e0928b8a73374fe80b794ed3395
4
+ data.tar.gz: c868924983bf5cdef3b8c831d577cef5f6d73ced
5
5
  SHA512:
6
- metadata.gz: 654d04316831d5d9e889a22351690bd319a5383b5ef7f4a7575789021b11833bcb6ecbf92dd0d7a462b3ca374404d19ae64a30d0a69e8f183e6fb4720dd8ee83
7
- data.tar.gz: 80490066ecb5c094666622be4300294c45ccf14794a7ca853135e798d1dd317b1806945559edf06e71cc9c2d88523cd8757f61695f6153293ceb1596c3a0eeea
6
+ metadata.gz: 1808362014a5493c6a5ef4fd513ce3e1041c1f6afcde57323f46be0daf2d7b8f1e22675637a4c08e7c2ac601a287914e2330251e8f8a66ac636859ca5917e95e
7
+ data.tar.gz: bcf26630f116004671779737e434c6e46d5c33bfb2d283b189e46cc88d620fad567d9b97783e0b65c0f7b7c20d6b5cf9860537a27f9cc3dba4208fa3a44274de
data/README.md CHANGED
@@ -73,6 +73,16 @@ NetSuite.configure do
73
73
  end
74
74
  ```
75
75
 
76
+ If you'd like to use a API endpoints greater than 2015_1 you'll need to specify an application ID:
77
+
78
+ ```
79
+ NetSuite::Configuration.soap_header = {
80
+ 'platformMsgs:ApplicationInfo' => {
81
+ 'platformMsgs:applicationId' => 'your-netsuite-app-id'
82
+ }
83
+ }
84
+ ```
85
+
76
86
  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/).
77
87
 
78
88
  ```ruby
@@ -87,7 +97,7 @@ NetSuite.configure do
87
97
  token_secret ENV['NETSUITE_TOKEN_SECRET']
88
98
 
89
99
  # oauth does not work with API versions less than 2015_2
90
- api_version '2015_2'
100
+ api_version '2016_2'
91
101
  end
92
102
  ```
93
103
 
@@ -137,6 +147,19 @@ NetSuite::Records::BaseRefList.get_select_value(
137
147
  field: 'taxSchedule'
138
148
  )
139
149
 
150
+ # get options for a custom sublist field (i.e. transaction column fields)
151
+ NetSuite::Records::BaseRefList.get_select_value(
152
+ field: 'custcol69_2',
153
+ sublist: 'itemList',
154
+ recordType: 'salesOrder'
155
+ )
156
+
157
+ # output names of options available for a custom field
158
+ options = NetSuite::Records::BaseRefList.get_select_value(
159
+ field: 'custbody_order_source',
160
+ recordType: 'invoice'
161
+ )
162
+ options.base_refs.map(&:name)
140
163
  ```
141
164
 
142
165
  #### Custom Records & Fields
@@ -206,6 +229,10 @@ search = NetSuite::Records::Customer.search({
206
229
 
207
230
  `open https://system.netsuite.com/app/common/entity/custjob.nl?id=#{search.results.first.internal_id}`
208
231
 
232
+ # find the avalara tax item. Some records don't support search.
233
+ all_sales_taxes = NetSuite::Utilities.backoff { NetSuite::Records::SalesTaxItem.get_all }
234
+ ns_tax_code = all_sales_taxes.detect { |st| st.item_id == 'AVATAX' }
235
+
209
236
  # searching for custom records
210
237
  NetSuite::Records::CustomRecord.search(
211
238
  basic: [
@@ -490,13 +517,3 @@ states = NetSuite::Configuration.connection.call(:get_all, message: {
490
517
  })
491
518
  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] } }
492
519
  ```
493
-
494
- #### 2015_2 ApplicationId Support
495
-
496
- ```ruby
497
- NetSuite::Configuration.soap_header = {
498
- 'platformMsgs:ApplicationInfo' => {
499
- 'platformMsgs:applicationId' => 'your-netsuite-app-id'
500
- }
501
- }
502
- ```
@@ -212,6 +212,8 @@ module NetSuite
212
212
  autoload :RevRecSchedule, 'netsuite/records/rev_rec_schedule'
213
213
  autoload :RoleList, 'netsuite/records/role_list'
214
214
  autoload :ReturnAuthorization, 'netsuite/records/return_authorization'
215
+ autoload :ReturnAuthorizationItem, 'netsuite/records/return_authorization_item'
216
+ autoload :ReturnAuthorizationItemList, 'netsuite/records/return_authorization_item_list'
215
217
  autoload :SalesOrder, 'netsuite/records/sales_order'
216
218
  autoload :SalesOrderShipGroupList, 'netsuite/records/sales_order_ship_group_list'
217
219
  autoload :SalesOrderItem, 'netsuite/records/sales_order_item'
@@ -27,14 +27,10 @@ module NetSuite
27
27
  # </platformCore:wsRoleList>
28
28
 
29
29
  def self.call(credentials)
30
- passport = NetSuite::Configuration.auth_header.dup
31
- passport['platformMsgs:passport']['platformCore:email'] = credentials[:email] || ''
32
- passport['platformMsgs:passport']['platformCore:password'] = credentials[:password] || ''
33
- passport['platformMsgs:passport']['platformCore:role'] = credentials[:role] || ''
34
- passport['platformMsgs:passport']['platformCore:account'] = credentials[:account] if !credentials[:account].nil?
30
+ passport = NetSuite::Configuration.auth_header(credentials).dup
35
31
 
36
32
  begin
37
- response = NetSuite::Configuration.connection(soap_header: {}).call :login, message: passport
33
+ response = NetSuite::Configuration.connection(soap_header: {}).call(:login, message: passport)
38
34
  rescue Savon::SOAPFault => e
39
35
  error_details = e.to_hash[:fault]
40
36
 
@@ -19,7 +19,7 @@ module NetSuite
19
19
  'platformCore:token' => token_id,
20
20
  'platformCore:nonce' => nonce,
21
21
  'platformCore:timestamp' => timestamp,
22
- 'platformCore:signature' => signature,
22
+ 'platformCore:signature' => signature.strip,
23
23
  :attributes! => { 'platformCore:signature' => { 'algorithm' => 'HMAC-SHA256' } }
24
24
  }
25
25
  }
@@ -13,14 +13,15 @@ module NetSuite
13
13
  actions :get, :get_list, :search
14
14
 
15
15
  fields :base_currency, :effective_date, :exchange_rate, :transaction_currency
16
-
16
+
17
17
  record_refs :base_currency, :transaction_currency
18
-
18
+
19
19
  #field :base_currency, Currency
20
20
  #field :transaction_currency, Currency
21
21
 
22
22
  attr_reader :internal_id
23
23
  attr_accessor :external_id
24
+ attr_accessor :search_joins
24
25
 
25
26
  def initialize(attributes = {})
26
27
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -31,4 +32,4 @@ module NetSuite
31
32
 
32
33
  end
33
34
  end
34
- end
35
+ end
@@ -6,16 +6,6 @@ module NetSuite
6
6
  include Support::Records
7
7
  include Namespaces::TranBank
8
8
 
9
- # <element name="entity" type="platformCore:RecordRef" minOccurs="0"/>
10
- # <element name="amount" type="xsd:double" minOccurs="0"/>
11
- # <element name="account" type="platformCore:RecordRef" minOccurs="0"/>
12
- # <element name="paymentMethod" type="platformCore:RecordRef" minOccurs="0"/>
13
- # <element name="refNum" type="xsd:string" minOccurs="0"/>
14
- # <element name="department" type="platformCore:RecordRef" minOccurs="0"/>
15
- # <element name="class" type="platformCore:RecordRef" minOccurs="0"/>
16
- # <element name="location" type="platformCore:RecordRef" minOccurs="0"/>
17
- # <element name="memo" type="xsd:string" minOccurs="0"/>
18
-
19
9
  fields :amount, :ref_num, :memo
20
10
 
21
11
  record_refs :entity, :account, :payment_method, :department, :klass, :location
@@ -13,7 +13,7 @@ module NetSuite
13
13
 
14
14
  fields :balance, :bill_address,
15
15
  :billing_schedule, :contrib_pct, :created_date, :currency_name, :custom_field_list,
16
- :deferred_revenue, :discount_amount, :discount_date, :discount_item, :discount_rate,
16
+ :deferred_revenue, :discount_amount, :discount_date, :discount_rate,
17
17
  :due_date, :email, :end_date, :est_gross_profit, :est_gross_profit_percent, :exchange_rate,
18
18
  :exclude_commission, :exp_cost_disc_amount, :exp_cost_disc_print, :exp_cost_disc_rate, :exp_cost_disc_tax_1_amt,
19
19
  :exp_cost_disc_taxable, :exp_cost_discount, :exp_cost_list, :exp_cost_tax_code, :exp_cost_tax_rate_1,
@@ -44,7 +44,7 @@ module NetSuite
44
44
 
45
45
  record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass, :partner,
46
46
  :posting_period, :ship_address_list, :terms, :location, :sales_rep, :tax_item, :created_from,
47
- :ship_method, :lead_source, :promo_code, :subsidiary, :currency, :approval_status, :job
47
+ :ship_method, :lead_source, :promo_code, :subsidiary, :currency, :approval_status, :job, :discount_item
48
48
 
49
49
  attr_reader :internal_id
50
50
  attr_accessor :external_id
@@ -5,7 +5,7 @@ module NetSuite
5
5
  include Support::RecordRefs
6
6
  include Support::Records
7
7
  include Support::Actions
8
- include Namespaces::TranSales
8
+ include Namespaces::TranCust
9
9
 
10
10
  # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2015_2/schema/record/returnauthorization.html
11
11
 
@@ -103,9 +103,10 @@ module NetSuite
103
103
  # :partners_list,
104
104
  # :sales_team_list,
105
105
  # :ship_address_list,
106
-
106
+
107
107
  field :billing_address, Address
108
108
  field :custom_field_list, CustomFieldList
109
+ field :item_list, ReturnAuthorizationItemList
109
110
 
110
111
  attr_reader :internal_id
111
112
  attr_accessor :external_id
@@ -0,0 +1,43 @@
1
+ module NetSuite
2
+ module Records
3
+ class ReturnAuthorizationItem
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::TranCust
8
+
9
+ fields :alt_sales_amt, :amortization_period, :amortization_type, :amount, :bill_variance_status, :catch_up_period,
10
+ :cost_estimate, :cost_estimate_rate, :cost_estimate_type, :days_before_expiration, :defer_rev_rec, :description,
11
+ :gift_cert_from, :gift_cert_message, :gift_cert_recipient_email, :gift_cert_recipient_name, :id, :inventory_detail,
12
+ :is_closed, :is_drop_shipment, :is_taxable, :is_vsoe_bundle, :item_subtype, :item_type, :line, :line_number,
13
+ :matrix_type, :options, :print_items, :quantity, :quantity_billed, :quantity_received, :quantity_rev_committed,
14
+ :rate, :rate_schedule, :rev_rec_end_date, :rev_rec_start_date, :tax_rate1, :vsoe_allocation, :vsoe_amount,
15
+ :vsoe_deferral, :vsoe_delivered, :vsoe_is_estimate, :vsoe_permit_discount, :vsoe_price, :vsoe_sop_group
16
+
17
+ field :custom_field_list, CustomFieldList
18
+
19
+ record_refs :department, :item, :job, :klass, :location, :price, :rev_rec_schedule, :tax_code, :units
20
+
21
+ def initialize(attributes_or_record = {})
22
+ case attributes_or_record
23
+ when Hash
24
+ initialize_from_attributes_hash(attributes_or_record)
25
+ when self.class
26
+ initialize_from_record(attributes_or_record)
27
+ end
28
+ end
29
+
30
+ def initialize_from_record(record)
31
+ self.attributes = record.send(:attributes)
32
+ end
33
+
34
+ def to_record
35
+ rec = super
36
+ if rec["#{record_namespace}:customFieldList"]
37
+ rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
38
+ end
39
+ rec
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,11 @@
1
+ module NetSuite
2
+ module Records
3
+ class ReturnAuthorizationItemList < Support::Sublist
4
+ include Namespaces::TranCust
5
+
6
+ sublist :item, ReturnAuthorizationItem
7
+
8
+ alias :items :item
9
+ end
10
+ end
11
+ end
@@ -27,6 +27,7 @@ module NetSuite
27
27
 
28
28
  attr_reader :internal_id
29
29
  attr_accessor :external_id
30
+ attr_accessor :search_joins
30
31
 
31
32
  def initialize(attributes = {})
32
33
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -7,7 +7,9 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search
10
+ # NOTE search not available on TaxGroup!
11
+
12
+ actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search, :get_all
11
13
 
12
14
  fields :city, :county, :description, :include_children, :is_default, :is_inactive,
13
15
  :item_id, :piggyback, :rate, :state, :subsidiary_list, :unitprice1, :unitprice2,
@@ -34,6 +34,7 @@ module NetSuite
34
34
 
35
35
  attr_reader :internal_id
36
36
  attr_accessor :external_id
37
+ attr_accessor :search_joins
37
38
 
38
39
  def initialize(attributes = {})
39
40
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
@@ -234,7 +234,8 @@ module NetSuite
234
234
  'UG' => '_uganda',
235
235
  'UA' => '_ukraine',
236
236
  'AE' => '_unitedArabEmirates',
237
- 'GB' => '_unitedKingdomGB',
237
+ # NOTE GB country code changed on 2016_1
238
+ 'GB' => NetSuite::Configuration.api_version <= "2015_2" ? '_unitedKingdomGB' : '_unitedKingdom',
238
239
  'US' => '_unitedStates',
239
240
  'UY' => '_uruguay',
240
241
  'UM' => '_uSMinorOutlyingIslands',
@@ -56,7 +56,8 @@ module NetSuite
56
56
  Savon::SOAPFault,
57
57
  Savon::InvalidResponseError,
58
58
  Zlib::BufError,
59
- Savon::HTTPError
59
+ Savon::HTTPError,
60
+ SocketError,
60
61
  ]
61
62
 
62
63
  # available in ruby > 1.9
@@ -65,9 +66,12 @@ module NetSuite
65
66
  end
66
67
 
67
68
  # available in ruby > 2.2.0
68
- if defined?(OpenSSL::SSL::SSLErrorWaitReadable)
69
- exceptions_to_retry << OpenSSL::SSL::SSLErrorWaitReadable
70
- end
69
+ exceptions_to_retry << IO::EINPROGRESSWaitWritable if defined?(IO::EINPROGRESSWaitWritable)
70
+ exceptions_to_retry << OpenSSL::SSL::SSLErrorWaitReadable if defined?(OpenSSL::SSL::SSLErrorWaitReadable)
71
+
72
+ # depends on the http library chosen
73
+ exceptions_to_retry << Excon::Error::Timeout if defined?(Excon::Error::Timeout)
74
+ exceptions_to_retry << Excon::Error::Socket if defined?(Excon::Error::Socket)
71
75
 
72
76
  if !exceptions_to_retry.include?(e.class)
73
77
  raise
@@ -215,7 +219,7 @@ module NetSuite
215
219
  end
216
220
 
217
221
  # http://mikebian.co/notes-on-dates-timezones-with-netsuites-suitetalk-api/
218
- # assumes input is UTC0 unix timestamp
222
+ # assumes UTC0 unix timestamp
219
223
  def normalize_time_to_netsuite_date(unix_timestamp)
220
224
  # convert to date to eliminate hr/min/sec
221
225
  time = Time.at(unix_timestamp).utc.to_date.to_datetime
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ReturnAuthorizationItemList do
4
+ let(:list) { NetSuite::Records::ReturnAuthorizationItemList.new }
5
+
6
+ it 'has a items attribute' do
7
+ expect(list.items).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.items << NetSuite::Records::ReturnAuthorizationItem.new(
13
+ :rate => 10
14
+ )
15
+ end
16
+
17
+ it 'can represent itself as a SOAP record' do
18
+ record = {
19
+ 'tranSales:item' => [{
20
+ 'tranSales:rate' => 10
21
+ }]
22
+ }
23
+ expect(list.to_record).to eql(record)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ReturnAuthorizationItem do
4
+ let(:item) { NetSuite::Records::ReturnAuthorizationItem.new }
5
+
6
+ it 'has all the right fields' do
7
+ [
8
+ :alt_sales_amt, :amortization_period, :amortization_type, :amount, :bill_variance_status, :catch_up_period, :cost_estimate,
9
+ :cost_estimate_rate, :cost_estimate_type, :days_before_expiration, :defer_rev_rec, :description, :gift_cert_from, :gift_cert_message,
10
+ :gift_cert_recipient_email, :gift_cert_recipient_name, :id, :inventory_detail, :is_closed, :is_drop_shipment, :is_taxable,
11
+ :is_vsoe_bundle, :item_subtype, :item_type, :line, :line_number, :matrix_type, :options, :print_items,
12
+ :quantity, :quantity_billed, :quantity_received, :quantity_rev_committed, :rate, :rate_schedule, :rev_rec_end_date,
13
+ :rev_rec_start_date, :tax_rate1, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_is_estimate,
14
+ :vsoe_permit_discount, :vsoe_price, :vsoe_sop_group
15
+ ].each do |field|
16
+ expect(item).to have_field(field)
17
+ end
18
+ end
19
+
20
+ it 'has all the right record refs' do
21
+ [
22
+ :department, :item, :job, :klass, :location, :price, :rev_rec_schedule, :tax_code, :units
23
+ ].each do |record_ref|
24
+ expect(item).to have_record_ref(record_ref)
25
+ end
26
+ end
27
+
28
+ describe '#options' do
29
+ it 'can be set from attributes'
30
+ it 'can be set from a CustomFieldList object'
31
+ end
32
+
33
+ describe '#inventory_detail' do
34
+ it 'can be set from attributes'
35
+ it 'can be set from an InventoryDetail object'
36
+ end
37
+
38
+ describe '#custom_field_list' do
39
+ it 'can be set from attributes'
40
+ it 'can be set from a CustomFieldList object'
41
+ end
42
+
43
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-22 00:00:00.000000000 Z
12
+ date: 2017-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
@@ -238,6 +238,8 @@ files:
238
238
  - lib/netsuite/records/record_ref.rb
239
239
  - lib/netsuite/records/record_ref_list.rb
240
240
  - lib/netsuite/records/return_authorization.rb
241
+ - lib/netsuite/records/return_authorization_item.rb
242
+ - lib/netsuite/records/return_authorization_item_list.rb
241
243
  - lib/netsuite/records/rev_rec_schedule.rb
242
244
  - lib/netsuite/records/rev_rec_template.rb
243
245
  - lib/netsuite/records/role_list.rb
@@ -404,6 +406,8 @@ files:
404
406
  - spec/netsuite/records/pomo_code_spec.rb
405
407
  - spec/netsuite/records/pricing_matrix_spec.rb
406
408
  - spec/netsuite/records/record_ref_spec.rb
409
+ - spec/netsuite/records/return_authorization_item_list_spec.rb
410
+ - spec/netsuite/records/return_authorization_item_spec.rb
407
411
  - spec/netsuite/records/rev_rec_template_spec.rb
408
412
  - spec/netsuite/records/sales_order_item_list_spec.rb
409
413
  - spec/netsuite/records/sales_order_item_spec.rb
@@ -596,6 +600,8 @@ test_files:
596
600
  - spec/netsuite/records/pomo_code_spec.rb
597
601
  - spec/netsuite/records/pricing_matrix_spec.rb
598
602
  - spec/netsuite/records/record_ref_spec.rb
603
+ - spec/netsuite/records/return_authorization_item_list_spec.rb
604
+ - spec/netsuite/records/return_authorization_item_spec.rb
599
605
  - spec/netsuite/records/rev_rec_template_spec.rb
600
606
  - spec/netsuite/records/sales_order_item_list_spec.rb
601
607
  - spec/netsuite/records/sales_order_item_spec.rb