netsuite 0.8.2 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +7 -2
- data/README.md +107 -32
- data/circle.yml +33 -13
- data/lib/netsuite.rb +36 -19
- data/lib/netsuite/actions/login.rb +20 -1
- data/lib/netsuite/actions/search.rb +1 -6
- data/lib/netsuite/actions/update.rb +6 -2
- data/lib/netsuite/actions/update_list.rb +109 -0
- data/lib/netsuite/actions/upsert.rb +2 -0
- data/lib/netsuite/configuration.rb +21 -4
- data/lib/netsuite/errors.rb +1 -0
- data/lib/netsuite/records/assembly_build.rb +4 -1
- data/lib/netsuite/records/assembly_item.rb +1 -0
- data/lib/netsuite/records/assembly_unbuild.rb +3 -0
- data/lib/netsuite/records/bin_number.rb +18 -0
- data/lib/netsuite/records/bin_number_list.rb +1 -20
- data/lib/netsuite/records/bin_transfer.rb +38 -0
- data/lib/netsuite/records/bin_transfer_inventory.rb +20 -0
- data/lib/netsuite/records/bin_transfer_inventory_list.rb +10 -0
- data/lib/netsuite/records/cash_refund_item.rb +1 -1
- data/lib/netsuite/records/classification.rb +5 -2
- data/lib/netsuite/records/custom_field_list.rb +10 -2
- data/lib/netsuite/records/custom_record.rb +3 -3
- data/lib/netsuite/records/custom_record_ref.rb +1 -0
- data/lib/netsuite/records/customer.rb +5 -4
- data/lib/netsuite/records/customer_credit_cards.rb +36 -0
- data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
- data/lib/netsuite/records/customer_deposit.rb +5 -2
- data/lib/netsuite/records/customer_payment.rb +1 -0
- data/lib/netsuite/records/customer_sales_team.rb +24 -0
- data/lib/netsuite/records/customer_sales_team_list.rb +9 -0
- data/lib/netsuite/records/customer_status.rb +29 -0
- data/lib/netsuite/records/customer_subscription.rb +18 -0
- data/lib/netsuite/records/customer_subscriptions_list.rb +10 -0
- data/lib/netsuite/records/employee.rb +1 -1
- data/lib/netsuite/records/entity_custom_field.rb +53 -0
- data/lib/netsuite/records/estimate.rb +42 -0
- data/lib/netsuite/records/estimate_item.rb +40 -0
- data/lib/netsuite/records/estimate_item_list.rb +11 -0
- data/lib/netsuite/records/inbound_shipment.rb +33 -0
- data/lib/netsuite/records/inbound_shipment_item.rb +39 -0
- data/lib/netsuite/records/inbound_shipment_item_list.rb +11 -0
- data/lib/netsuite/records/inter_company_journal_entry.rb +48 -0
- data/lib/netsuite/records/inter_company_journal_entry_line.rb +28 -0
- data/lib/netsuite/records/inter_company_journal_entry_line_list.rb +14 -0
- data/lib/netsuite/records/inventory_item.rb +1 -1
- data/lib/netsuite/records/invoice.rb +1 -1
- data/lib/netsuite/records/item_fulfillment.rb +1 -1
- data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
- data/lib/netsuite/records/matrix_option_list.rb +12 -4
- data/lib/netsuite/records/message.rb +30 -0
- data/lib/netsuite/records/non_inventory_resale_item.rb +3 -2
- data/lib/netsuite/records/non_inventory_sale_item.rb +1 -1
- data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
- data/lib/netsuite/records/partner.rb +1 -1
- data/lib/netsuite/records/price.rb +17 -0
- data/lib/netsuite/records/price_level.rb +26 -0
- data/lib/netsuite/records/price_list.rb +9 -0
- data/lib/netsuite/records/pricing.rb +20 -0
- data/lib/netsuite/records/pricing_matrix.rb +2 -2
- data/lib/netsuite/records/promotions.rb +26 -0
- data/lib/netsuite/records/promotions_list.rb +9 -0
- data/lib/netsuite/records/return_authorization_item.rb +1 -1
- data/lib/netsuite/records/sales_order.rb +1 -0
- data/lib/netsuite/records/sales_order_item.rb +12 -5
- data/lib/netsuite/records/sales_role.rb +26 -0
- data/lib/netsuite/records/sales_tax_item.rb +3 -1
- data/lib/netsuite/records/serialized_assembly_item.rb +239 -0
- data/lib/netsuite/records/service_resale_item.rb +1 -1
- data/lib/netsuite/records/service_sale_item.rb +1 -1
- data/lib/netsuite/records/support_case.rb +1 -1
- data/lib/netsuite/records/support_case_type.rb +26 -0
- data/lib/netsuite/records/tax_group.rb +2 -2
- data/lib/netsuite/records/transaction_body_custom_field.rb +61 -0
- data/lib/netsuite/records/transaction_column_custom_field.rb +59 -0
- data/lib/netsuite/records/vendor_credit.rb +2 -0
- data/lib/netsuite/records/work_order.rb +8 -0
- data/lib/netsuite/support/actions.rb +2 -0
- data/lib/netsuite/support/country.rb +27 -15
- data/lib/netsuite/support/search_result.rb +20 -5
- data/lib/netsuite/utilities.rb +83 -21
- data/lib/netsuite/version.rb +1 -1
- data/netsuite.gemspec +4 -3
- data/spec/netsuite/actions/login_spec.rb +23 -0
- data/spec/netsuite/actions/update_list_spec.rb +107 -0
- data/spec/netsuite/actions/update_spec.rb +42 -0
- data/spec/netsuite/configuration_spec.rb +79 -6
- data/spec/netsuite/records/address_spec.rb +10 -0
- data/spec/netsuite/records/basic_record_spec.rb +11 -1
- data/spec/netsuite/records/bin_number_spec.rb +23 -0
- data/spec/netsuite/records/classification_spec.rb +10 -1
- data/spec/netsuite/records/custom_field_list_spec.rb +39 -4
- data/spec/netsuite/records/custom_record_spec.rb +1 -1
- data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
- data/spec/netsuite/records/customer_sales_team_list_spec.rb +41 -0
- data/spec/netsuite/records/customer_spec.rb +44 -2
- data/spec/netsuite/records/customer_subscription_spec.rb +41 -0
- data/spec/netsuite/records/customer_subscriptions_list_spec.rb +19 -0
- data/spec/netsuite/records/employee_spec.rb +2 -2
- data/spec/netsuite/records/entity_custom_field_spec.rb +34 -0
- data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
- data/spec/netsuite/records/estimate_item_spec.rb +40 -0
- data/spec/netsuite/records/estimate_spec.rb +216 -0
- data/spec/netsuite/records/inter_company_journal_entry_line_list_spec.rb +26 -0
- data/spec/netsuite/records/inter_company_journal_entry_line_spec.rb +60 -0
- data/spec/netsuite/records/inter_company_journal_entry_spec.rb +156 -0
- data/spec/netsuite/records/inventory_item_spec.rb +57 -0
- data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
- data/spec/netsuite/records/message_spec.rb +49 -0
- data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
- data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
- data/spec/netsuite/records/partner_spec.rb +141 -0
- data/spec/netsuite/records/price_level_spec.rb +16 -0
- data/spec/netsuite/records/pricing_matrix_spec.rb +15 -13
- data/spec/netsuite/records/return_authorization_item_spec.rb +1 -1
- data/spec/netsuite/records/sales_order_item_spec.rb +11 -5
- data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
- data/spec/netsuite/records/support_case_type_spec.rb +22 -0
- data/spec/netsuite/records/transaction_body_custom_field_spec.rb +32 -0
- data/spec/netsuite/records/transaction_column_custom_field_spec.rb +32 -0
- data/spec/netsuite/records/vendor_credit_spec.rb +29 -0
- data/spec/netsuite/support/search_result_spec.rb +24 -0
- data/spec/netsuite/utilities_spec.rb +44 -6
- data/spec/spec_helper.rb +5 -4
- data/spec/support/fixtures/update_list/update_list_items.xml +22 -0
- data/spec/support/fixtures/update_list/update_list_one_item.xml +18 -0
- data/spec/support/fixtures/update_list/update_list_with_errors.xml +32 -0
- metadata +101 -8
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::InterCompanyJournalEntryLineList do
|
4
|
+
let(:list) { NetSuite::Records::InterCompanyJournalEntryLineList.new }
|
5
|
+
|
6
|
+
it 'has a custom_fields attribute' do
|
7
|
+
expect(list.lines).to be_kind_of(Array)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#to_record' do
|
11
|
+
before do
|
12
|
+
list.lines << NetSuite::Records::InterCompanyJournalEntryLine.new(:memo => 'This is a memo')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'can represent itself as a SOAP record' do
|
16
|
+
record =
|
17
|
+
{
|
18
|
+
'tranGeneral:line' => [{
|
19
|
+
'tranGeneral:memo' => 'This is a memo'
|
20
|
+
}]
|
21
|
+
}
|
22
|
+
expect(list.to_record).to eql(record)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::InterCompanyJournalEntryLine do
|
4
|
+
let(:line) { NetSuite::Records::InterCompanyJournalEntryLine.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:amortization_end_date, :amortization_residual, :amortiz_start_date, :credit, :debit, :eliminate, :end_date, :gross_amt, :memo,
|
9
|
+
:residual, :start_date, :tax1_amt, :tax_rate1
|
10
|
+
].each do |field|
|
11
|
+
expect(line).to have_field(field)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has all the right record refs' do
|
16
|
+
[
|
17
|
+
:account, :department, :entity, :klass, :line_subsidiary, :location, :schedule, :schedule_num, :tax1_acct, :tax_code
|
18
|
+
].each do |record_ref|
|
19
|
+
expect(line).to have_record_ref(record_ref)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#custom_field_list' do
|
24
|
+
it 'can be set from attributes' do
|
25
|
+
attributes = {
|
26
|
+
:custom_field => {
|
27
|
+
:amount => 10,
|
28
|
+
:internal_id => 'custfield_amount'
|
29
|
+
}
|
30
|
+
}
|
31
|
+
line.custom_field_list = attributes
|
32
|
+
expect(line.custom_field_list).to be_kind_of(NetSuite::Records::CustomFieldList)
|
33
|
+
expect(line.custom_field_list.custom_fields.length).to eql(1)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'can be set from a CustomFieldList object' do
|
37
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
38
|
+
line.custom_field_list = custom_field_list
|
39
|
+
expect(line.custom_field_list).to eql(custom_field_list)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#to_record' do
|
44
|
+
let(:line) { NetSuite::Records::InterCompanyJournalEntryLine.new(:memo => 'This is a memo', :eliminate => true) }
|
45
|
+
|
46
|
+
it 'returns a hash of attributes that can be used in a SOAP request' do
|
47
|
+
expect(line.to_record).to eql({
|
48
|
+
'tranGeneral:memo' => 'This is a memo',
|
49
|
+
'tranGeneral:eliminate' => true
|
50
|
+
})
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#record_type' do
|
55
|
+
it 'returns a string type for the record to be used in a SOAP request' do
|
56
|
+
expect(line.record_type).to eql('tranGeneral:InterCompanyJournalEntryLine')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::InterCompanyJournalEntry do
|
4
|
+
let(:entry) { NetSuite::Records::InterCompanyJournalEntry.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:approved, :created_date, :exchange_rate, :is_book_specific, :last_modified_date, :memo, :reversal_date,
|
9
|
+
:reversal_defer, :reversal_entry, :tran_date, :tran_id
|
10
|
+
].each do |field|
|
11
|
+
expect(entry).to have_field(field)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has all the right record refs' do
|
16
|
+
[
|
17
|
+
:created_from, :currency, :custom_form, :department, :klass, :location, :parent_expense_alloc, :posting_period,
|
18
|
+
:subsidiary, :to_subsidiary
|
19
|
+
].each do |record_ref|
|
20
|
+
expect(entry).to have_record_ref(record_ref)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#custom_field_list' do
|
25
|
+
it 'can be set from attributes' do
|
26
|
+
attributes = {
|
27
|
+
:custom_field => {
|
28
|
+
:amount => 10,
|
29
|
+
:script_id => 'custfield_amount'
|
30
|
+
}
|
31
|
+
}
|
32
|
+
entry.custom_field_list = attributes
|
33
|
+
expect(entry.custom_field_list).to be_kind_of(NetSuite::Records::CustomFieldList)
|
34
|
+
expect(entry.custom_field_list.custom_fields.length).to eql(1)
|
35
|
+
expect(entry.custom_field_list.custfield_amount.attributes[:amount]).to eq(10)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'can be set from a CustomFieldList object' do
|
39
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
40
|
+
entry.custom_field_list = custom_field_list
|
41
|
+
expect(entry.custom_field_list).to eql(custom_field_list)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#line_list' do
|
46
|
+
it 'can be set from attributes' do
|
47
|
+
attributes = {
|
48
|
+
:line => {
|
49
|
+
|
50
|
+
}
|
51
|
+
}
|
52
|
+
entry.line_list = attributes
|
53
|
+
expect(entry.line_list).to be_kind_of(NetSuite::Records::InterCompanyJournalEntryLineList)
|
54
|
+
expect(entry.line_list.lines.length).to eql(1)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'can be set from a InterCompanyJournalEntryLineList object' do
|
58
|
+
line_list = NetSuite::Records::InterCompanyJournalEntryLineList.new
|
59
|
+
entry.line_list = line_list
|
60
|
+
expect(entry.line_list).to eql(line_list)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '.get' do
|
65
|
+
context 'when the response is successful' do
|
66
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :approved => true }) }
|
67
|
+
|
68
|
+
it 'returns a InterCompanyJournalEntry instance populated with the data from the response object' do
|
69
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::InterCompanyJournalEntry, {:external_id => 1}], {}).and_return(response)
|
70
|
+
customer = NetSuite::Records::InterCompanyJournalEntry.get(:external_id => 1)
|
71
|
+
expect(customer).to be_kind_of(NetSuite::Records::InterCompanyJournalEntry)
|
72
|
+
expect(customer.approved).to be_truthy
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when the response is unsuccessful' do
|
77
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
78
|
+
|
79
|
+
it 'raises a RecordNotFound exception' do
|
80
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::InterCompanyJournalEntry, {:external_id => 1}], {}).and_return(response)
|
81
|
+
expect {
|
82
|
+
NetSuite::Records::InterCompanyJournalEntry.get(:external_id => 1)
|
83
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
84
|
+
/NetSuite::Records::InterCompanyJournalEntry with OPTIONS=(.*) could not be found/)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#add' do
|
90
|
+
let(:entry) { NetSuite::Records::InterCompanyJournalEntry.new(:approved => true) }
|
91
|
+
|
92
|
+
context 'when the response is successful' do
|
93
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
94
|
+
|
95
|
+
it 'returns true' do
|
96
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
97
|
+
with([entry], {}).
|
98
|
+
and_return(response)
|
99
|
+
expect(entry.add).to be_truthy
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'when the response is unsuccessful' do
|
104
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
105
|
+
|
106
|
+
it 'returns false' do
|
107
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
108
|
+
with([entry], {}).
|
109
|
+
and_return(response)
|
110
|
+
expect(entry.add).to be_falsey
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '#delete' do
|
116
|
+
context 'when the response is successful' do
|
117
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
118
|
+
|
119
|
+
it 'returns true' do
|
120
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
121
|
+
with([entry], {}).
|
122
|
+
and_return(response)
|
123
|
+
expect(entry.delete).to be_truthy
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
context 'when the response is unsuccessful' do
|
128
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
129
|
+
|
130
|
+
it 'returns false' do
|
131
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
132
|
+
with([entry], {}).
|
133
|
+
and_return(response)
|
134
|
+
expect(entry.delete).to be_falsey
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe '#to_record' do
|
140
|
+
let(:entry) { NetSuite::Records::InterCompanyJournalEntry.new(:tran_id => '1234', :approved => true) }
|
141
|
+
|
142
|
+
it 'returns a hash of attributes that can be used in a SOAP request' do
|
143
|
+
expect(entry.to_record).to eql({
|
144
|
+
'tranGeneral:tranId' => '1234',
|
145
|
+
'tranGeneral:approved' => true
|
146
|
+
})
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe '#record_type' do
|
151
|
+
it 'returns a string type for the record to be used in a SOAP request' do
|
152
|
+
expect(entry.record_type).to eql('tranGeneral:InterCompanyJournalEntry')
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
@@ -231,4 +231,61 @@ describe NetSuite::Records::InventoryItem do
|
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
|
+
describe '.update_list' do
|
235
|
+
before { savon.mock! }
|
236
|
+
after { savon.unmock! }
|
237
|
+
|
238
|
+
context 'with one item' do
|
239
|
+
before do
|
240
|
+
savon.expects(:update_list).with(:message =>
|
241
|
+
{
|
242
|
+
'record' => [{
|
243
|
+
'listAcct:itemId' => 'Target',
|
244
|
+
'@xsi:type' => 'listAcct:InventoryItem',
|
245
|
+
'@internalId' => '624113'
|
246
|
+
}]
|
247
|
+
}).returns(File.read('spec/support/fixtures/update_list/update_list_one_item.xml'))
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'returns collection with one InventoryItem instances populated with the data from the response object' do
|
251
|
+
items = NetSuite::Records::InventoryItem.update_list([
|
252
|
+
NetSuite::Records::InventoryItem.new(internal_id: '624113', item_id: 'Target', upccode: 'Target')
|
253
|
+
])
|
254
|
+
shutter_fly = items[0]
|
255
|
+
expect(shutter_fly).to be_kind_of(NetSuite::Records::InventoryItem)
|
256
|
+
expect(shutter_fly.item_id).to eq('Target')
|
257
|
+
expect(shutter_fly.internal_id).to eq('624113')
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
context 'with two items' do
|
262
|
+
before do
|
263
|
+
savon.expects(:update_list).with(:message =>
|
264
|
+
{
|
265
|
+
'record' => [{
|
266
|
+
'listAcct:itemId' => 'Shutter Fly',
|
267
|
+
'@xsi:type' => 'listAcct:InventoryItem',
|
268
|
+
'@internalId' => '624172'
|
269
|
+
},
|
270
|
+
{
|
271
|
+
'listAcct:itemId' => 'Target',
|
272
|
+
'@xsi:type' => 'listAcct:InventoryItem',
|
273
|
+
'@internalId' => '624113'
|
274
|
+
}
|
275
|
+
]
|
276
|
+
}).returns(File.read('spec/support/fixtures/update_list/update_list_items.xml'))
|
277
|
+
end
|
278
|
+
|
279
|
+
it 'returns collection of InventoryItem instances populated with the data from the response object' do
|
280
|
+
items = NetSuite::Records::InventoryItem.update_list( [
|
281
|
+
NetSuite::Records::InventoryItem.new(internal_id: '624172', item_id: 'Shutter Fly', upccode: 'Shutter Fly, Inc.'),
|
282
|
+
NetSuite::Records::InventoryItem.new(internal_id: '624113', item_id: 'Target', upccode: 'Target')
|
283
|
+
])
|
284
|
+
shutter_fly = items[0]
|
285
|
+
expect(shutter_fly).to be_kind_of(NetSuite::Records::InventoryItem)
|
286
|
+
expect(shutter_fly.item_id).to eq('Shutter Fly')
|
287
|
+
expect(shutter_fly.internal_id).to eq('624172')
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
234
291
|
end
|
@@ -5,20 +5,30 @@ module NetSuite
|
|
5
5
|
module Records
|
6
6
|
describe MatrixOptionList do
|
7
7
|
it "deals with hash properly" do
|
8
|
-
hash = {:value=>{:@internal_id=>"1", :@type_id=>"36"}}
|
8
|
+
hash = {:value=>{:@internal_id=>"1", :@type_id=>"36", :name=>"some value"}, :@script_id=>'cust_field_1'}
|
9
9
|
|
10
10
|
list = described_class.new({ matrix_option: hash })
|
11
|
-
|
11
|
+
option = list.options.first
|
12
|
+
expect(option.value_id).to eq "1"
|
13
|
+
expect(option.type_id).to eq "36"
|
14
|
+
expect(option.name).to eq "some value"
|
15
|
+
expect(option.script_id).to eq "cust_field_1"
|
12
16
|
end
|
13
17
|
|
14
18
|
it "deals with arrays properly" do
|
15
19
|
array = [
|
16
|
-
{:value=>{:@internal_id=>"2", :@type_id=>"28"}},
|
17
|
-
{:value=>{:@internal_id=>"1", :@type_id=>"29"}}
|
20
|
+
{:value=>{:@internal_id=>"2", :@type_id=>"28", :name=>"some value 28"}, :@script_id=>'cust_field_28'},
|
21
|
+
{:value=>{:@internal_id=>"1", :@type_id=>"29", :name=>"some value 29"}, :@script_id=>'cust_field_29'}
|
18
22
|
]
|
19
23
|
|
20
24
|
list = described_class.new({ matrix_option: array })
|
21
|
-
expect(list.options.
|
25
|
+
expect(list.options.count).to eq 2
|
26
|
+
|
27
|
+
option = list.options.first
|
28
|
+
expect(option.value_id).to eq "2"
|
29
|
+
expect(option.type_id).to eq "28"
|
30
|
+
expect(option.name).to eq "some value 28"
|
31
|
+
expect(option.script_id).to eq "cust_field_28"
|
22
32
|
end
|
23
33
|
end
|
24
34
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::Message do
|
4
|
+
let(:message) { NetSuite::Records::Message.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:bcc, :cc, :compress_attachments, :date_time, :emailed,
|
9
|
+
:incoming, :message, :record_name, :record_type_name, :subject,
|
10
|
+
:last_modified_date, :message_date
|
11
|
+
].each do |field|
|
12
|
+
expect(message).to have_field(field)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'has the right record_refs' do
|
17
|
+
[
|
18
|
+
:activity, :author, :recipient, :transaction
|
19
|
+
].each do |record_ref|
|
20
|
+
expect(message).to have_record_ref(record_ref)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.get' do
|
25
|
+
context 'when the response is successful' do
|
26
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => {message: 'message text'})}
|
27
|
+
|
28
|
+
it 'returns a Message instance populated with data from the response object' do
|
29
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Message, :external_id => 1], {}).and_return(response)
|
30
|
+
|
31
|
+
message = NetSuite::Records::Message.get(:external_id => 1)
|
32
|
+
expect(message).to be_kind_of(NetSuite::Records::Message)
|
33
|
+
expect(message.message).to eq('message text')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'when response is unsuccessful' do
|
38
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
39
|
+
it 'raises a RecordNotFound exception' do
|
40
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Message, :external_id => 1], {}).and_return(response)
|
41
|
+
expect {
|
42
|
+
NetSuite::Records::Message.get(:external_id => 1)
|
43
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
44
|
+
/NetSuite::Records::Message with OPTIONS=(.*) could not be found/)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,165 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::NonInventoryResaleItem do
|
4
|
+
let(:item) { NetSuite::Records::NonInventoryResaleItem.new }
|
5
|
+
|
6
|
+
it 'has the right fields' do
|
7
|
+
[
|
8
|
+
:available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture, :created_date,
|
9
|
+
:display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap,
|
10
|
+
:featured_description, :handling_cost, :handling_cost_units, :include_children, :is_donation_item, :is_fulfillable,
|
11
|
+
:is_gco_compliant, :is_inactive, :is_online, :is_taxable, :item_id, :last_modified_date, :manufacturer, :manufacturer_addr1,
|
12
|
+
:manufacturer_city, :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id, :manufacturer_zip, :matrix_option_list,
|
13
|
+
:matrix_type, :max_donation_amount, :meta_tag_html, :minimum_quantity, :minimum_quantity_units, :mpn,
|
14
|
+
:mult_manufacture_addr, :nex_tag_category, :no_price_message, :offer_support, :on_special, :out_of_stock_behavior,
|
15
|
+
:out_of_stock_message, :overall_quantity_pricing_type, :page_title, :preference_criterion, :presentation_item_list,
|
16
|
+
:prices_include_tax, :producer, :product_feed_list, :rate, :related_items_description, :sales_description,
|
17
|
+
:schedule_b_code, :schedule_b_number, :schedule_b_quantity, :search_keywords, :ship_individually, :shipping_cost,
|
18
|
+
:shipping_cost_units, :shopping_dot_com_category, :shopzilla_category_id, :show_default_donation_amount,
|
19
|
+
:site_category_list, :sitemap_priority, :soft_descriptor, :specials_description, :stock_description, :store_description,
|
20
|
+
:store_detailed_description, :store_display_name, :translations_list, :upc_code, :url_component, :use_marginal_rates,
|
21
|
+
:vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units
|
22
|
+
].each do |field|
|
23
|
+
expect(item).to have_field(field)
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO there is a probably a more robust way to test this
|
27
|
+
expect(item.custom_field_list.class).to eq(NetSuite::Records::CustomFieldList)
|
28
|
+
expect(item.pricing_matrix.class).to eq(NetSuite::Records::PricingMatrix)
|
29
|
+
expect(item.subsidiary_list.class).to eq(NetSuite::Records::RecordRefList)
|
30
|
+
expect(item.item_vendor_list.class).to eq(NetSuite::Records::ItemVendorList)
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'has the right record_refs' do
|
35
|
+
[
|
36
|
+
:billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account,
|
37
|
+
:issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code,
|
38
|
+
:quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :store_display_image,
|
39
|
+
:store_display_thumbnail, :store_item_template, :tax_schedule, :units_type, :expense_account
|
40
|
+
].each do |record_ref|
|
41
|
+
expect(item).to have_record_ref(record_ref)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '.get' do
|
46
|
+
context 'when the response is successful' do
|
47
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :manufacturer_zip => '90401' }) }
|
48
|
+
|
49
|
+
it 'returns a NonInventoryResaleItem instance populated with the data from the response object' do
|
50
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::NonInventoryResaleItem, {:external_id => 20}], {}).and_return(response)
|
51
|
+
customer = NetSuite::Records::NonInventoryResaleItem.get(:external_id => 20)
|
52
|
+
expect(customer).to be_kind_of(NetSuite::Records::NonInventoryResaleItem)
|
53
|
+
expect(customer.manufacturer_zip).to eql('90401')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context 'when the response is unsuccessful' do
|
58
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
59
|
+
|
60
|
+
it 'raises a RecordNotFound exception' do
|
61
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::NonInventoryResaleItem, {:external_id => 20}], {}).and_return(response)
|
62
|
+
expect {
|
63
|
+
NetSuite::Records::NonInventoryResaleItem.get(:external_id => 20)
|
64
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
65
|
+
/NetSuite::Records::NonInventoryResaleItem with OPTIONS=(.*) could not be found/)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe '#add' do
|
71
|
+
context 'when the response is successful' do
|
72
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
73
|
+
|
74
|
+
it 'returns true' do
|
75
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
76
|
+
with([item], {}).
|
77
|
+
and_return(response)
|
78
|
+
expect(item.add).to be_truthy
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when the response is unsuccessful' do
|
83
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
84
|
+
|
85
|
+
it 'returns false' do
|
86
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
87
|
+
with([item], {}).
|
88
|
+
and_return(response)
|
89
|
+
expect(item.add).to be_falsey
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#update' do
|
95
|
+
context 'when the response is successful' do
|
96
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
97
|
+
|
98
|
+
it 'returns true' do
|
99
|
+
expect(NetSuite::Actions::Update).to receive(:call).
|
100
|
+
with([item.class, {external_id: 'foo'}], {}).
|
101
|
+
and_return(response)
|
102
|
+
item.external_id = 'foo'
|
103
|
+
expect(item.update).to be_truthy
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'when the response is unsuccessful' do
|
108
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
109
|
+
|
110
|
+
it 'returns false' do
|
111
|
+
expect(NetSuite::Actions::Update).to receive(:call).
|
112
|
+
with([item.class, {external_id: 'foo'}], {}).
|
113
|
+
and_return(response)
|
114
|
+
item.external_id = 'foo'
|
115
|
+
expect(item.update).to be_falsey
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe '#delete' do
|
121
|
+
context 'when the response is successful' do
|
122
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
123
|
+
|
124
|
+
it 'returns true' do
|
125
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
126
|
+
with([item], {}).
|
127
|
+
and_return(response)
|
128
|
+
expect(item.delete).to be_truthy
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context 'when the response is unsuccessful' do
|
133
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
134
|
+
|
135
|
+
it 'returns false' do
|
136
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
137
|
+
with([item], {}).
|
138
|
+
and_return(response)
|
139
|
+
expect(item.delete).to be_falsey
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe '#to_record' do
|
145
|
+
before do
|
146
|
+
item.handling_cost = 100.0
|
147
|
+
item.is_online = true
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'can represent itself as a SOAP record' do
|
151
|
+
record = {
|
152
|
+
'listAcct:handlingCost' => 100.0,
|
153
|
+
'listAcct:isOnline' => true
|
154
|
+
}
|
155
|
+
expect(item.to_record).to eql(record)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe '#record_type' do
|
160
|
+
it 'returns a string of the SOAP type' do
|
161
|
+
expect(item.record_type).to eql('listAcct:NonInventoryResaleItem')
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|