netsuite 0.8.1 → 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 +111 -31
- data/circle.yml +33 -13
- data/lib/netsuite.rb +40 -19
- data/lib/netsuite/actions/login.rb +25 -2
- 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 +3 -0
- data/lib/netsuite/passports/token.rb +1 -1
- 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.rb +3 -1
- data/lib/netsuite/records/cash_refund_item.rb +1 -1
- data/lib/netsuite/records/classification.rb +5 -2
- data/lib/netsuite/records/contact.rb +2 -1
- data/lib/netsuite/records/contact_addressbook.rb +64 -0
- data/lib/netsuite/records/contact_addressbook_list.rb +11 -0
- 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 +2 -2
- 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_adjustment.rb +1 -1
- data/lib/netsuite/records/inventory_adjustment_inventory.rb +1 -1
- data/lib/netsuite/records/inventory_item.rb +2 -2
- data/lib/netsuite/records/invoice.rb +1 -1
- data/lib/netsuite/records/item_fulfillment.rb +1 -1
- data/lib/netsuite/records/lot_numbered_assembly_item.rb +64 -0
- 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 +2 -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 +2 -1
- data/lib/netsuite/records/support_case.rb +1 -1
- data/lib/netsuite/records/support_case_type.rb +26 -0
- data/lib/netsuite/records/task.rb +2 -1
- 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/transfer_order_item.rb +2 -2
- 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 +86 -21
- data/lib/netsuite/version.rb +2 -2
- data/netsuite.gemspec +5 -4
- 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 +12 -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/invoice_spec.rb +2 -2
- 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_list_spec.rb +2 -2
- 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 +104 -8
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::PriceLevel do
|
4
|
+
describe "#initialize" do
|
5
|
+
it "behaves appropriately if it gets a hash as attributes[:pricing]" do
|
6
|
+
# this is what savon returns if there is only one pricing strategy matrix
|
7
|
+
# for the item:
|
8
|
+
level = {
|
9
|
+
:name => 'Base Price'
|
10
|
+
}
|
11
|
+
|
12
|
+
subject = NetSuite::Records::PriceLevel.new(level)
|
13
|
+
expect(subject.name).to eq(level[:name])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -5,21 +5,23 @@ describe NetSuite::Records::PricingMatrix do
|
|
5
5
|
it "behaves appropriately if it gets a hash as attributes[:pricing]" do
|
6
6
|
# this is what savon returns if there is only one pricing strategy matrix
|
7
7
|
# for the item:
|
8
|
-
matrix =
|
9
|
-
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
matrix = [
|
9
|
+
{
|
10
|
+
currency: { internal_id: 1 },
|
11
|
+
price_level: { internal_id: 1 },
|
12
|
+
price_list: {
|
13
|
+
price: [
|
14
|
+
{
|
15
|
+
value: 25.0,
|
16
|
+
quantity: 0
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
18
20
|
}
|
19
|
-
|
21
|
+
]
|
20
22
|
|
21
|
-
subject =
|
22
|
-
expect(subject.
|
23
|
+
subject = described_class.new({pricing: matrix})
|
24
|
+
expect(subject.pricing[0]).to be_kind_of(NetSuite::Records::Pricing)
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -16,8 +16,8 @@ describe NetSuite::Records::ReturnAuthorizationItemList do
|
|
16
16
|
|
17
17
|
it 'can represent itself as a SOAP record' do
|
18
18
|
record = {
|
19
|
-
'
|
20
|
-
'
|
19
|
+
'tranCust:item' => [{
|
20
|
+
'tranCust:rate' => 10
|
21
21
|
}]
|
22
22
|
}
|
23
23
|
expect(list.to_record).to eql(record)
|
@@ -8,7 +8,7 @@ describe NetSuite::Records::ReturnAuthorizationItem do
|
|
8
8
|
:alt_sales_amt, :amortization_period, :amortization_type, :amount, :bill_variance_status, :catch_up_period, :cost_estimate,
|
9
9
|
:cost_estimate_rate, :cost_estimate_type, :days_before_expiration, :defer_rev_rec, :description, :gift_cert_from, :gift_cert_message,
|
10
10
|
:gift_cert_recipient_email, :gift_cert_recipient_name, :id, :inventory_detail, :is_closed, :is_drop_shipment, :is_taxable,
|
11
|
-
:is_vsoe_bundle, :item_subtype, :item_type, :line, :line_number, :matrix_type, :options, :print_items,
|
11
|
+
:is_vsoe_bundle, :item_subtype, :item_type, :line, :line_number, :matrix_type, :options, :order_line, :print_items,
|
12
12
|
:quantity, :quantity_billed, :quantity_received, :quantity_rev_committed, :rate, :rate_schedule, :rev_rec_end_date,
|
13
13
|
:rev_rec_start_date, :tax_rate1, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_is_estimate,
|
14
14
|
:vsoe_permit_discount, :vsoe_price, :vsoe_sop_group
|
@@ -5,11 +5,17 @@ describe NetSuite::Records::SalesOrderItem do
|
|
5
5
|
|
6
6
|
it 'has all the right fields' do
|
7
7
|
[
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
:amount, :bin_numbers, :cost_estimate, :cost_estimate_type,
|
9
|
+
:defer_rev_rec, :description, :expand_item_group,
|
10
|
+
:gift_cert_from, :gift_cert_message, :gift_cert_number,
|
11
|
+
:gift_cert_recipient_email, :gift_cert_recipient_name,
|
12
|
+
:gross_amt, :is_taxable, :line, :order_line, :po_currency,
|
13
|
+
:quantity, :quantity_back_ordered, :quantity_billed,
|
14
|
+
:quantity_committed, :quantity_fulfilled,
|
15
|
+
:rate, :rev_rec_end_date, :rev_rec_start_date,
|
16
|
+
:rev_rec_term_in_months, :serial_numbers, :tax1_amt, :tax_rate1,
|
17
|
+
:tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral,
|
18
|
+
:vsoe_delivered, :vsoe_permit_discount, :vsoe_price
|
13
19
|
].each do |field|
|
14
20
|
expect(item).to have_field(field)
|
15
21
|
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::ServiceResaleItem do
|
4
|
+
let(:item) { NetSuite::Records::ServiceResaleItem.new }
|
5
|
+
|
6
|
+
it 'has the right fields' do
|
7
|
+
[
|
8
|
+
:available_to_partners, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date,
|
9
|
+
:display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description,
|
10
|
+
:include_children, :is_donation_item, :is_fulfillable, :is_gco_compliant, :is_inactive, :is_online, :is_taxable,
|
11
|
+
:item_id, :last_modified_date, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html,
|
12
|
+
:minimum_quantity, :minimum_quantity_units, :no_price_message, :offer_support, :on_special, :out_of_stock_behavior,
|
13
|
+
:out_of_stock_message, :overall_quantity_pricing_type, :page_title, :presentation_item_list, :prices_include_tax,
|
14
|
+
:show_default_donation_amount, :site_category_list, :sitemap_priority, :soft_descriptor, :specials_description,
|
15
|
+
:store_description, :store_detailed_description, :store_display_name, :translations_list, :upc_code, :url_component,
|
16
|
+
:use_marginal_rates, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :vsoe_sop_group
|
17
|
+
].each do |field|
|
18
|
+
expect(item).to have_field(field)
|
19
|
+
end
|
20
|
+
|
21
|
+
# TODO there is a probably a more robust way to test this
|
22
|
+
expect(item.custom_field_list.class).to eq(NetSuite::Records::CustomFieldList)
|
23
|
+
expect(item.pricing_matrix.class).to eq(NetSuite::Records::PricingMatrix)
|
24
|
+
expect(item.subsidiary_list.class).to eq(NetSuite::Records::RecordRefList)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'has the right record_refs' do
|
28
|
+
[
|
29
|
+
:billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_account,
|
30
|
+
:issue_product, :item_options_list, :klass, :location, :parent, :pricing_group, :purchase_tax_code,
|
31
|
+
:quantity_pricing_schedule, :rev_rec_schedule, :sale_unit, :sales_tax_code, :store_display_image,
|
32
|
+
:store_display_thumbnail, :store_item_template, :tax_schedule, :units_type
|
33
|
+
].each do |record_ref|
|
34
|
+
expect(item).to have_record_ref(record_ref)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.get' do
|
39
|
+
context 'when the response is successful' do
|
40
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :item_id => 'penguins' }) }
|
41
|
+
|
42
|
+
it 'returns a ServiceResaleItem instance populated with the data from the response object' do
|
43
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::ServiceResaleItem, :external_id => 20], {}).and_return(response)
|
44
|
+
customer = NetSuite::Records::ServiceResaleItem.get(:external_id => 20)
|
45
|
+
expect(customer).to be_kind_of(NetSuite::Records::ServiceResaleItem)
|
46
|
+
expect(customer.item_id).to eql('penguins')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when the response is unsuccessful' do
|
51
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
52
|
+
|
53
|
+
it 'raises a RecordNotFound exception' do
|
54
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::ServiceResaleItem, :external_id => 20], {}).and_return(response)
|
55
|
+
expect {
|
56
|
+
NetSuite::Records::ServiceResaleItem.get(:external_id => 20)
|
57
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
58
|
+
/NetSuite::Records::ServiceResaleItem with OPTIONS=(.*) could not be found/)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#add' do
|
64
|
+
let(:item) { NetSuite::Records::ServiceResaleItem.new(:cost => 100, :is_inactive => false) }
|
65
|
+
|
66
|
+
context 'when the response is successful' do
|
67
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
68
|
+
|
69
|
+
it 'returns true' do
|
70
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
71
|
+
with([item], {}).
|
72
|
+
and_return(response)
|
73
|
+
expect(item.add).to be_truthy
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when the response is unsuccessful' do
|
78
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
79
|
+
|
80
|
+
it 'returns false' do
|
81
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
82
|
+
with([item], {}).
|
83
|
+
and_return(response)
|
84
|
+
expect(item.add).to be_falsey
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#delete' do
|
90
|
+
context 'when the response is successful' do
|
91
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
92
|
+
|
93
|
+
it 'returns true' do
|
94
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
95
|
+
with([item], {}).
|
96
|
+
and_return(response)
|
97
|
+
expect(item.delete).to be_truthy
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'when the response is unsuccessful' do
|
102
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
103
|
+
|
104
|
+
it 'returns false' do
|
105
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
106
|
+
with([item], {}).
|
107
|
+
and_return(response)
|
108
|
+
expect(item.delete).to be_falsey
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#to_record' do
|
114
|
+
before do
|
115
|
+
item.item_id = 'penguins'
|
116
|
+
item.is_online = true
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'can represent itself as a SOAP record' do
|
120
|
+
record = {
|
121
|
+
'listAcct:itemId' => 'penguins',
|
122
|
+
'listAcct:isOnline' => true
|
123
|
+
}
|
124
|
+
expect(item.to_record).to eql(record)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#record_type' do
|
129
|
+
it 'returns a string of the SOAP type' do
|
130
|
+
expect(item.record_type).to eql('listAcct:ServiceResaleItem')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::SupportCaseType do
|
4
|
+
let(:support_case_type) { NetSuite::Records::SupportCaseType.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:description, :is_inactive, :name
|
9
|
+
].each do |field|
|
10
|
+
expect(support_case_type).to have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has the right record_refs' do
|
15
|
+
[
|
16
|
+
:insert_before
|
17
|
+
].each do |record_ref|
|
18
|
+
expect(support_case_type).to have_record_ref(record_ref)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe NetSuite::Records::TransactionBodyCustomField do
|
4
|
+
describe ".get" do
|
5
|
+
context "success" do
|
6
|
+
let(:internal_id) { 1 }
|
7
|
+
let(:response) do
|
8
|
+
NetSuite::Response.new(
|
9
|
+
success: true,
|
10
|
+
body: {
|
11
|
+
access_level: "_edit",
|
12
|
+
field_type: "_freeFormText",
|
13
|
+
label: "Billing System Subdomain",
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns a TransactionColumnCustomField instance with populated fields" do
|
19
|
+
expect(NetSuite::Actions::Get)
|
20
|
+
.to receive(:call)
|
21
|
+
.with([NetSuite::Records::TransactionBodyCustomField, internal_id: internal_id], {})
|
22
|
+
.and_return(response)
|
23
|
+
|
24
|
+
record = NetSuite::Records::TransactionBodyCustomField.get(internal_id: internal_id)
|
25
|
+
|
26
|
+
expect(record.access_level).to eql("_edit")
|
27
|
+
expect(record.field_type).to eql("_freeFormText")
|
28
|
+
expect(record.label).to eql("Billing System Subdomain")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe NetSuite::Records::TransactionColumnCustomField do
|
4
|
+
describe ".get" do
|
5
|
+
context "success" do
|
6
|
+
let(:internal_id) { 1 }
|
7
|
+
let(:response) do
|
8
|
+
NetSuite::Response.new(
|
9
|
+
success: true,
|
10
|
+
body: {
|
11
|
+
access_level: "_none",
|
12
|
+
field_type: "_decimalNumber",
|
13
|
+
label: "Billing System Tax",
|
14
|
+
}
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "returns a TransactionColumnCustomField instance with populated fields" do
|
19
|
+
expect(NetSuite::Actions::Get)
|
20
|
+
.to receive(:call)
|
21
|
+
.with([NetSuite::Records::TransactionColumnCustomField, internal_id: internal_id], {})
|
22
|
+
.and_return(response)
|
23
|
+
|
24
|
+
record = NetSuite::Records::TransactionColumnCustomField.get(internal_id: internal_id)
|
25
|
+
|
26
|
+
expect(record.access_level).to eql("_none")
|
27
|
+
expect(record.field_type).to eql("_decimalNumber")
|
28
|
+
expect(record.label).to eql("Billing System Tax")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::VendorCredit do
|
4
|
+
describe '.get' do
|
5
|
+
context 'when the response is successful' do
|
6
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :@internal_id => '1', :@external_id =>'some_id' }) }
|
7
|
+
|
8
|
+
it 'returns a VendorCredit instance populated with the data from the response object' do
|
9
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::VendorCredit, external_id: 'some_id'], {}).and_return(response)
|
10
|
+
vendor_credit = NetSuite::Records::VendorCredit.get(external_id: 'some_id')
|
11
|
+
expect(vendor_credit).to be_kind_of(NetSuite::Records::VendorCredit)
|
12
|
+
expect(vendor_credit.internal_id).to eq('1')
|
13
|
+
expect(vendor_credit.external_id).to eq('some_id')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when the response is unsuccessful' do
|
18
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
19
|
+
|
20
|
+
it 'raises a RecordNotFound exception' do
|
21
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::VendorCredit, external_id: 'some_id'], {}).and_return(response)
|
22
|
+
expect {
|
23
|
+
NetSuite::Records::VendorCredit.get(external_id: 'some_id')
|
24
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
25
|
+
/NetSuite::Records::VendorCredit with OPTIONS=(.*) could not be found/)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Support::SearchResult do
|
4
|
+
describe '#results' do
|
5
|
+
context 'empty page' do
|
6
|
+
it 'returns empty array' do
|
7
|
+
response_body = {
|
8
|
+
:status => {:@is_success=>"true"},
|
9
|
+
:total_records => "242258",
|
10
|
+
:page_size => "10",
|
11
|
+
:total_pages => "24226",
|
12
|
+
:page_index => "99",
|
13
|
+
:search_id => "WEBSERVICES_4132604_SB1_051620191060155623420663266_336cbf12",
|
14
|
+
:record_list => nil,
|
15
|
+
:"@xmlns:platform_core" => "urn:core_2016_2.platform.webservices.netsuite.com"
|
16
|
+
}
|
17
|
+
response = NetSuite::Response.new(body: response_body)
|
18
|
+
|
19
|
+
results = described_class.new(response, NetSuite::Actions::Search, {}).results
|
20
|
+
expect(results).to eq []
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -3,14 +3,52 @@ require 'spec_helper'
|
|
3
3
|
describe NetSuite::Utilities do
|
4
4
|
describe 'time utilities' do
|
5
5
|
it '#normalize_time_to_netsuite_date' do
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
['Etc/UTC', 'America/Los_Angeles', 'America/Denver'].each do |zone|
|
7
|
+
ENV['TZ'] = zone
|
8
|
+
puts "In zone: #{zone}"
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
stamp = DateTime.parse('Wed, 27 Jul 2016 00:00:00 -0000')
|
11
|
+
formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(stamp.to_time.to_i)
|
12
|
+
expect(formatted_date).to eq('2016-07-27T00:00:00-07:00')
|
13
|
+
|
14
|
+
no_dst_stamp = DateTime.parse('Sun, November 6 2017 00:00:00 -0000')
|
15
|
+
formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(no_dst_stamp.to_time.to_i)
|
16
|
+
expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
|
17
|
+
|
18
|
+
no_dst_stamp_with_time = DateTime.parse('Sun, November 6 2017 12:11:10 -0000')
|
19
|
+
formatted_date = NetSuite::Utilities.normalize_time_to_netsuite_date(no_dst_stamp_with_time.to_time.to_i)
|
20
|
+
expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "#netsuite_data_center_urls" do
|
26
|
+
domains = NetSuite::Utilities.netsuite_data_center_urls('TSTDRV1576318')
|
27
|
+
expect(domains[:webservices_domain]).to eq('https://tstdrv1576318.suitetalk.api.netsuite.com')
|
28
|
+
expect(domains[:system_domain]).to eq('https://tstdrv1576318.app.netsuite.com')
|
29
|
+
|
30
|
+
# ensure domains returned don't change when sandbox is enabled
|
31
|
+
NetSuite.configure do
|
32
|
+
reset!
|
33
|
+
sandbox true
|
34
|
+
end
|
35
|
+
|
36
|
+
domains = NetSuite::Utilities.netsuite_data_center_urls('TSTDRV1576318')
|
37
|
+
expect(domains[:webservices_domain]).to eq('https://tstdrv1576318.suitetalk.api.netsuite.com')
|
38
|
+
expect(domains[:system_domain]).to eq('https://tstdrv1576318.app.netsuite.com')
|
39
|
+
|
40
|
+
NetSuite.configure do
|
41
|
+
reset!
|
42
|
+
api_version '2015_1'
|
13
43
|
end
|
44
|
+
|
45
|
+
domains = NetSuite::Utilities.netsuite_data_center_urls('TSTDRV1576318')
|
46
|
+
expect(domains[:webservices_domain]).to eq('https://tstdrv1576318.suitetalk.api.netsuite.com')
|
47
|
+
expect(domains[:system_domain]).to eq('https://tstdrv1576318.app.netsuite.com')
|
48
|
+
|
49
|
+
domains = NetSuite::Utilities.netsuite_data_center_urls('4810331')
|
50
|
+
expect(domains[:webservices_domain]).to eq('https://4810331.suitetalk.api.netsuite.com')
|
51
|
+
expect(domains[:system_domain]).to eq('https://4810331.app.netsuite.com')
|
14
52
|
end
|
15
53
|
|
16
54
|
describe '#get_record' do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..') ))
|
2
2
|
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler/setup"
|
5
|
+
|
6
|
+
Bundler.require
|
7
|
+
|
3
8
|
# https://circleci.com/docs/code-coverage
|
4
9
|
if ENV['CIRCLE_ARTIFACTS']
|
5
10
|
require 'simplecov'
|
@@ -8,10 +13,6 @@ if ENV['CIRCLE_ARTIFACTS']
|
|
8
13
|
SimpleCov.start
|
9
14
|
end
|
10
15
|
|
11
|
-
require 'rspec'
|
12
|
-
require 'netsuite'
|
13
|
-
require 'pry'
|
14
|
-
|
15
16
|
# Requires supporting ruby files with custom matchers and macros, etc,
|
16
17
|
# in spec/support/ and its subdirectories.
|
17
18
|
Dir['spec/support/**/*.rb'].each { |f| require f }
|