netsuite 0.0.26 → 0.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. data/lib/netsuite.rb +1 -0
  2. data/lib/netsuite/actions/add.rb +8 -8
  3. data/lib/netsuite/actions/delete.rb +53 -0
  4. data/lib/netsuite/records/account.rb +1 -1
  5. data/lib/netsuite/records/classification.rb +1 -1
  6. data/lib/netsuite/records/credit_memo.rb +1 -1
  7. data/lib/netsuite/records/custom_record.rb +1 -1
  8. data/lib/netsuite/records/custom_record_type.rb +1 -1
  9. data/lib/netsuite/records/customer.rb +1 -1
  10. data/lib/netsuite/records/customer_payment.rb +1 -1
  11. data/lib/netsuite/records/customer_refund.rb +6 -1
  12. data/lib/netsuite/records/inventory_item.rb +1 -1
  13. data/lib/netsuite/records/invoice.rb +1 -1
  14. data/lib/netsuite/records/job.rb +1 -1
  15. data/lib/netsuite/records/journal_entry.rb +1 -1
  16. data/lib/netsuite/support/actions.rb +11 -0
  17. data/lib/netsuite/support/requests.rb +3 -3
  18. data/lib/netsuite/version.rb +1 -1
  19. data/spec/netsuite/actions/delete_spec.rb +34 -0
  20. data/spec/netsuite/records/account_spec.rb +56 -0
  21. data/spec/netsuite/records/classification_spec.rb +28 -0
  22. data/spec/netsuite/records/credit_memo_spec.rb +28 -0
  23. data/spec/netsuite/records/custom_record_spec.rb +25 -1
  24. data/spec/netsuite/records/custom_record_type_spec.rb +48 -0
  25. data/spec/netsuite/records/customer_payment_spec.rb +25 -1
  26. data/spec/netsuite/records/customer_refund_spec.rb +27 -1
  27. data/spec/netsuite/records/customer_spec.rb +24 -0
  28. data/spec/netsuite/records/inventory_item_spec.rb +24 -0
  29. data/spec/netsuite/records/invoice_spec.rb +26 -0
  30. data/spec/netsuite/records/job_spec.rb +24 -0
  31. data/spec/netsuite/records/journal_entry_spec.rb +24 -0
  32. data/spec/support/fixtures/delete/delete_customer.xml +16 -0
  33. metadata +9 -4
@@ -30,6 +30,7 @@ module NetSuite
30
30
 
31
31
  module Actions
32
32
  autoload :Add, 'netsuite/actions/add'
33
+ autoload :Delete, 'netsuite/actions/delete'
33
34
  autoload :Get, 'netsuite/actions/get'
34
35
  autoload :Initialize, 'netsuite/actions/initialize'
35
36
  autoload :Update, 'netsuite/actions/update'
@@ -3,8 +3,8 @@ module NetSuite
3
3
  class Add
4
4
  include Support::Requests
5
5
 
6
- def initialize(obj = nil)
7
- @obj = obj
6
+ def initialize(object = nil)
7
+ @object = object
8
8
  end
9
9
 
10
10
  private
@@ -33,18 +33,18 @@ module NetSuite
33
33
  # </soap:Body>
34
34
  def request_body
35
35
  hash = {
36
- 'platformMsgs:record' => @obj.to_record,
36
+ 'platformMsgs:record' => @object.to_record,
37
37
  :attributes! => {
38
38
  'platformMsgs:record' => {
39
- 'xsi:type' => @obj.record_type
39
+ 'xsi:type' => @object.record_type
40
40
  }
41
41
  }
42
42
  }
43
- if @obj.respond_to?(:internal_id) && @obj.internal_id
44
- hash[:attributes!]['platformMsgs:record']['platformMsgs:internalId'] = @obj.internal_id
43
+ if @object.respond_to?(:internal_id) && @object.internal_id
44
+ hash[:attributes!]['platformMsgs:record']['platformMsgs:internalId'] = @object.internal_id
45
45
  end
46
- if @obj.respond_to?(:external_id) && @obj.external_id
47
- hash[:attributes!]['platformMsgs:record']['platformMsgs:externalId'] = @obj.external_id
46
+ if @object.respond_to?(:external_id) && @object.external_id
47
+ hash[:attributes!]['platformMsgs:record']['platformMsgs:externalId'] = @object.external_id
48
48
  end
49
49
  hash
50
50
  end
@@ -0,0 +1,53 @@
1
+ module NetSuite
2
+ module Actions
3
+ class Delete
4
+ include Support::Requests
5
+
6
+ def initialize(object = nil)
7
+ @object = object
8
+ end
9
+
10
+ private
11
+
12
+ def request
13
+ connection.request :platformMsgs, :delete do
14
+ soap.namespaces['xmlns:platformMsgs'] = 'urn:messages_2011_2.platform.webservices.netsuite.com'
15
+ soap.namespaces['xmlns:platformCore'] = 'urn:core_2011_2.platform.webservices.netsuite.com'
16
+ soap.header = auth_header
17
+ soap.body = request_body
18
+ end
19
+ end
20
+
21
+ # <soap:Body>
22
+ # <platformMsgs:delete>
23
+ # <platformMsgs:baseRef internalId="980" type="customer" xsi:type="platformCore:RecordRef"/>
24
+ # </platformMsgs:delete>
25
+ # </soap:Body>
26
+ def request_body
27
+ {
28
+ 'platformMsgs:baseRef' => {},
29
+ :attributes! => {
30
+ 'platformMsgs:baseRef' => {
31
+ 'internalId' => @object.internal_id,
32
+ 'type' => @object.class.to_s.split('::').last.lower_camelcase,
33
+ 'xsi:type' => 'platformCore:RecordRef'
34
+ }
35
+ }
36
+ }
37
+ end
38
+
39
+ def response_hash
40
+ @response_hash ||= @response.to_hash[:delete_response][:write_response]
41
+ end
42
+
43
+ def success?
44
+ @success ||= response_hash[:status][:@is_success] == 'true'
45
+ end
46
+
47
+ def response_body
48
+ @response_body ||= response_hash[:base_ref]
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -5,7 +5,7 @@ module NetSuite
5
5
  include Support::RecordRefs
6
6
  include Support::Actions
7
7
 
8
- actions :get
8
+ actions :get, :add, :delete
9
9
 
10
10
  fields :acct_name, :acct_number, :acct_type, :cash_flow_rate, :cur_doc_num, :description, :eliminate, :exchange_rate,
11
11
  :general_rate, :include_children, :inventory, :is_inactive, :opening_balance, :revalue, :tran_date
@@ -4,7 +4,7 @@ module NetSuite
4
4
  include Support::Fields
5
5
  include Support::Actions
6
6
 
7
- actions :get
7
+ actions :get, :delete
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::TranCust
9
9
 
10
- actions :get, :add, :initialize
10
+ actions :get, :add, :initialize, :delete
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,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::SetupCustom
9
9
 
10
- actions :get, :add
10
+ actions :get, :add, :delete
11
11
 
12
12
  fields :allow_attachments, :allow_inline_editing, :allow_numbering_override, :allow_quick_search, :created,
13
13
  :custom_record_id, :description, :disclaimer, :enabl_email_merge, :enable_numbering, :include_name,
@@ -5,7 +5,7 @@ module NetSuite
5
5
  include Support::RecordRefs
6
6
  include Support::Actions
7
7
 
8
- actions :get
8
+ actions :get, :add, :delete
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::ListRel
9
9
 
10
- actions :get, :add
10
+ actions :get, :add, :delete
11
11
 
12
12
  fields :access_role, :account_number, :aging, :alt_email, :alt_name, :alt_phone, :bill_pay,
13
13
  :buying_reason, :buying_time_frame, :campaign_category, :category, :click_stream, :comments, :company_name,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::TranCust
9
9
 
10
- actions :get, :initialize, :add
10
+ actions :get, :initialize, :add, :delete
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
10
+ actions :get, :initialize, :add, :delete
11
11
 
12
12
  fields :address, :balance, :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,
@@ -22,7 +22,12 @@ module NetSuite
22
22
  record_refs :account, :ar_acct, :credit_card, :credit_card_processor, :custom_form, :customer, :department, :klass,
23
23
  :location, :payment_method, :posting_period, :subsidiary, :void_journal
24
24
 
25
+ attr_reader :internal_id
26
+ attr_accessor :external_id
27
+
25
28
  def initialize(attributes = {})
29
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
30
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
26
31
  initialize_from_attributes_hash(attributes)
27
32
  end
28
33
 
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :add
10
+ actions :get, :add, :delete
11
11
 
12
12
  fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost,
13
13
  :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
10
+ actions :get, :initialize, :add, :delete
11
11
 
12
12
  fields :alt_handling_cost, :alt_shipping_cost, :balance, :bill_address,
13
13
  :billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name, :custom_field_list,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListRel
9
9
 
10
- actions :get, :add
10
+ actions :get, :add, :delete
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
10
+ actions :get, :add, :delete
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
@@ -26,6 +26,8 @@ module NetSuite
26
26
  define_add(instance_module)
27
27
  when :initialize
28
28
  define_initialize(class_module)
29
+ when :delete
30
+ define_delete(instance_module)
29
31
  else
30
32
  raise "Unknown action: #{action.inspect}"
31
33
  end
@@ -73,6 +75,15 @@ module NetSuite
73
75
  end
74
76
  end
75
77
 
78
+ def define_delete(instance_module)
79
+ instance_module.module_eval do
80
+ define_method :delete do
81
+ response = NetSuite::Actions::Delete.call(self)
82
+ response.success?
83
+ end
84
+ end
85
+ end
86
+
76
87
  end
77
88
 
78
89
  end
@@ -22,7 +22,7 @@ module NetSuite
22
22
  private
23
23
 
24
24
  def request
25
- raise NotImplementedError
25
+ raise NotImplementedError, 'Please implement a #request method'
26
26
  end
27
27
 
28
28
  def connection
@@ -38,11 +38,11 @@ module NetSuite
38
38
  end
39
39
 
40
40
  def success?
41
- raise NotImplementedError
41
+ raise NotImplementedError, 'Please implement a #success? method'
42
42
  end
43
43
 
44
44
  def response_body
45
- raise NotImplementedError
45
+ raise NotImplementedError, 'Please implement a #response_body method'
46
46
  end
47
47
 
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.26'
2
+ VERSION = '0.0.27'
3
3
  end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Actions::Delete do
4
+
5
+ context 'Customer' do
6
+ let(:customer) do
7
+ NetSuite::Records::Customer.new(:internal_id => '980', :entity_id => 'Shutter Fly', :company_name => 'Shutter Fly, Inc.')
8
+ end
9
+
10
+ before do
11
+ savon.expects(:delete).with({
12
+ 'platformMsgs:baseRef' => {},
13
+ :attributes! => {
14
+ 'platformMsgs:baseRef' => {
15
+ 'internalId' => '980',
16
+ 'type' => 'customer',
17
+ 'xsi:type' => 'platformCore:RecordRef'
18
+ }
19
+ }
20
+ }).returns(:delete_customer)
21
+ end
22
+
23
+ it 'makes a valid request to the NetSuite API' do
24
+ NetSuite::Actions::Delete.call(customer)
25
+ end
26
+
27
+ it 'returns a valid Response object' do
28
+ response = NetSuite::Actions::Delete.call(customer)
29
+ response.should be_kind_of(NetSuite::Response)
30
+ response.should be_success
31
+ end
32
+ end
33
+
34
+ end
@@ -48,4 +48,60 @@ describe NetSuite::Records::Account do
48
48
  end
49
49
  end
50
50
 
51
+ describe '#add' do
52
+ let(:test_data) { { :acct_name => 'Test Account', :description => 'An example account' } }
53
+
54
+ context 'when the response is successful' do
55
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
56
+
57
+ it 'returns true' do
58
+ account = NetSuite::Records::Account.new(test_data)
59
+ NetSuite::Actions::Add.should_receive(:call).
60
+ with(account).
61
+ and_return(response)
62
+ account.add.should be_true
63
+ end
64
+ end
65
+
66
+ context 'when the response is unsuccessful' do
67
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
68
+
69
+ it 'returns false' do
70
+ account = NetSuite::Records::Account.new(test_data)
71
+ NetSuite::Actions::Add.should_receive(:call).
72
+ with(account).
73
+ and_return(response)
74
+ account.add.should be_false
75
+ end
76
+ end
77
+ end
78
+
79
+ describe '#delete' do
80
+ let(:test_data) { { :internal_id => '1' } }
81
+
82
+ context 'when the response is successful' do
83
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
84
+
85
+ it 'returns true' do
86
+ account = NetSuite::Records::Account.new(test_data)
87
+ NetSuite::Actions::Delete.should_receive(:call).
88
+ with(account).
89
+ and_return(response)
90
+ account.delete.should be_true
91
+ end
92
+ end
93
+
94
+ context 'when the response is unsuccessful' do
95
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
96
+
97
+ it 'returns false' do
98
+ account = NetSuite::Records::Account.new(test_data)
99
+ NetSuite::Actions::Delete.should_receive(:call).
100
+ with(account).
101
+ and_return(response)
102
+ account.delete.should be_false
103
+ end
104
+ end
105
+ end
106
+
51
107
  end
@@ -35,4 +35,32 @@ describe NetSuite::Records::Classification do
35
35
  end
36
36
  end
37
37
 
38
+ describe '#delete' do
39
+ let(:test_data) { { :internal_id => '1' } }
40
+
41
+ context 'when the response is successful' do
42
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
43
+
44
+ it 'returns true' do
45
+ classification = NetSuite::Records::Classification.new(test_data)
46
+ NetSuite::Actions::Delete.should_receive(:call).
47
+ with(classification).
48
+ and_return(response)
49
+ classification.delete.should be_true
50
+ end
51
+ end
52
+
53
+ context 'when the response is unsuccessful' do
54
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
55
+
56
+ it 'returns false' do
57
+ classification = NetSuite::Records::Classification.new(test_data)
58
+ NetSuite::Actions::Delete.should_receive(:call).
59
+ with(classification).
60
+ and_return(response)
61
+ classification.delete.should be_false
62
+ end
63
+ end
64
+ end
65
+
38
66
  end
@@ -139,6 +139,34 @@ describe NetSuite::Records::CreditMemo do
139
139
  end
140
140
  end
141
141
 
142
+ describe '#delete' do
143
+ let(:test_data) { { :internal_id => '1' } }
144
+
145
+ context 'when the response is successful' do
146
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
147
+
148
+ it 'returns true' do
149
+ memo = NetSuite::Records::CreditMemo.new(test_data)
150
+ NetSuite::Actions::Delete.should_receive(:call).
151
+ with(memo).
152
+ and_return(response)
153
+ memo.delete.should be_true
154
+ end
155
+ end
156
+
157
+ context 'when the response is unsuccessful' do
158
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
159
+
160
+ it 'returns false' do
161
+ memo = NetSuite::Records::CreditMemo.new(test_data)
162
+ NetSuite::Actions::Delete.should_receive(:call).
163
+ with(memo).
164
+ and_return(response)
165
+ memo.delete.should be_false
166
+ end
167
+ end
168
+ end
169
+
142
170
  describe '#to_record' do
143
171
  before do
144
172
  memo.email = 'something@example.com'
@@ -80,7 +80,7 @@ describe NetSuite::Records::CustomRecord do
80
80
  NetSuite::Actions::Add.should_receive(:call).
81
81
  with(record).
82
82
  and_return(response)
83
- record.add
83
+ record.add.should be_true
84
84
  end
85
85
  end
86
86
 
@@ -96,4 +96,28 @@ describe NetSuite::Records::CustomRecord do
96
96
  end
97
97
  end
98
98
 
99
+ describe '#delete' do
100
+ context 'when the response is successful' do
101
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
102
+
103
+ it 'returns true' do
104
+ NetSuite::Actions::Delete.should_receive(:call).
105
+ with(record).
106
+ and_return(response)
107
+ record.delete.should be_true
108
+ end
109
+ end
110
+
111
+ context 'when the response is unsuccessful' do
112
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
113
+
114
+ it 'returns false' do
115
+ NetSuite::Actions::Delete.should_receive(:call).
116
+ with(record).
117
+ and_return(response)
118
+ record.delete.should be_false
119
+ end
120
+ end
121
+ end
122
+
99
123
  end
@@ -63,4 +63,52 @@ describe NetSuite::Records::CustomRecordType do
63
63
  end
64
64
  end
65
65
 
66
+ describe '#add' do
67
+ context 'when the response is successful' do
68
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
69
+
70
+ it 'returns true' do
71
+ NetSuite::Actions::Add.should_receive(:call).
72
+ with(record_type).
73
+ and_return(response)
74
+ record_type.add.should be_true
75
+ end
76
+ end
77
+
78
+ context 'when the response is unsuccessful' do
79
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
80
+
81
+ it 'returns false' do
82
+ NetSuite::Actions::Add.should_receive(:call).
83
+ with(record_type).
84
+ and_return(response)
85
+ record_type.add.should be_false
86
+ end
87
+ end
88
+ end
89
+
90
+ describe '#delete' do
91
+ context 'when the response is successful' do
92
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
93
+
94
+ it 'returns true' do
95
+ NetSuite::Actions::Delete.should_receive(:call).
96
+ with(record_type).
97
+ and_return(response)
98
+ record_type.delete.should be_true
99
+ end
100
+ end
101
+
102
+ context 'when the response is unsuccessful' do
103
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
104
+
105
+ it 'returns false' do
106
+ NetSuite::Actions::Delete.should_receive(:call).
107
+ with(record_type).
108
+ and_return(response)
109
+ record_type.delete.should be_false
110
+ end
111
+ end
112
+ end
113
+
66
114
  end
@@ -104,7 +104,7 @@ describe NetSuite::Records::CustomerPayment do
104
104
  let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
105
105
 
106
106
  it 'returns false' do
107
- pyament = NetSuite::Records::CustomerPayment.new(test_data)
107
+ payment = NetSuite::Records::CustomerPayment.new(test_data)
108
108
  NetSuite::Actions::Add.should_receive(:call).
109
109
  with(payment).
110
110
  and_return(response)
@@ -113,6 +113,30 @@ describe NetSuite::Records::CustomerPayment do
113
113
  end
114
114
  end
115
115
 
116
+ describe '#delete' do
117
+ context 'when the response is successful' do
118
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
119
+
120
+ it 'returns true' do
121
+ NetSuite::Actions::Delete.should_receive(:call).
122
+ with(payment).
123
+ and_return(response)
124
+ payment.delete.should be_true
125
+ end
126
+ end
127
+
128
+ context 'when the response is unsuccessful' do
129
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
130
+
131
+ it 'returns false' do
132
+ NetSuite::Actions::Delete.should_receive(:call).
133
+ with(payment).
134
+ and_return(response)
135
+ payment.delete.should be_false
136
+ end
137
+ end
138
+ end
139
+
116
140
  describe '#to_record' do
117
141
  before do
118
142
  payment.cc_name = 'Ryan Moran'
@@ -140,7 +140,7 @@ describe NetSuite::Records::CustomerRefund do
140
140
  let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
141
141
 
142
142
  it 'returns false' do
143
- refund = NetSuite::Records::Invoice.new(test_data)
143
+ refund = NetSuite::Records::CustomerRefund.new(test_data)
144
144
  NetSuite::Actions::Add.should_receive(:call).
145
145
  with(refund).
146
146
  and_return(response)
@@ -149,6 +149,32 @@ describe NetSuite::Records::CustomerRefund do
149
149
  end
150
150
  end
151
151
 
152
+ describe '#delete' do
153
+ context 'when the response is successful' do
154
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
155
+
156
+ it 'returns true' do
157
+ refund = NetSuite::Records::CustomerRefund.new
158
+ NetSuite::Actions::Delete.should_receive(:call).
159
+ with(refund).
160
+ and_return(response)
161
+ refund.delete.should be_true
162
+ end
163
+ end
164
+
165
+ context 'when the response is unsuccessful' do
166
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
167
+
168
+ it 'returns false' do
169
+ refund = NetSuite::Records::CustomerRefund.new
170
+ NetSuite::Actions::Delete.should_receive(:call).
171
+ with(refund).
172
+ and_return(response)
173
+ refund.delete.should be_false
174
+ end
175
+ end
176
+ end
177
+
152
178
  describe '#to_record' do
153
179
  before do
154
180
  refund.memo = 'This is a memo'
@@ -114,6 +114,30 @@ describe NetSuite::Records::Customer do
114
114
  end
115
115
  end
116
116
 
117
+ describe '#delete' do
118
+ context 'when the response is successful' do
119
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
120
+
121
+ it 'returns true' do
122
+ NetSuite::Actions::Delete.should_receive(:call).
123
+ with(customer).
124
+ and_return(response)
125
+ customer.delete.should be_true
126
+ end
127
+ end
128
+
129
+ context 'when the response is unsuccessful' do
130
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
131
+
132
+ it 'returns false' do
133
+ NetSuite::Actions::Delete.should_receive(:call).
134
+ with(customer).
135
+ and_return(response)
136
+ customer.delete.should be_false
137
+ end
138
+ end
139
+ end
140
+
117
141
  describe '#to_record' do
118
142
  let(:customer) { NetSuite::Records::Customer.new(:entity_id => 'TEST CUSTOMER', :is_person => true) }
119
143
 
@@ -103,6 +103,30 @@ describe NetSuite::Records::InventoryItem do
103
103
  end
104
104
  end
105
105
 
106
+ describe '#delete' do
107
+ context 'when the response is successful' do
108
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
109
+
110
+ it 'returns true' do
111
+ NetSuite::Actions::Delete.should_receive(:call).
112
+ with(item).
113
+ and_return(response)
114
+ item.delete.should be_true
115
+ end
116
+ end
117
+
118
+ context 'when the response is unsuccessful' do
119
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
120
+
121
+ it 'returns false' do
122
+ NetSuite::Actions::Delete.should_receive(:call).
123
+ with(item).
124
+ and_return(response)
125
+ item.delete.should be_false
126
+ end
127
+ end
128
+ end
129
+
106
130
  describe '#to_record' do
107
131
  before do
108
132
  item.cost = 100
@@ -195,6 +195,32 @@ describe NetSuite::Records::Invoice do
195
195
  end
196
196
  end
197
197
 
198
+ describe '#delete' do
199
+ context 'when the response is successful' do
200
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
201
+
202
+ it 'returns true' do
203
+ invoice = NetSuite::Records::Invoice.new
204
+ NetSuite::Actions::Delete.should_receive(:call).
205
+ with(invoice).
206
+ and_return(response)
207
+ invoice.delete.should be_true
208
+ end
209
+ end
210
+
211
+ context 'when the response is unsuccessful' do
212
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
213
+
214
+ it 'returns false' do
215
+ invoice = NetSuite::Records::Invoice.new
216
+ NetSuite::Actions::Delete.should_receive(:call).
217
+ with(invoice).
218
+ and_return(response)
219
+ invoice.delete.should be_false
220
+ end
221
+ end
222
+ end
223
+
198
224
  describe '#to_record' do
199
225
  before do
200
226
  invoice.email = 'something@example.com'
@@ -135,6 +135,30 @@ describe NetSuite::Records::Job do
135
135
  end
136
136
  end
137
137
 
138
+ describe '#delete' do
139
+ context 'when the response is successful' do
140
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
141
+
142
+ it 'returns true' do
143
+ NetSuite::Actions::Delete.should_receive(:call).
144
+ with(job).
145
+ and_return(response)
146
+ job.delete.should be_true
147
+ end
148
+ end
149
+
150
+ context 'when the response is unsuccessful' do
151
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
152
+
153
+ it 'returns false' do
154
+ NetSuite::Actions::Delete.should_receive(:call).
155
+ with(job).
156
+ and_return(response)
157
+ job.delete.should be_false
158
+ end
159
+ end
160
+ end
161
+
138
162
  describe '#to_record' do
139
163
  let(:job) { NetSuite::Records::Job.new(:entity_id => 'TEST JOB', :account_number => 7) }
140
164
 
@@ -110,6 +110,30 @@ describe NetSuite::Records::JournalEntry do
110
110
  end
111
111
  end
112
112
 
113
+ describe '#delete' do
114
+ context 'when the response is successful' do
115
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
116
+
117
+ it 'returns true' do
118
+ NetSuite::Actions::Delete.should_receive(:call).
119
+ with(entry).
120
+ and_return(response)
121
+ entry.delete.should be_true
122
+ end
123
+ end
124
+
125
+ context 'when the response is unsuccessful' do
126
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
127
+
128
+ it 'returns false' do
129
+ NetSuite::Actions::Delete.should_receive(:call).
130
+ with(entry).
131
+ and_return(response)
132
+ entry.delete.should be_false
133
+ end
134
+ end
135
+ end
136
+
113
137
  describe '#to_record' do
114
138
  let(:entry) { NetSuite::Records::JournalEntry.new(:tran_id => '1234', :approved => true) }
115
139
 
@@ -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_1220201115821392011296470399_67055c545d0</platformMsgs:nsId>
6
+ </platformMsgs:documentInfo>
7
+ </soapenv:Header>
8
+ <soapenv:Body>
9
+ <deleteResponse xmlns="urn:messages_2_5.platform.webservices.netsuite.com">
10
+ <writeResponse xmlns="urn:messages_2_5.platform.webservices.netsuite.com">
11
+ <ns1:status isSuccess="true" xmlns:ns1="urn:core_2_5.platform.webservices.netsuite.com"/>
12
+ <baseRef internalId="980" type="customer" xsi:type="ns2:RecordRef" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:core_2_5.platform.webservices.netsuite.com"/>
13
+ </writeResponse>
14
+ </deleteResponse>
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: 43
4
+ hash: 41
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 26
10
- version: 0.0.26
9
+ - 27
10
+ version: 0.0.27
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -115,6 +115,7 @@ files:
115
115
  - Rakefile
116
116
  - lib/netsuite.rb
117
117
  - lib/netsuite/actions/add.rb
118
+ - lib/netsuite/actions/delete.rb
118
119
  - lib/netsuite/actions/get.rb
119
120
  - lib/netsuite/actions/initialize.rb
120
121
  - lib/netsuite/actions/update.rb
@@ -175,6 +176,7 @@ files:
175
176
  - lib/netsuite/xml_logger.rb
176
177
  - netsuite.gemspec
177
178
  - spec/netsuite/actions/add_spec.rb
179
+ - spec/netsuite/actions/delete_spec.rb
178
180
  - spec/netsuite/actions/get_spec.rb
179
181
  - spec/netsuite/actions/initialize_spec.rb
180
182
  - spec/netsuite/actions/update_spec.rb
@@ -228,6 +230,7 @@ files:
228
230
  - spec/support/field_matcher.rb
229
231
  - spec/support/fixtures/add/add_customer.xml
230
232
  - spec/support/fixtures/add/add_invoice.xml
233
+ - spec/support/fixtures/delete/delete_customer.xml
231
234
  - spec/support/fixtures/get/get_customer.xml
232
235
  - spec/support/fixtures/get/get_invoice.xml
233
236
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml
@@ -266,12 +269,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
269
  requirements: []
267
270
 
268
271
  rubyforge_project:
269
- rubygems_version: 1.8.13
272
+ rubygems_version: 1.8.15
270
273
  signing_key:
271
274
  specification_version: 3
272
275
  summary: NetSuite SuiteTalk API Wrapper
273
276
  test_files:
274
277
  - spec/netsuite/actions/add_spec.rb
278
+ - spec/netsuite/actions/delete_spec.rb
275
279
  - spec/netsuite/actions/get_spec.rb
276
280
  - spec/netsuite/actions/initialize_spec.rb
277
281
  - spec/netsuite/actions/update_spec.rb
@@ -325,6 +329,7 @@ test_files:
325
329
  - spec/support/field_matcher.rb
326
330
  - spec/support/fixtures/add/add_customer.xml
327
331
  - spec/support/fixtures/add/add_invoice.xml
332
+ - spec/support/fixtures/delete/delete_customer.xml
328
333
  - spec/support/fixtures/get/get_customer.xml
329
334
  - spec/support/fixtures/get/get_invoice.xml
330
335
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml