netsuite 0.8.2 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.ruby-version +1 -1
  4. data/Gemfile +7 -2
  5. data/README.md +107 -32
  6. data/circle.yml +33 -13
  7. data/lib/netsuite.rb +36 -19
  8. data/lib/netsuite/actions/login.rb +20 -1
  9. data/lib/netsuite/actions/search.rb +1 -6
  10. data/lib/netsuite/actions/update.rb +6 -2
  11. data/lib/netsuite/actions/update_list.rb +109 -0
  12. data/lib/netsuite/actions/upsert.rb +2 -0
  13. data/lib/netsuite/configuration.rb +21 -4
  14. data/lib/netsuite/errors.rb +1 -0
  15. data/lib/netsuite/records/assembly_build.rb +4 -1
  16. data/lib/netsuite/records/assembly_item.rb +1 -0
  17. data/lib/netsuite/records/assembly_unbuild.rb +3 -0
  18. data/lib/netsuite/records/bin_number.rb +18 -0
  19. data/lib/netsuite/records/bin_number_list.rb +1 -20
  20. data/lib/netsuite/records/bin_transfer.rb +38 -0
  21. data/lib/netsuite/records/bin_transfer_inventory.rb +20 -0
  22. data/lib/netsuite/records/bin_transfer_inventory_list.rb +10 -0
  23. data/lib/netsuite/records/cash_refund_item.rb +1 -1
  24. data/lib/netsuite/records/classification.rb +5 -2
  25. data/lib/netsuite/records/custom_field_list.rb +10 -2
  26. data/lib/netsuite/records/custom_record.rb +3 -3
  27. data/lib/netsuite/records/custom_record_ref.rb +1 -0
  28. data/lib/netsuite/records/customer.rb +5 -4
  29. data/lib/netsuite/records/customer_credit_cards.rb +36 -0
  30. data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
  31. data/lib/netsuite/records/customer_deposit.rb +5 -2
  32. data/lib/netsuite/records/customer_payment.rb +1 -0
  33. data/lib/netsuite/records/customer_sales_team.rb +24 -0
  34. data/lib/netsuite/records/customer_sales_team_list.rb +9 -0
  35. data/lib/netsuite/records/customer_status.rb +29 -0
  36. data/lib/netsuite/records/customer_subscription.rb +18 -0
  37. data/lib/netsuite/records/customer_subscriptions_list.rb +10 -0
  38. data/lib/netsuite/records/employee.rb +1 -1
  39. data/lib/netsuite/records/entity_custom_field.rb +53 -0
  40. data/lib/netsuite/records/estimate.rb +42 -0
  41. data/lib/netsuite/records/estimate_item.rb +40 -0
  42. data/lib/netsuite/records/estimate_item_list.rb +11 -0
  43. data/lib/netsuite/records/inbound_shipment.rb +33 -0
  44. data/lib/netsuite/records/inbound_shipment_item.rb +39 -0
  45. data/lib/netsuite/records/inbound_shipment_item_list.rb +11 -0
  46. data/lib/netsuite/records/inter_company_journal_entry.rb +48 -0
  47. data/lib/netsuite/records/inter_company_journal_entry_line.rb +28 -0
  48. data/lib/netsuite/records/inter_company_journal_entry_line_list.rb +14 -0
  49. data/lib/netsuite/records/inventory_item.rb +1 -1
  50. data/lib/netsuite/records/invoice.rb +1 -1
  51. data/lib/netsuite/records/item_fulfillment.rb +1 -1
  52. data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
  53. data/lib/netsuite/records/matrix_option_list.rb +12 -4
  54. data/lib/netsuite/records/message.rb +30 -0
  55. data/lib/netsuite/records/non_inventory_resale_item.rb +3 -2
  56. data/lib/netsuite/records/non_inventory_sale_item.rb +1 -1
  57. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  58. data/lib/netsuite/records/partner.rb +1 -1
  59. data/lib/netsuite/records/price.rb +17 -0
  60. data/lib/netsuite/records/price_level.rb +26 -0
  61. data/lib/netsuite/records/price_list.rb +9 -0
  62. data/lib/netsuite/records/pricing.rb +20 -0
  63. data/lib/netsuite/records/pricing_matrix.rb +2 -2
  64. data/lib/netsuite/records/promotions.rb +26 -0
  65. data/lib/netsuite/records/promotions_list.rb +9 -0
  66. data/lib/netsuite/records/return_authorization_item.rb +1 -1
  67. data/lib/netsuite/records/sales_order.rb +1 -0
  68. data/lib/netsuite/records/sales_order_item.rb +12 -5
  69. data/lib/netsuite/records/sales_role.rb +26 -0
  70. data/lib/netsuite/records/sales_tax_item.rb +3 -1
  71. data/lib/netsuite/records/serialized_assembly_item.rb +239 -0
  72. data/lib/netsuite/records/service_resale_item.rb +1 -1
  73. data/lib/netsuite/records/service_sale_item.rb +1 -1
  74. data/lib/netsuite/records/support_case.rb +1 -1
  75. data/lib/netsuite/records/support_case_type.rb +26 -0
  76. data/lib/netsuite/records/tax_group.rb +2 -2
  77. data/lib/netsuite/records/transaction_body_custom_field.rb +61 -0
  78. data/lib/netsuite/records/transaction_column_custom_field.rb +59 -0
  79. data/lib/netsuite/records/vendor_credit.rb +2 -0
  80. data/lib/netsuite/records/work_order.rb +8 -0
  81. data/lib/netsuite/support/actions.rb +2 -0
  82. data/lib/netsuite/support/country.rb +27 -15
  83. data/lib/netsuite/support/search_result.rb +20 -5
  84. data/lib/netsuite/utilities.rb +83 -21
  85. data/lib/netsuite/version.rb +1 -1
  86. data/netsuite.gemspec +4 -3
  87. data/spec/netsuite/actions/login_spec.rb +23 -0
  88. data/spec/netsuite/actions/update_list_spec.rb +107 -0
  89. data/spec/netsuite/actions/update_spec.rb +42 -0
  90. data/spec/netsuite/configuration_spec.rb +79 -6
  91. data/spec/netsuite/records/address_spec.rb +10 -0
  92. data/spec/netsuite/records/basic_record_spec.rb +11 -1
  93. data/spec/netsuite/records/bin_number_spec.rb +23 -0
  94. data/spec/netsuite/records/classification_spec.rb +10 -1
  95. data/spec/netsuite/records/custom_field_list_spec.rb +39 -4
  96. data/spec/netsuite/records/custom_record_spec.rb +1 -1
  97. data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
  98. data/spec/netsuite/records/customer_sales_team_list_spec.rb +41 -0
  99. data/spec/netsuite/records/customer_spec.rb +44 -2
  100. data/spec/netsuite/records/customer_subscription_spec.rb +41 -0
  101. data/spec/netsuite/records/customer_subscriptions_list_spec.rb +19 -0
  102. data/spec/netsuite/records/employee_spec.rb +2 -2
  103. data/spec/netsuite/records/entity_custom_field_spec.rb +34 -0
  104. data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
  105. data/spec/netsuite/records/estimate_item_spec.rb +40 -0
  106. data/spec/netsuite/records/estimate_spec.rb +216 -0
  107. data/spec/netsuite/records/inter_company_journal_entry_line_list_spec.rb +26 -0
  108. data/spec/netsuite/records/inter_company_journal_entry_line_spec.rb +60 -0
  109. data/spec/netsuite/records/inter_company_journal_entry_spec.rb +156 -0
  110. data/spec/netsuite/records/inventory_item_spec.rb +57 -0
  111. data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
  112. data/spec/netsuite/records/message_spec.rb +49 -0
  113. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
  114. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
  115. data/spec/netsuite/records/partner_spec.rb +141 -0
  116. data/spec/netsuite/records/price_level_spec.rb +16 -0
  117. data/spec/netsuite/records/pricing_matrix_spec.rb +15 -13
  118. data/spec/netsuite/records/return_authorization_item_spec.rb +1 -1
  119. data/spec/netsuite/records/sales_order_item_spec.rb +11 -5
  120. data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
  121. data/spec/netsuite/records/support_case_type_spec.rb +22 -0
  122. data/spec/netsuite/records/transaction_body_custom_field_spec.rb +32 -0
  123. data/spec/netsuite/records/transaction_column_custom_field_spec.rb +32 -0
  124. data/spec/netsuite/records/vendor_credit_spec.rb +29 -0
  125. data/spec/netsuite/support/search_result_spec.rb +24 -0
  126. data/spec/netsuite/utilities_spec.rb +44 -6
  127. data/spec/spec_helper.rb +5 -4
  128. data/spec/support/fixtures/update_list/update_list_items.xml +22 -0
  129. data/spec/support/fixtures/update_list/update_list_one_item.xml +18 -0
  130. data/spec/support/fixtures/update_list/update_list_with_errors.xml +32 -0
  131. metadata +101 -8
@@ -6,7 +6,7 @@ describe NetSuite::Records::NonInventorySaleItem do
6
6
  it 'has the right fields' do
7
7
  [
8
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,
9
+ :direct_revenue_posting, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap,
10
10
  :featured_description, :handling_cost, :handling_cost_units, :include_children, :is_donation_item, :is_fulfillable,
11
11
  :is_gco_compliant, :is_inactive, :is_online, :is_taxable, :item_id, :last_modified_date, :manufacturer, :manufacturer_addr1,
12
12
  :manufacturer_city, :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id, :manufacturer_zip, :matrix_option_list,
@@ -0,0 +1,141 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::Partner do
4
+ let(:partner) { NetSuite::Records::Partner.new }
5
+
6
+ it 'has all the right fields' do
7
+ [
8
+ :phone, :home_phone, :first_name, :last_name, :alt_name, :is_inactive, :email, :give_access,
9
+ :partner_code, :is_person, :company_name, :eligible_for_commission, :entity_id, :last_modified_date,
10
+ :date_created, :title, :mobile_phone, :comments, :middle_name, :send_email, :password, :password2
11
+ ].each do |field|
12
+ expect(partner).to have_field(field)
13
+ end
14
+ end
15
+
16
+ it 'has all the right record refs' do
17
+ [
18
+ :klass, :access_role, :department, :subsidiary
19
+ ].each do |record_ref|
20
+ expect(partner).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 => { :account_number => 7 }) }
27
+
28
+ it 'returns an Partner instance populated with the data from the response object' do
29
+ expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Partner, { :external_id => 1 }], {}).and_return(response)
30
+ Partner = NetSuite::Records::Partner.get(:external_id => 1)
31
+ expect(Partner).to be_kind_of(NetSuite::Records::Partner)
32
+ end
33
+ end
34
+
35
+ context 'when the response is unsuccessful' do
36
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
37
+
38
+ it 'raises a RecordNotFound exception' do
39
+ expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Partner, { :external_id => 1 }], {}).and_return(response)
40
+ expect {
41
+ NetSuite::Records::Partner.get(:external_id => 1)
42
+ }.to raise_error(NetSuite::RecordNotFound,
43
+ /NetSuite::Records::Partner with OPTIONS=(.*) could not be found/)
44
+ end
45
+ end
46
+ end
47
+
48
+ describe '#add' do
49
+ let(:partner) { NetSuite::Records::Partner.new(:email => 'dale.cooper@example.com') }
50
+
51
+ context 'when the response is successful' do
52
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
53
+
54
+ it 'returns true' do
55
+ expect(NetSuite::Actions::Add).to receive(:call).
56
+ with([partner], {}).
57
+ and_return(response)
58
+ expect(partner.add).to be_truthy
59
+ end
60
+ end
61
+
62
+ context 'when the response is unsuccessful' do
63
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
64
+
65
+ it 'returns false' do
66
+ expect(NetSuite::Actions::Add).to receive(:call).
67
+ with([partner], {}).
68
+ and_return(response)
69
+ expect(partner.add).to be_falsey
70
+ end
71
+ end
72
+ end
73
+
74
+ describe '#delete' do
75
+ context 'when the response is successful' do
76
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
77
+
78
+ it 'returns true' do
79
+ expect(NetSuite::Actions::Delete).to receive(:call).
80
+ with([partner], {}).
81
+ and_return(response)
82
+ expect(partner.delete).to be_truthy
83
+ end
84
+ end
85
+
86
+ context 'when the response is unsuccessful' do
87
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
88
+
89
+ it 'returns false' do
90
+ expect(NetSuite::Actions::Delete).to receive(:call).
91
+ with([partner], {}).
92
+ and_return(response)
93
+ expect(partner.delete).to be_falsey
94
+ end
95
+ end
96
+ end
97
+
98
+ describe '.update' do
99
+ context 'when the response is successful' do
100
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :email => 'leland.palmer@example.com' }) }
101
+
102
+ it 'returns true' do
103
+ expect(NetSuite::Actions::Update).to receive(:call).with([NetSuite::Records::Partner, { :internal_id => 1, :email => 'leland.palmer@example.com' }], {}).and_return(response)
104
+ partner = NetSuite::Records::Partner.new(:internal_id => 1)
105
+ expect(partner.update(:email => 'leland.palmer@example.com')).to be_truthy
106
+ end
107
+ end
108
+
109
+ context 'when the response is unsuccessful' do
110
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
111
+
112
+ it 'raises a RecordNotFound exception' do
113
+ expect(NetSuite::Actions::Update).to receive(:call).with([NetSuite::Records::Partner, { :internal_id => 1, :account_number => 7 }], {}).and_return(response)
114
+ partner = NetSuite::Records::Partner.new(:internal_id => 1)
115
+ expect(partner.update(:account_number => 7)).to be_falsey
116
+ end
117
+ end
118
+ end
119
+
120
+ describe '#to_record' do
121
+ let(:partner) { NetSuite::Records::Partner.new(:email => 'bob@example.com') }
122
+
123
+ it 'returns a hash of attributes that can be used in a SOAP request' do
124
+ expect(partner.to_record).to eql({ 'listRel:email' => 'bob@example.com' })
125
+ end
126
+ end
127
+
128
+ describe '#record_type' do
129
+ it 'returns a string type for the record to be used in a SOAP request' do
130
+ expect(partner.record_type).to eql('listRel:Partner')
131
+ end
132
+ end
133
+
134
+ it 'has the right record_refs' do
135
+ [
136
+ :klass, :access_role, :department, :subsidiary
137
+ ].each do |record_ref|
138
+ expect(partner).to have_record_ref(record_ref)
139
+ end
140
+ end
141
+ end
@@ -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
- :pricing=> {
10
- :currency=>"US Dollar",
11
- :priceLevel=>"Base Price",
12
- :priceList=>[
13
- {:price=>{:value=>12.0, :quantity=>0.0}},
14
- {:price=>{:value=>10.0, :quantity=>10.0}},
15
- {:price=>{:value=>9.0, :quantity=>100.0}},
16
- {:price=>{:value=>7.0, :quantity=>5000.0}}
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 = NetSuite::Records::PricingMatrix.new({pricing: matrix})
22
- expect(subject.prices[0].pricing).to eq(matrix[:pricing])
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
@@ -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
- :amount, :bin_numbers, :cost_estimate, :cost_estimate_type, :defer_rev_rec, :description, :gift_cert_from,
9
- :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email, :gift_cert_recipient_name, :gross_amt, :is_taxable,
10
- :line, :order_line, :po_currency, :quantity, :rate, :rev_rec_end_date, :rev_rec_start_date, :rev_rec_term_in_months,
11
- :serial_numbers, :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered,
12
- :vsoe_permit_discount, :vsoe_price
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