netsuite 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,7 @@ require 'netsuite/support/requests'
23
23
  require 'netsuite/actions/add'
24
24
  require 'netsuite/actions/get'
25
25
  require 'netsuite/actions/initialize'
26
+ require 'netsuite/actions/update'
26
27
 
27
28
  # RECORDS
28
29
  require 'netsuite/records/bill_address'
@@ -38,6 +39,7 @@ require 'netsuite/records/non_inventory_sale_item'
38
39
  require 'netsuite/records/invoice_item'
39
40
  require 'netsuite/records/invoice_item_list'
40
41
  require 'netsuite/records/classification'
42
+ require 'netsuite/records/custom_record'
41
43
 
42
44
  module NetSuite
43
45
 
@@ -31,7 +31,7 @@ module NetSuite
31
31
  # </platformMsgs:add>
32
32
  # </soap:Body>
33
33
  def request_body
34
- {
34
+ hash = {
35
35
  'platformMsgs:record' => @obj.to_record,
36
36
  :attributes! => {
37
37
  'platformMsgs:record' => {
@@ -39,6 +39,13 @@ module NetSuite
39
39
  }
40
40
  }
41
41
  }
42
+ if @obj.respond_to?(:internal_id) && @obj.internal_id
43
+ hash[:attributes!]['platformMsgs:record']['platformMsgs:internalId'] = @obj.internal_id
44
+ end
45
+ if @obj.respond_to?(:external_id) && @obj.external_id
46
+ hash[:attributes!]['platformMsgs:record']['platformMsgs:externalId'] = @obj.external_id
47
+ end
48
+ hash
42
49
  end
43
50
 
44
51
  def success?
@@ -3,9 +3,9 @@ module NetSuite
3
3
  class Get
4
4
  include Support::Requests
5
5
 
6
- def initialize(id, klass)
7
- @id = id
8
- @klass = klass
6
+ def initialize(klass, options = {})
7
+ @klass = klass
8
+ @options = options
9
9
  end
10
10
 
11
11
  private
@@ -31,16 +31,19 @@ module NetSuite
31
31
  # </platformMsgs:get>
32
32
  # </soap:Body>
33
33
  def request_body
34
- {
34
+ body = {
35
35
  'platformMsgs:baseRef' => {},
36
36
  :attributes! => {
37
37
  'platformMsgs:baseRef' => {
38
- :externalId => @id,
39
- :type => soap_type,
40
- 'xsi:type' => 'platformCore:RecordRef'
38
+ 'xsi:type' => (@options[:custom] ? 'platformCore:CustomRecordRef' : 'platformCore:RecordRef')
41
39
  }
42
40
  }
43
41
  }
42
+ body[:attributes!]['platformMsgs:baseRef']['externalId'] = @options[:external_id] if @options[:external_id]
43
+ body[:attributes!]['platformMsgs:baseRef']['internalId'] = @options[:internal_id] if @options[:internal_id]
44
+ body[:attributes!]['platformMsgs:baseRef']['typeId'] = @options[:type_id] if @options[:type_id]
45
+ body[:attributes!]['platformMsgs:baseRef']['type'] = soap_type unless @options[:custom]
46
+ body
44
47
  end
45
48
 
46
49
  def success?
@@ -0,0 +1,60 @@
1
+ module NetSuite
2
+ module Actions
3
+ class Update
4
+ include Support::Requests
5
+
6
+ def initialize(obj = nil)
7
+ @obj = obj
8
+ end
9
+
10
+ def request
11
+ connection.request :platformMsgs, :update do
12
+ soap.namespaces['xmlns:platformMsgs'] = 'urn:messages_2011_2.platform.webservices.netsuite.com'
13
+ soap.namespaces['xmlns:platformCore'] = 'urn:core_2011_2.platform.webservices.netsuite.com'
14
+ soap.namespaces['xmlns:listRel'] = 'urn:relationships_2011_2.lists.webservices.netsuite.com'
15
+ soap.namespaces['xmlns:tranSales'] = 'urn:sales_2011_2.transactions.webservices.netsuite.com'
16
+ soap.namespaces['xmlns:platformCommon'] = 'urn:common_2011_2.platform.webservices.netsuite.com'
17
+ soap.namespaces['xmlns:listAcct'] = 'urn:accounting_2011_2.lists.webservices.netsuite.com'
18
+ soap.header = auth_header
19
+ soap.body = request_body
20
+ end
21
+ end
22
+
23
+ # <platformMsgs:update>
24
+ # <platformMsgs:record internalId="980" xsi:type="listRel:Customer">
25
+ # <listRel:companyName>Shutter Fly Corporation</listRel:companyName>
26
+ # </platformMsgs:record>
27
+ # </platformMsgs:update>
28
+ def request_body
29
+ hash = {
30
+ 'platformMsgs:record' => @obj.to_record,
31
+ :attributes! => {
32
+ 'platformMsgs:record' => {
33
+ 'xsi:type' => @obj.record_type
34
+ }
35
+ }
36
+ }
37
+ if @obj.respond_to?(:internal_id) && @obj.internal_id
38
+ hash[:attributes!]['platformMsgs:record']['platformMsgs:internalId'] = @obj.internal_id
39
+ end
40
+ if @obj.respond_to?(:external_id) && @obj.external_id
41
+ hash[:attributes!]['platformMsgs:record']['platformMsgs:externalId'] = @obj.external_id
42
+ end
43
+ hash
44
+ end
45
+
46
+ def success?
47
+ @success ||= response_hash[:status][:@is_success] == 'true'
48
+ end
49
+
50
+ def response_body
51
+ @response_body ||= response_hash[:base_ref]
52
+ end
53
+
54
+ def response_hash
55
+ @response_hash ||= @response.to_hash[:update_response][:write_response]
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -14,12 +14,12 @@ module NetSuite
14
14
  initialize_from_attributes_hash(attributes)
15
15
  end
16
16
 
17
- def self.get(id)
18
- response = Actions::Get.call(id, self)
17
+ def self.get(options = {})
18
+ response = Actions::Get.call(self, options)
19
19
  if response.success?
20
20
  new(response.body)
21
21
  else
22
- raise RecordNotFound, "#{self} with ID=#{id} could not be found"
22
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
23
23
  end
24
24
  end
25
25
 
@@ -0,0 +1,37 @@
1
+ module NetSuite
2
+ module Records
3
+ class CustomRecord
4
+ include Support::Fields
5
+
6
+ fields :allow_attachments, :allow_inline_editing, :allow_numbering_override, :allow_quick_search, :created,
7
+ :custom_record_id, :description, :disclaimer, :enabl_email_merge, :enable_numbering, :include_name,
8
+ :is_available_offline, :is_inactive, :is_numbering_updateable, :is_ordered, :last_modified, :name,
9
+ :numbering_current_number, :numbering_init, :numbering_min_digits, :numbering_prefix, :numbering_suffix,
10
+ :record_name, :script_id, :show_creation_date, :show_creation_date_on_list, :show_id, :show_last_modified_on_list,
11
+ :show_last_modified, :show_notes, :show_owner, :show_owner_allow_change, :show_owner_on_list, :use_permissions
12
+
13
+ def initialize(attributes = {})
14
+ initialize_from_attributes_hash(attributes)
15
+ end
16
+
17
+ def self.get(options = {})
18
+ options.merge!(:type_id => type_id) unless options[:type_id]
19
+ response = Actions::Get.call(self, options.merge!(:custom => true))
20
+ if response.success?
21
+ new(response.body)
22
+ else
23
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
24
+ end
25
+ end
26
+
27
+ def self.type_id(id = nil)
28
+ if id
29
+ @type_id = id
30
+ else
31
+ @type_id
32
+ end
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -6,23 +6,26 @@ module NetSuite
6
6
  include Support::Records
7
7
  include Namespaces::ListRel
8
8
 
9
- fields :access_role, :account_number, :addressbook_list, :aging, :alt_email, :alt_name, :alt_phone, :balance, :bill_pay,
9
+ fields :access_role, :account_number, :addressbook_list, :aging, :alt_email, :alt_name, :alt_phone, :bill_pay,
10
10
  :buying_reason, :buying_time_frame, :campaign_category, :category, :click_stream, :comments, :company_name,
11
- :consol_aging, :consol_balance, :consol_days_overdue, :consol_deposit_balance, :consol_overdue_balance,
12
- :consol_unbilled_orders, :contact_roles_list, :contrib_pct, :credit_cards_list, :credit_hold_override, :credit_limit,
11
+ :consol_aging, :consol_days_overdue,
12
+ :contact_roles_list, :contrib_pct, :credit_cards_list, :credit_hold_override, :credit_limit,
13
13
  :currency, :currency_list, :custom_field_list, :date_created, :days_overdue, :default_address,
14
- :deposit_balance, :download_list, :email, :email_preference, :email_transactions, :end_date, :entity_id,
14
+ :download_list, :email, :email_preference, :email_transactions, :end_date, :entity_id,
15
15
  :estimated_budget, :fax, :fax_transactions, :first_name, :first_visit, :give_access, :global_subscription_status,
16
16
  :group_pricing_list, :home_phone, :image, :is_budget_approved, :is_inactive, :is_person, :item_pricing_list, :keywords,
17
17
  :language, :last_modified, :last_name, :last_page_visited, :last_visit, :lead_source, :middle_name, :mobile_phone,
18
- :opening_balance, :opening_balance_account, :opening_balance_date, :overdue_balance, :parent, :partner, :partners_list,
18
+ :opening_balance, :opening_balance_account, :opening_balance_date, :parent, :partner, :partners_list,
19
19
  :password, :password_2, :phone, :phonetic_name, :pref_cc_processor, :price_level, :print_on_check_as,
20
20
  :print_transactions, :referrer, :reminder_days, :representing_subsidiary, :require_pwd_change, :resale_number,
21
21
  :sales_group, :sales_readiness, :sales_rep, :sales_team_list, :salutation, :send_email, :ship_complete, :shipping_item,
22
22
  :stage, :start_date, :subscriptions_list, :subsidiary, :sync_partner_teams, :tax_exempt, :tax_item, :taxable, :terms,
23
- :territory, :third_party_acct, :third_party_country, :third_party_zipcode, :title, :unbilled_orders, :url,
23
+ :territory, :third_party_acct, :third_party_country, :third_party_zipcode, :title, :url,
24
24
  :vat_reg_number, :visits, :web_lead
25
25
 
26
+ read_only_fields :balance, :consol_balance, :deposit_balance, :consol_deposit_balance, :overdue_balance,
27
+ :consol_overdue_balance, :unbilled_orders, :consol_unbilled_orders
28
+
26
29
  record_refs :custom_form, :entity_status
27
30
 
28
31
  attr_reader :internal_id
@@ -42,12 +45,12 @@ module NetSuite
42
45
  attributes[:addressbook_list] ||= CustomerAddressbookList.new
43
46
  end
44
47
 
45
- def self.get(id)
46
- response = Actions::Get.call(id, self)
48
+ def self.get(options = {})
49
+ response = Actions::Get.call(self, options)
47
50
  if response.success?
48
51
  new(response.body)
49
52
  else
50
- raise RecordNotFound, "#{self} with ID=#{id} could not be found"
53
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
51
54
  end
52
55
  end
53
56
 
@@ -6,7 +6,7 @@ module NetSuite
6
6
  include Support::Records
7
7
  include Namespaces::TranSales
8
8
 
9
- fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :balance, :bill_address,
9
+ fields :alt_handling_cost, :alt_shipping_cost, :balance, :bill_address,
10
10
  :billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name, :custom_field_list,
11
11
  :deferred_revenue, :department, :discount_amount, :discount_date, :discount_item, :discount_rate,
12
12
  :due_date, :email, :end_date, :est_gross_profit, :est_gross_profit_percent, :exchange_rate,
@@ -17,7 +17,7 @@ module NetSuite
17
17
  :item_cost_disc_rate, :item_cost_disc_tax_1_amt, :item_cost_disc_taxable, :item_cost_discount, :item_cost_list,
18
18
  :item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :job, :last_modified_date,
19
19
  :lead_source, :linked_tracking_numbers, :location, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
20
- :other_ref_name, :partner, :partners_list, :promo_code, :recognized_revenue, :rev_rec_end_date,
20
+ :other_ref_name, :partner, :partners_list, :promo_code, :rev_rec_end_date,
21
21
  :rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date,
22
22
  :sales_group, :sales_rep, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
23
23
  :ship_method, :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date,
@@ -27,7 +27,7 @@ module NetSuite
27
27
  :to_be_printed, :total_cost_estimate, :tracking_numbers, :tran_date, :tran_id, :tran_is_vsoe_bundle,
28
28
  :transaction_bill_address, :transaction_ship_address, :vat_reg_num, :vsoe_auto_calc
29
29
 
30
- read_only_fields :sub_total, :discount_total, :total
30
+ read_only_fields :sub_total, :discount_total, :total, :recognized_revenue, :amount_remaining, :amount_paid
31
31
 
32
32
  record_refs :account, :bill_address_list, :custom_form, :entity, :klass, :posting_period, :ship_address_list
33
33
 
@@ -60,12 +60,12 @@ module NetSuite
60
60
  attributes[:custom_field_list] = CustomFieldList.new(attrs)
61
61
  end
62
62
 
63
- def self.get(id)
64
- response = Actions::Get.call(id, self)
63
+ def self.get(options = {})
64
+ response = Actions::Get.call(self, options)
65
65
  if response.success?
66
66
  new(response.body)
67
67
  else
68
- raise RecordNotFound, "#{self} with ID=#{id} could not be found"
68
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
69
69
  end
70
70
  end
71
71
 
@@ -36,12 +36,12 @@ module NetSuite
36
36
  initialize_from_attributes_hash(attributes)
37
37
  end
38
38
 
39
- def self.get(id)
40
- response = Actions::Get.call(id, self)
39
+ def self.get(options = {})
40
+ response = Actions::Get.call(self, options)
41
41
  if response.success?
42
42
  new(response.body)
43
43
  else
44
- raise RecordNotFound, "#{self} with ID=#{id} could not be found"
44
+ raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
45
45
  end
46
46
  end
47
47
 
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.15'
2
+ VERSION = '0.0.16'
3
3
  end
@@ -17,11 +17,11 @@ describe NetSuite::Actions::Get do
17
17
  end
18
18
 
19
19
  it 'makes a valid request to the NetSuite API' do
20
- NetSuite::Actions::Get.call(1, NetSuite::Records::Customer)
20
+ NetSuite::Actions::Get.call(NetSuite::Records::Customer, :external_id => 1)
21
21
  end
22
22
 
23
23
  it 'returns a valid Response object' do
24
- response = NetSuite::Actions::Get.call(1, NetSuite::Records::Customer)
24
+ response = NetSuite::Actions::Get.call(NetSuite::Records::Customer, :external_id => 1)
25
25
  response.should be_kind_of(NetSuite::Response)
26
26
  end
27
27
  end
@@ -41,11 +41,11 @@ describe NetSuite::Actions::Get do
41
41
  end
42
42
 
43
43
  it 'makes a valid request to the NetSuite API' do
44
- NetSuite::Actions::Get.call(1, NetSuite::Records::Invoice)
44
+ NetSuite::Actions::Get.call(NetSuite::Records::Invoice, :external_id => 1)
45
45
  end
46
46
 
47
47
  it 'returns a valid Response object' do
48
- response = NetSuite::Actions::Get.call(1, NetSuite::Records::Invoice)
48
+ response = NetSuite::Actions::Get.call(NetSuite::Records::Invoice, :external_id => 1)
49
49
  response.should be_kind_of(NetSuite::Response)
50
50
  end
51
51
  end
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Actions::Update do
4
+
5
+ context 'Customer' do
6
+ let(:customer) do
7
+ NetSuite::Records::Customer.new(:entity_id => 'Shutter Fly', :company_name => 'Shutter Fly, Inc.')
8
+ end
9
+
10
+ before do
11
+ savon.expects(:update).with({
12
+ 'platformMsgs:record' => {
13
+ 'listRel:entityId' => 'Shutter Fly',
14
+ 'listRel:companyName' => 'Shutter Fly, Inc.'
15
+ },
16
+ :attributes! => {
17
+ 'platformMsgs:baseRef' => {
18
+ 'xsi:type' => 'listRel:Customer'
19
+ }
20
+ }
21
+ }).returns(:update_customer)
22
+ end
23
+
24
+ it 'makes a valid request to the NetSuite API' do
25
+ NetSuite::Actions::Update.call(customer)
26
+ end
27
+
28
+ it 'returns a valid Response object' do
29
+ response = NetSuite::Actions::Update.call(customer)
30
+ response.should be_kind_of(NetSuite::Response)
31
+ response.should be_success
32
+ end
33
+ end
34
+
35
+ context 'Invoice' do
36
+ let(:invoice) do
37
+ NetSuite::Records::Invoice.new(:source => 'Google', :total => 100.0)
38
+ end
39
+
40
+ before do
41
+ pending
42
+ savon.expects(:update).with({
43
+ 'platformMsgs:record' => {
44
+ 'listRel:source' => 'Google',
45
+ 'listRel:total' => 100.0
46
+ },
47
+ :attributes! => {
48
+ 'platformMsgs:baseRef' => {
49
+ 'xsi:type' => 'listRel:Invoice'
50
+ }
51
+ }
52
+ }).returns(:update_invoice)
53
+ end
54
+
55
+ it 'makes a valid request to the NetSuite API' do
56
+ NetSuite::Actions::Update.call(invoice)
57
+ end
58
+
59
+ it 'returns a valid Response object' do
60
+ response = NetSuite::Actions::Update.call(invoice)
61
+ response.should be_kind_of(NetSuite::Response)
62
+ response.should be_success
63
+ end
64
+ end
65
+
66
+ end
@@ -16,8 +16,8 @@ describe NetSuite::Records::Classification do
16
16
  let(:response) { NetSuite::Response.new(:success => true, :body => { :name => 'Retail' }) }
17
17
 
18
18
  it 'returns an Invoice instance populated with the data from the response object' do
19
- NetSuite::Actions::Get.should_receive(:call).with(10, NetSuite::Records::Classification).and_return(response)
20
- invoice = NetSuite::Records::Classification.get(10)
19
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Classification, :external_id => 10).and_return(response)
20
+ invoice = NetSuite::Records::Classification.get(:external_id => 10)
21
21
  invoice.should be_kind_of(NetSuite::Records::Classification)
22
22
  end
23
23
  end
@@ -26,10 +26,11 @@ describe NetSuite::Records::Classification do
26
26
  let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
27
27
 
28
28
  it 'raises a RecordNotFound exception' do
29
- NetSuite::Actions::Get.should_receive(:call).with(10, NetSuite::Records::Classification).and_return(response)
29
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Classification, :external_id => 10).and_return(response)
30
30
  lambda {
31
- NetSuite::Records::Classification.get(10)
32
- }.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Records::Classification with ID=10 could not be found')
31
+ NetSuite::Records::Classification.get(:external_id => 10)
32
+ }.should raise_error(NetSuite::RecordNotFound,
33
+ /NetSuite::Records::Classification with OPTIONS=(.*) could not be found/)
33
34
  end
34
35
  end
35
36
  end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::CustomRecord do
4
+ let(:record) { NetSuite::Records::CustomRecord.new }
5
+ #<element name="customForm" type="platformCore:RecordRef" minOccurs="0"/>
6
+ #<element name="owner" type="platformCore:RecordRef" minOccurs="0"/>
7
+ #<element name="recType" type="platformCore:RecordRef" minOccurs="0"/>
8
+ #<element name="customFieldList" type="platformCore:CustomFieldList" minOccurs="0"/>
9
+
10
+ it 'has all the right fields' do
11
+ [
12
+ :allow_attachments, :allow_inline_editing, :allow_numbering_override, :allow_quick_search, :created, :custom_record_id,
13
+ :description, :disclaimer, :enabl_email_merge, :enable_numbering, :include_name, :is_available_offline, :is_inactive,
14
+ :is_numbering_updateable, :is_ordered, :last_modified, :name, :numbering_current_number, :numbering_init,
15
+ :numbering_min_digits, :numbering_prefix, :numbering_suffix, :record_name, :script_id, :show_creation_date,
16
+ :show_creation_date_on_list, :show_id, :show_last_modified, :show_last_modified_on_list, :show_notes, :show_owner,
17
+ :show_owner_allow_change, :show_owner_on_list, :use_permissions
18
+ ].each do |field|
19
+ record.should have_field(field)
20
+ end
21
+ end
22
+
23
+ describe '.get' do
24
+ context 'when the response is successful' do
25
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :allow_quick_search => true }) }
26
+
27
+ it 'returns a Customer instance populated with the data from the response object' do
28
+ NetSuite::Actions::Get.should_receive(:call).
29
+ with(NetSuite::Records::CustomRecord, :external_id => 1, :type_id => nil, :custom => true).
30
+ and_return(response)
31
+ customer = NetSuite::Records::CustomRecord.get(:external_id => 1)
32
+ customer.should be_kind_of(NetSuite::Records::CustomRecord)
33
+ customer.allow_quick_search.should be_true
34
+ end
35
+ end
36
+
37
+ context 'when the response is unsuccessful' do
38
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
39
+
40
+ it 'raises a RecordNotFound exception' do
41
+ NetSuite::Actions::Get.should_receive(:call).
42
+ with(NetSuite::Records::CustomRecord, :external_id => 1, :type_id => nil, :custom => true).
43
+ and_return(response)
44
+ lambda {
45
+ NetSuite::Records::CustomRecord.get(:external_id => 1)
46
+ }.should raise_error(NetSuite::RecordNotFound,
47
+ /NetSuite::Records::CustomRecord with OPTIONS={(.*)} could not be found/)
48
+ end
49
+ end
50
+ end
51
+
52
+ end
@@ -59,8 +59,8 @@ describe NetSuite::Records::Customer do
59
59
  let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
60
60
 
61
61
  it 'returns a Customer instance populated with the data from the response object' do
62
- NetSuite::Actions::Get.should_receive(:call).with(1, NetSuite::Records::Customer).and_return(response)
63
- customer = NetSuite::Records::Customer.get(1)
62
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Customer, :external_id => 1).and_return(response)
63
+ customer = NetSuite::Records::Customer.get(:external_id => 1)
64
64
  customer.should be_kind_of(NetSuite::Records::Customer)
65
65
  customer.is_person.should be_true
66
66
  end
@@ -70,10 +70,11 @@ describe NetSuite::Records::Customer do
70
70
  let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
71
71
 
72
72
  it 'raises a RecordNotFound exception' do
73
- NetSuite::Actions::Get.should_receive(:call).with(1, NetSuite::Records::Customer).and_return(response)
73
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Customer, :external_id => 1).and_return(response)
74
74
  lambda {
75
- NetSuite::Records::Customer.get(1)
76
- }.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Records::Customer with ID=1 could not be found')
75
+ NetSuite::Records::Customer.get(:external_id => 1)
76
+ }.should raise_error(NetSuite::RecordNotFound,
77
+ /NetSuite::Records::Customer with OPTIONS=(.*) could not be found/)
77
78
  end
78
79
  end
79
80
  end
@@ -67,8 +67,8 @@ describe NetSuite::Records::Invoice do
67
67
  let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
68
68
 
69
69
  it 'returns an Invoice instance populated with the data from the response object' do
70
- NetSuite::Actions::Get.should_receive(:call).with(10, NetSuite::Records::Invoice).and_return(response)
71
- invoice = NetSuite::Records::Invoice.get(10)
70
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Invoice, :external_id => 10).and_return(response)
71
+ invoice = NetSuite::Records::Invoice.get(:external_id => 10)
72
72
  invoice.should be_kind_of(NetSuite::Records::Invoice)
73
73
  end
74
74
  end
@@ -77,10 +77,11 @@ describe NetSuite::Records::Invoice do
77
77
  let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
78
78
 
79
79
  it 'raises a RecordNotFound exception' do
80
- NetSuite::Actions::Get.should_receive(:call).with(10, NetSuite::Records::Invoice).and_return(response)
80
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::Invoice, :external_id => 10).and_return(response)
81
81
  lambda {
82
- NetSuite::Records::Invoice.get(10)
83
- }.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Records::Invoice with ID=10 could not be found')
82
+ NetSuite::Records::Invoice.get(:external_id => 10)
83
+ }.should raise_error(NetSuite::RecordNotFound,
84
+ /NetSuite::Records::Invoice with OPTIONS=(.*) could not be found/)
84
85
  end
85
86
  end
86
87
  end
@@ -42,8 +42,8 @@ describe NetSuite::Records::NonInventorySaleItem do
42
42
  let(:response) { NetSuite::Response.new(:success => true, :body => { :manufacturer_zip => '90401' }) }
43
43
 
44
44
  it 'returns a NonInventorySaleItem instance populated with the data from the response object' do
45
- NetSuite::Actions::Get.should_receive(:call).with(20, NetSuite::Records::NonInventorySaleItem).and_return(response)
46
- customer = NetSuite::Records::NonInventorySaleItem.get(20)
45
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::NonInventorySaleItem, :external_id => 20).and_return(response)
46
+ customer = NetSuite::Records::NonInventorySaleItem.get(:external_id => 20)
47
47
  customer.should be_kind_of(NetSuite::Records::NonInventorySaleItem)
48
48
  customer.manufacturer_zip.should eql('90401')
49
49
  end
@@ -53,10 +53,11 @@ describe NetSuite::Records::NonInventorySaleItem do
53
53
  let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
54
54
 
55
55
  it 'raises a RecordNotFound exception' do
56
- NetSuite::Actions::Get.should_receive(:call).with(20, NetSuite::Records::NonInventorySaleItem).and_return(response)
56
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::NonInventorySaleItem, :external_id => 20).and_return(response)
57
57
  lambda {
58
- NetSuite::Records::NonInventorySaleItem.get(20)
59
- }.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Records::NonInventorySaleItem with ID=20 could not be found')
58
+ NetSuite::Records::NonInventorySaleItem.get(:external_id => 20)
59
+ }.should raise_error(NetSuite::RecordNotFound,
60
+ /NetSuite::Records::NonInventorySaleItem with OPTIONS=(.*) could not be found/)
60
61
  end
61
62
  end
62
63
  end
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <soapenv:Header>
4
+ <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2011_2.platform.webservices.netsuite.com">
5
+ <platformMsgs:nsId>WEBSERVICES_3392464_011220127305624241236468140_8ef09e2dc9b2</platformMsgs:nsId>
6
+ </platformMsgs:documentInfo>
7
+ </soapenv:Header>
8
+ <soapenv:Body>
9
+ <updateResponse xmlns="urn:messages_2011_2.platform.webservices.netsuite.com">
10
+ <writeResponse>
11
+ <platformCore:status isSuccess="true" xmlns:platformCore="urn:core_2011_2.platform.webservices.netsuite.com"/>
12
+ <baseRef internalId="329" externalId="100001" type="customer" xsi:type="platformCore:RecordRef" xmlns:platformCore="urn:core_2011_2.platform.webservices.netsuite.com"/>
13
+ </writeResponse>
14
+ </updateResponse>
15
+ </soapenv:Body>
16
+ </soapenv:Envelope>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1
4
+ hash: 63
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 15
10
- version: 0.0.15
9
+ - 16
10
+ version: 0.0.16
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-12 00:00:00 Z
18
+ date: 2012-01-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon
@@ -103,6 +103,7 @@ files:
103
103
  - lib/netsuite/actions/add.rb
104
104
  - lib/netsuite/actions/get.rb
105
105
  - lib/netsuite/actions/initialize.rb
106
+ - lib/netsuite/actions/update.rb
106
107
  - lib/netsuite/configuration.rb
107
108
  - lib/netsuite/errors.rb
108
109
  - lib/netsuite/namespaces/list_acct.rb
@@ -114,6 +115,7 @@ files:
114
115
  - lib/netsuite/records/classification.rb
115
116
  - lib/netsuite/records/custom_field.rb
116
117
  - lib/netsuite/records/custom_field_list.rb
118
+ - lib/netsuite/records/custom_record.rb
117
119
  - lib/netsuite/records/customer.rb
118
120
  - lib/netsuite/records/customer_addressbook.rb
119
121
  - lib/netsuite/records/customer_addressbook_list.rb
@@ -134,11 +136,13 @@ files:
134
136
  - spec/netsuite/actions/add_spec.rb
135
137
  - spec/netsuite/actions/get_spec.rb
136
138
  - spec/netsuite/actions/initialize_spec.rb
139
+ - spec/netsuite/actions/update_spec.rb
137
140
  - spec/netsuite/configuration_spec.rb
138
141
  - spec/netsuite/records/bill_address_spec.rb
139
142
  - spec/netsuite/records/classification_spec.rb
140
143
  - spec/netsuite/records/custom_field_list_spec.rb
141
144
  - spec/netsuite/records/custom_field_spec.rb
145
+ - spec/netsuite/records/custom_record_spec.rb
142
146
  - spec/netsuite/records/customer_addressbook_list_spec.rb
143
147
  - spec/netsuite/records/customer_addressbook_spec.rb
144
148
  - spec/netsuite/records/customer_spec.rb
@@ -163,6 +167,8 @@ files:
163
167
  - spec/support/fixtures/get/get_customer.xml
164
168
  - spec/support/fixtures/get/get_invoice.xml
165
169
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml
170
+ - spec/support/fixtures/update/update_customer.xml
171
+ - spec/support/fixtures/update/update_invoice.xml
166
172
  - spec/support/read_only_field_matcher.rb
167
173
  - spec/support/record_ref_matcher.rb
168
174
  - spec/support/savon.rb
@@ -204,11 +210,13 @@ test_files:
204
210
  - spec/netsuite/actions/add_spec.rb
205
211
  - spec/netsuite/actions/get_spec.rb
206
212
  - spec/netsuite/actions/initialize_spec.rb
213
+ - spec/netsuite/actions/update_spec.rb
207
214
  - spec/netsuite/configuration_spec.rb
208
215
  - spec/netsuite/records/bill_address_spec.rb
209
216
  - spec/netsuite/records/classification_spec.rb
210
217
  - spec/netsuite/records/custom_field_list_spec.rb
211
218
  - spec/netsuite/records/custom_field_spec.rb
219
+ - spec/netsuite/records/custom_record_spec.rb
212
220
  - spec/netsuite/records/customer_addressbook_list_spec.rb
213
221
  - spec/netsuite/records/customer_addressbook_spec.rb
214
222
  - spec/netsuite/records/customer_spec.rb
@@ -233,6 +241,8 @@ test_files:
233
241
  - spec/support/fixtures/get/get_customer.xml
234
242
  - spec/support/fixtures/get/get_invoice.xml
235
243
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml
244
+ - spec/support/fixtures/update/update_customer.xml
245
+ - spec/support/fixtures/update/update_invoice.xml
236
246
  - spec/support/read_only_field_matcher.rb
237
247
  - spec/support/record_ref_matcher.rb
238
248
  - spec/support/savon.rb