netsuite 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -363,6 +363,18 @@ search.results_in_batches do |batch|
363
363
  puts Base64.decode64(file.content)
364
364
  end
365
365
  end
366
+
367
+ # the getList operation
368
+ NetSuite::Records::CustomRecord.get_list(
369
+ # netsuite internalIDs
370
+ list: [1,2,3],
371
+ # only needed for a custom record
372
+ type_id: 1234,
373
+ # allow inclomplete results (defaults to false)
374
+ allow_incomplete: true
375
+ ).each do |record|
376
+ # do your thing...
377
+ end
366
378
  ```
367
379
 
368
380
  #### Non-standard Operations
@@ -60,11 +60,17 @@ module NetSuite
60
60
 
61
61
  def response_body
62
62
  @response_body ||= @response.body[:get_list_response][:read_response_list][:read_response]
63
+ @response_body = [@response_body] unless @response_body.is_a? Array
64
+ @response_body
63
65
  end
64
66
 
65
67
  def success?
66
- # each returned record has its own status; for now if one fails, the entire operation has failed
67
- @success ||= response_body.detect { |r| r[:status][:@is_success] != 'true' }.nil?
68
+ # each returned record has its own status;
69
+ if @options[:allow_incomplete]
70
+ @success ||= !response_body.detect { |r| r[:status][:@is_success] == 'true' }.nil?
71
+ else
72
+ @success ||= response_body.detect { |r| r[:status][:@is_success] != 'true' }.nil?
73
+ end
68
74
  end
69
75
 
70
76
  module Support
@@ -77,8 +83,9 @@ module NetSuite
77
83
  response = NetSuite::Actions::GetList.call([self, options], credentials)
78
84
 
79
85
  if response.success?
80
- response.body.map do |record|
81
- new(record[:record])
86
+ response.body.inject([]) do |arr, record|
87
+ arr << new(record[:record]) unless record[:status][:@is_success] != 'true'
88
+ arr
82
89
  end
83
90
  else
84
91
  false
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :add, :delete, :search, :upsert
10
+ actions :get, :get_list, :add, :delete, :search, :upsert
11
11
 
12
12
  fields :acct_name, :acct_number, :acct_type, :cash_flow_rate, :cur_doc_num, :description, :eliminate, :exchange_rate,
13
13
  :general_rate, :include_children, :inventory, :is_inactive, :opening_balance, :revalue, :tran_date
@@ -6,7 +6,7 @@ module NetSuite
6
6
  include Support::Actions
7
7
  include Namespaces::ListAcct
8
8
 
9
- actions :get, :add, :delete, :upsert, :search
9
+ actions :get, :get_list, :add, :delete, :upsert, :search
10
10
 
11
11
  fields :allow_non_gl_changes, :end_date, :is_adjust, :is_quarter, :is_year, :period_name, :start_date
12
12
 
@@ -5,7 +5,7 @@ module NetSuite
5
5
  include Support::RecordRefs
6
6
  include Support::Actions
7
7
 
8
- actions :get, :search
8
+ actions :get, :get_list, :search
9
9
 
10
10
  fields :audience, :base_cost, :campaign_direct_mail_list, :campaign_email_list,
11
11
  :campaign_event_list, :campaign_id, :category, :conv_cost_per_customer, :conversions,
@@ -4,7 +4,7 @@ module NetSuite
4
4
  include Support::Fields
5
5
  include Support::Actions
6
6
 
7
- actions :get, :delete, :upsert
7
+ actions :get, :get_list, :delete, :upsert
8
8
 
9
9
  fields :name, :include_children, :is_inactive, :class_translation_list, :subsidiary_list, :custom_field_list
10
10
 
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListRel
9
9
 
10
- actions :get, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_list, :add, :delete, :search, :update, :upsert
11
11
 
12
12
  fields :salutation, :first_name, :middle_name, :last_name, :title, :phone, :fax, :email, :default_address,
13
13
  :entity_id, :phonetic_name, :alt_email, :office_phone, :home_phone, :mobile_phone, :supervisor_phone,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranCust
9
9
 
10
- actions :get, :add, :initialize, :delete, :update, :upsert
10
+ actions :get, :get_list, :add, :initialize, :delete, :update, :upsert
11
11
 
12
12
  fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :auto_apply, :balance,
13
13
  :bill_address, :contrib_pct, :created_date, :currency_name, :deferred_revenue, :discount_rate, :email,
@@ -5,7 +5,7 @@ module NetSuite
5
5
  include Support::RecordRefs
6
6
  include Support::Actions
7
7
 
8
- actions :get, :add, :delete, :upsert
8
+ actions :get, :get_list, :add, :delete, :upsert
9
9
 
10
10
  fields :allow_attachments, :allow_inline_editing, :allow_numbering_override, :allow_quick_search, :description,
11
11
  :disclaimer, :enable_mail_merge, :enable_numbering, :include_name, :is_available_offline, :is_inactive,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranCust
9
9
 
10
- actions :get, :initialize, :add, :delete, :upsert
10
+ actions :get, :get_list, :initialize, :add, :delete, :upsert
11
11
 
12
12
  fields :auth_code, :auto_apply, :cc_approved, :cc_avs_street_match, :cc_avs_zip_match,
13
13
  :cc_expire_date, :cc_name, :cc_number, :cc_security_code, :cc_security_code_match, :cc_street, :cc_zip_code,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranCust
9
9
 
10
- actions :get, :initialize, :add, :delete, :upsert
10
+ actions :get, :get_list, :initialize, :add, :delete, :upsert
11
11
 
12
12
  fields :address, :cc_approved, :cc_expire_date, :cc_name, :cc_number, :cc_street, :cc_zip_code, :charge_it,
13
13
  :created_date, :currency_name, :debit_card_issue_no, :exchange_rate, :last_modified_date, :memo, :pn_ref_num, :status,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranBank
9
9
 
10
- actions :get, :add, :delete, :upsert
10
+ actions :get, :get_list, :add, :delete, :upsert
11
11
 
12
12
  fields :created_date, :last_modified_date, :currency_name, :tran_id, :total, :tran_date, :memo, :to_be_printed
13
13
 
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :add, :delete, :upsert
10
+ actions :get, :get_list, :add, :delete, :upsert
11
11
 
12
12
  fields :available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :is_pretax,
13
13
  :item_id, :last_modified_date, :non_posting, :rate, :upc_code, :vendor_name
@@ -20,7 +20,7 @@ module NetSuite
20
20
  # }
21
21
  # ]
22
22
  #
23
- actions :get, :add, :delete, :search, :update, :upsert
23
+ actions :get, :get_list, :add, :delete, :search, :update, :upsert
24
24
 
25
25
  fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost,
26
26
  :copy_description, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :cost_units, :costing_method,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranSales
9
9
 
10
- actions :get, :initialize, :add, :delete, :upsert
10
+ actions :get, :get_list, :initialize, :add, :delete, :upsert
11
11
 
12
12
  fields :balance, :bill_address,
13
13
  :billing_schedule, :contrib_pct, :created_date, :currency_name, :custom_field_list,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranSales
9
9
 
10
- actions :get, :add, :initialize, :update, :delete, :search, :upsert
10
+ actions :get, :get_list, :add, :initialize, :update, :delete, :search, :upsert
11
11
 
12
12
  fields :tran_date, :tran_id, :shipping_cost, :memo, :ship_company, :ship_attention, :ship_addr1,
13
13
  :ship_addr2, :ship_city, :ship_state, :ship_zip, :ship_phone, :ship_is_residential,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListRel
9
9
 
10
- actions :get, :add, :delete, :update, :upsert
10
+ actions :get, :get_list, :add, :delete, :update, :upsert
11
11
 
12
12
  fields :account_number, :allocate_payroll_expenses, :allow_all_resources_for_tasks, :allow_expenses, :allow_time,
13
13
  :alt_name, :alt_phone, :bill_pay, :calculated_end_date, :calculated_end_date_baseline, :comments, :company_name,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranGeneral
9
9
 
10
- actions :get, :add, :delete, :upsert
10
+ actions :get, :get_list, :add, :delete, :upsert
11
11
 
12
12
  fields :approved, :created_date, :exchange_rate, :last_modified_date, :reversal_date, :reversal_defer, :reversal_entry,
13
13
  :tran_date, :tran_id
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :add, :delete, :search, :upsert
10
+ actions :get, :get_list, :add, :delete, :search, :upsert
11
11
 
12
12
  fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture,
13
13
  :created_date, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ActSched
9
9
 
10
- actions :get, :add, :delete, :update, :upsert
10
+ actions :get, :get_list, :add, :delete, :update, :upsert
11
11
 
12
12
  fields :title, :message, :phone, :status, :priority, :start_date, :end_date,
13
13
  :start_time, :end_time, :completed_date, :timed_event, :access_level, :timed_event
@@ -9,7 +9,7 @@ module NetSuite
9
9
  include Support::Actions
10
10
  include Namespaces::ListMkt
11
11
 
12
- actions :get, :add, :search, :delete, :update
12
+ actions :get, :get_list, :add, :search, :delete, :update
13
13
 
14
14
  fields :code, :code_pattern, :description, :discount_type, :display_line_discounts, :end_date,
15
15
  :exclude_items, :is_inactive, :is_public, :minimum_order_amount, :name, :number_to_generate,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranSales
9
9
 
10
- actions :get, :add, :initialize, :delete, :update, :upsert, :search
10
+ actions :get, :get_list, :add, :initialize, :delete, :update, :upsert, :search
11
11
 
12
12
  fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :auto_apply, :balance,
13
13
  :bill_address, :cc_approved, :contrib_pct, :created_date, :currency_name, :deferred_revenue, :discount_rate, :email, :end_date,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :add, :delete, :upsert
10
+ actions :get, :get_list, :add, :delete, :upsert
11
11
 
12
12
  fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date,
13
13
  :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description,
@@ -9,7 +9,7 @@ module NetSuite
9
9
 
10
10
  # https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2014_1/schema/record/sitecategory.html
11
11
 
12
- actions :get, :add, :delete, :update, :upsert, :search
12
+ actions :get, :get_list, :add, :delete, :update, :upsert, :search
13
13
 
14
14
  fields :description, :exclude_from_site_map, :is_inactive, :is_online,
15
15
  :item_id, :meta_tag_html, :page_title, :presentation_item_list,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListSupport
9
9
 
10
- actions :get, :add, :delete, :update, :upsert
10
+ actions :get, :get_list, :add, :delete, :update, :upsert
11
11
 
12
12
  fields :end_date, :incoming_message, :outgoing_message, :search_solution, :email_form,
13
13
  :internal_only, :title, :case_number, :start_date, :email, :phone, :inbound_email,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ActSched
9
9
 
10
- actions :get, :add, :search, :delete, :update, :upsert
10
+ actions :get, :get_list, :add, :search, :delete, :update, :upsert
11
11
 
12
12
  fields :title, :send_email, :message, :status, :access_level, :reminder_type,
13
13
  :reminder_minutes, :start_date, :end_date, :due_date, :timed_event,
@@ -5,7 +5,7 @@ module NetSuite
5
5
  include Support::RecordRefs
6
6
  include Support::Actions
7
7
 
8
- actions :get, :add, :delete, :upsert
8
+ actions :get, :get_list, :add, :delete, :upsert
9
9
 
10
10
  fields :due_next_month_if_within_days, :name, :date_driven, :days_until_expiry, :days_until_next_due,
11
11
  :day_discount_expires, :day_of_month_net_due, :discount_percent, :discount_percent_date_driven, :is_inactive,
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -0,0 +1 @@
1
+ # TODO needs to be tested
@@ -4,6 +4,24 @@ describe NetSuite::Actions::Search do
4
4
  before(:all) { savon.mock! }
5
5
  after(:all) { savon.unmock! }
6
6
 
7
+ it "handles custom auth credentials" do
8
+ allow(NetSuite::Configuration).to receive(:connection).and_return(double().as_null_object)
9
+
10
+ NetSuite::Records::Customer.search({}, {
11
+ email: 'fake@domain.com',
12
+ password: 'fake'
13
+ })
14
+
15
+ expect(NetSuite::Configuration).to have_received(:connection).with({:soap_header=>{
16
+ "platformMsgs:passport"=>{
17
+ "platformCore:email"=>"fake@domain.com",
18
+ "platformCore:password"=>"fake",
19
+ "platformCore:account"=>"1234",
20
+ "platformCore:role"=>{:@internalId=>"3"}
21
+ }, "platformMsgs:SearchPreferences"=>{}}}
22
+ )
23
+ end
24
+
7
25
  context "search class name" do
8
26
  it "infers class name if class doesn't specify search class" do
9
27
  instance = described_class.new NetSuite::Records::Customer
@@ -189,4 +189,18 @@ describe NetSuite::Configuration do
189
189
  end
190
190
  end
191
191
 
192
+ describe "#credentials" do
193
+ context "when none are defined" do
194
+ skip "should properly create the auth credentials" do
195
+
196
+ end
197
+ end
198
+
199
+ context "when they are defined" do
200
+ it "should properly replace the default auth credentials" do
201
+
202
+ end
203
+ end
204
+ end
205
+
192
206
  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.3.1
4
+ version: 0.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-12-26 00:00:00.000000000 Z
13
+ date: 2014-12-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: savon
@@ -220,6 +220,7 @@ files:
220
220
  - netsuite.gemspec
221
221
  - spec/netsuite/actions/add_spec.rb
222
222
  - spec/netsuite/actions/delete_spec.rb
223
+ - spec/netsuite/actions/get_list_spec.rb
223
224
  - spec/netsuite/actions/get_spec.rb
224
225
  - spec/netsuite/actions/initialize_spec.rb
225
226
  - spec/netsuite/actions/search_spec.rb
@@ -366,6 +367,7 @@ summary: NetSuite SuiteTalk API (SOAP) Wrapper
366
367
  test_files:
367
368
  - spec/netsuite/actions/add_spec.rb
368
369
  - spec/netsuite/actions/delete_spec.rb
370
+ - spec/netsuite/actions/get_list_spec.rb
369
371
  - spec/netsuite/actions/get_spec.rb
370
372
  - spec/netsuite/actions/initialize_spec.rb
371
373
  - spec/netsuite/actions/search_spec.rb