netsuite 0.8.10 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +1 -0
  3. data/.github/dependabot.yml +14 -0
  4. data/.github/workflows/codeql-analysis.yml +70 -0
  5. data/.github/workflows/main.yml +7 -4
  6. data/Gemfile +5 -3
  7. data/HISTORY.md +56 -2
  8. data/README.md +94 -38
  9. data/lib/netsuite/actions/add.rb +7 -2
  10. data/lib/netsuite/actions/attach_file.rb +87 -0
  11. data/lib/netsuite/actions/delete.rb +18 -1
  12. data/lib/netsuite/actions/delete_list.rb +1 -1
  13. data/lib/netsuite/actions/get.rb +1 -1
  14. data/lib/netsuite/actions/get_deleted.rb +1 -1
  15. data/lib/netsuite/actions/get_list.rb +1 -1
  16. data/lib/netsuite/actions/initialize.rb +2 -2
  17. data/lib/netsuite/actions/search.rb +20 -7
  18. data/lib/netsuite/configuration.rb +16 -3
  19. data/lib/netsuite/records/account.rb +0 -1
  20. data/lib/netsuite/records/accounting_period.rb +1 -1
  21. data/lib/netsuite/records/assembly_component.rb +0 -2
  22. data/lib/netsuite/records/assembly_item.rb +2 -2
  23. data/lib/netsuite/records/assembly_unbuild.rb +0 -1
  24. data/lib/netsuite/records/cash_refund.rb +0 -1
  25. data/lib/netsuite/records/cash_refund_item.rb +1 -1
  26. data/lib/netsuite/records/cash_sale.rb +1 -2
  27. data/lib/netsuite/records/contact.rb +0 -1
  28. data/lib/netsuite/records/credit_memo.rb +1 -1
  29. data/lib/netsuite/records/currency_rate.rb +0 -1
  30. data/lib/netsuite/records/custom_record.rb +1 -1
  31. data/lib/netsuite/records/customer.rb +224 -23
  32. data/lib/netsuite/records/customer_deposit.rb +0 -1
  33. data/lib/netsuite/records/customer_payment.rb +0 -1
  34. data/lib/netsuite/records/customer_refund.rb +1 -2
  35. data/lib/netsuite/records/deposit.rb +0 -1
  36. data/lib/netsuite/records/deposit_application.rb +0 -1
  37. data/lib/netsuite/records/description_item.rb +3 -3
  38. data/lib/netsuite/records/discount_item.rb +1 -1
  39. data/lib/netsuite/records/employee.rb +1 -1
  40. data/lib/netsuite/records/estimate.rb +0 -1
  41. data/lib/netsuite/records/file.rb +1 -1
  42. data/lib/netsuite/records/gift_certificate_item.rb +1 -1
  43. data/lib/netsuite/records/inbound_shipment.rb +0 -1
  44. data/lib/netsuite/records/inventory_item.rb +237 -38
  45. data/lib/netsuite/records/inventory_number.rb +0 -1
  46. data/lib/netsuite/records/invoice.rb +2 -2
  47. data/lib/netsuite/records/item_availability.rb +46 -0
  48. data/lib/netsuite/records/item_fulfillment.rb +4 -2
  49. data/lib/netsuite/records/item_fulfillment_package_fed_ex.rb +28 -0
  50. data/lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb +32 -0
  51. data/lib/netsuite/records/item_fulfillment_package_ups.rb +27 -0
  52. data/lib/netsuite/records/item_fulfillment_package_ups_list.rb +32 -0
  53. data/lib/netsuite/records/item_fulfillment_package_usps.rb +26 -0
  54. data/lib/netsuite/records/item_fulfillment_package_usps_list.rb +32 -0
  55. data/lib/netsuite/records/item_group.rb +3 -3
  56. data/lib/netsuite/records/item_option_custom_field.rb +52 -0
  57. data/lib/netsuite/records/item_receipt.rb +0 -1
  58. data/lib/netsuite/records/item_vendor.rb +10 -1
  59. data/lib/netsuite/records/job.rb +0 -1
  60. data/lib/netsuite/records/kit_item.rb +2 -2
  61. data/lib/netsuite/records/location.rb +0 -1
  62. data/lib/netsuite/records/lot_numbered_assembly_item.rb +1 -1
  63. data/lib/netsuite/records/lot_numbered_inventory_item.rb +226 -82
  64. data/lib/netsuite/records/matrix_option_list.rb +16 -0
  65. data/lib/netsuite/records/non_inventory_purchase_item.rb +1 -1
  66. data/lib/netsuite/records/non_inventory_resale_item.rb +157 -21
  67. data/lib/netsuite/records/non_inventory_sale_item.rb +134 -22
  68. data/lib/netsuite/records/null_field_list.rb +15 -0
  69. data/lib/netsuite/records/opportunity.rb +0 -1
  70. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  71. data/lib/netsuite/records/payment_item.rb +3 -3
  72. data/lib/netsuite/records/payroll_item.rb +0 -1
  73. data/lib/netsuite/records/purchase_order.rb +0 -1
  74. data/lib/netsuite/records/record_ref.rb +1 -1
  75. data/lib/netsuite/records/return_authorization.rb +1 -0
  76. data/lib/netsuite/records/sales_order.rb +2 -2
  77. data/lib/netsuite/records/sales_order_item.rb +2 -1
  78. data/lib/netsuite/records/serialized_assembly_item.rb +1 -1
  79. data/lib/netsuite/records/serialized_inventory_item.rb +2 -2
  80. data/lib/netsuite/records/serialized_inventory_item_location.rb +0 -1
  81. data/lib/netsuite/records/service_resale_item.rb +125 -21
  82. data/lib/netsuite/records/service_sale_item.rb +1 -2
  83. data/lib/netsuite/records/{customer_subscription.rb → subscription.rb} +1 -1
  84. data/lib/netsuite/records/subscriptions_list.rb +10 -0
  85. data/lib/netsuite/records/subsidiary.rb +0 -1
  86. data/lib/netsuite/records/subtotal_item.rb +3 -4
  87. data/lib/netsuite/records/transfer_order.rb +0 -1
  88. data/lib/netsuite/records/translation.rb +17 -0
  89. data/lib/netsuite/records/translation_list.rb +11 -0
  90. data/lib/netsuite/records/vendor.rb +0 -1
  91. data/lib/netsuite/records/vendor_bill.rb +0 -1
  92. data/lib/netsuite/records/work_order.rb +0 -1
  93. data/lib/netsuite/records/work_order_item.rb +0 -1
  94. data/lib/netsuite/support/actions.rb +2 -0
  95. data/lib/netsuite/support/fields.rb +2 -0
  96. data/lib/netsuite/support/records.rb +22 -5
  97. data/lib/netsuite/support/sublist.rb +2 -2
  98. data/lib/netsuite/utilities/strings.rb +15 -0
  99. data/lib/netsuite/utilities.rb +25 -13
  100. data/lib/netsuite/version.rb +1 -1
  101. data/lib/netsuite.rb +15 -3
  102. data/netsuite.gemspec +5 -2
  103. data/spec/netsuite/actions/add_spec.rb +39 -1
  104. data/spec/netsuite/actions/attach_file_spec.rb +59 -0
  105. data/spec/netsuite/actions/delete_spec.rb +74 -14
  106. data/spec/netsuite/actions/get_select_value_spec.rb +43 -0
  107. data/spec/netsuite/actions/search_spec.rb +205 -0
  108. data/spec/netsuite/configuration_spec.rb +35 -0
  109. data/spec/netsuite/records/cash_refund_item_spec.rb +1 -1
  110. data/spec/netsuite/records/credit_memo_spec.rb +14 -0
  111. data/spec/netsuite/records/customer_spec.rb +287 -20
  112. data/spec/netsuite/records/inventory_item_spec.rb +239 -22
  113. data/spec/netsuite/records/invoice_spec.rb +43 -0
  114. data/spec/netsuite/records/item_availability_spec.rb +59 -0
  115. data/spec/netsuite/records/item_fulfillment_package_fed_ex_list_spec.rb +27 -0
  116. data/spec/netsuite/records/item_fulfillment_package_ups_list_spec.rb +27 -0
  117. data/spec/netsuite/records/item_fulfillment_package_usps_list_spec.rb +27 -0
  118. data/spec/netsuite/records/item_option_custom_field_spec.rb +27 -0
  119. data/spec/netsuite/records/item_vendor_list_spec.rb +2 -5
  120. data/spec/netsuite/records/item_vendor_spec.rb +14 -2
  121. data/spec/netsuite/records/lot_numbered_inventory_item_spec.rb +247 -0
  122. data/spec/netsuite/records/matrix_option_list_spec.rb +26 -0
  123. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +159 -24
  124. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +135 -22
  125. data/spec/netsuite/records/null_field_list_spec.rb +30 -0
  126. data/spec/netsuite/records/return_authorization_spec.rb +62 -0
  127. data/spec/netsuite/records/sales_order_item_spec.rb +4 -3
  128. data/spec/netsuite/records/sales_order_spec.rb +46 -0
  129. data/spec/netsuite/records/service_resale_item_spec.rb +122 -17
  130. data/spec/netsuite/records/{customer_subscription_spec.rb → subscription_spec.rb} +2 -2
  131. data/spec/netsuite/records/{customer_subscriptions_list_spec.rb → subscriptions_list_spec.rb} +2 -2
  132. data/spec/netsuite/records/translation_list_spec.rb +34 -0
  133. data/spec/netsuite/records/translation_spec.rb +28 -0
  134. data/spec/netsuite/support/fields_spec.rb +16 -4
  135. data/spec/netsuite/support/records_spec.rb +33 -7
  136. data/spec/netsuite/support/search_result_spec.rb +12 -0
  137. data/spec/netsuite/utilities_spec.rb +10 -2
  138. data/spec/support/fixtures/add/add_file.xml +20 -0
  139. data/spec/support/fixtures/add/add_invoice.xml +9 -5
  140. data/spec/support/fixtures/attach/attach_file_to_sales_order.xml +16 -0
  141. data/spec/support/fixtures/attach/attach_file_to_sales_order_error.xml +20 -0
  142. data/spec/support/fixtures/delete/delete_customer_error.xml +21 -0
  143. data/spec/support/fixtures/delete/delete_customer_multiple_errors.xml +25 -0
  144. data/spec/support/fixtures/get_item_availability/get_item_availability.xml +46 -0
  145. data/spec/support/fixtures/get_select_value/empty_result.xml +22 -0
  146. data/spec/support/fixtures/get_select_value/item_fulfillment_ship_method.xml +43 -0
  147. data/spec/support/fixtures/search/basic_search_contact.xml +39 -0
  148. data/spec/support/fixtures/search/single_search_result.xml +46 -0
  149. metadata +78 -17
  150. data/lib/netsuite/core_ext/string/lower_camelcase.rb +0 -9
  151. data/lib/netsuite/records/customer_subscriptions_list.rb +0 -10
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::ReturnAuthorization do
4
+ let(:return_authorization) { NetSuite::Records::ReturnAuthorization.new }
5
+
6
+
7
+ describe '#shipping_address' do
8
+ it 'can be set from attributes' do
9
+ attributes = {
10
+ :country => "_unitedStates",
11
+ :attention => "William Sanders",
12
+ :addressee => "William Sanders",
13
+ :addr1 => "test1",
14
+ :addr2 => "test2",
15
+ :city => "San Francisco",
16
+ :state => "CA",
17
+ :zip => "94131",
18
+ :addr_text => "William Sanders<br>William Sanders<br>test1<br>test2<br>San Francisco CA 94131",
19
+ :override => false,
20
+ :"@xmlns:platform_common" => "urn:common_2016_1.platform.webservices.netsuite.com"
21
+ }
22
+
23
+ return_authorization.shipping_address = attributes
24
+ expect(return_authorization.shipping_address).to be_kind_of(NetSuite::Records::Address)
25
+ expect(return_authorization.shipping_address.addressee).to eql("William Sanders")
26
+ end
27
+
28
+ it 'can be set from a ItemVendorList object' do
29
+ shipping_address = NetSuite::Records::Address.new
30
+ return_authorization.shipping_address = shipping_address
31
+ expect(return_authorization.shipping_address).to eql(shipping_address)
32
+ end
33
+ end
34
+
35
+ describe '#billing_address' do
36
+ it 'can be set from attributes' do
37
+ attributes = {
38
+ :country => "_unitedStates",
39
+ :attention => "William Sanders",
40
+ :addressee => "William Sanders",
41
+ :addr1 => "test1",
42
+ :addr2 => "test2",
43
+ :city => "San Francisco",
44
+ :state => "CA",
45
+ :zip => "94131",
46
+ :addr_text => "William Sanders<br>William Sanders<br>test1<br>test2<br>San Francisco CA 94131",
47
+ :override => false,
48
+ :"@xmlns:platform_common" => "urn:common_2016_1.platform.webservices.netsuite.com"
49
+ }
50
+
51
+ return_authorization.billing_address = attributes
52
+ expect(return_authorization.billing_address).to be_kind_of(NetSuite::Records::Address)
53
+ expect(return_authorization.billing_address.addressee).to eql("William Sanders")
54
+ end
55
+
56
+ it 'can be set from a ItemVendorList object' do
57
+ billing_address = NetSuite::Records::Address.new
58
+ return_authorization.billing_address = billing_address
59
+ expect(return_authorization.billing_address).to eql(billing_address)
60
+ end
61
+ end
62
+ end
@@ -13,9 +13,10 @@ describe NetSuite::Records::SalesOrderItem do
13
13
  :quantity, :quantity_back_ordered, :quantity_billed,
14
14
  :quantity_committed, :quantity_fulfilled,
15
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
16
+ :rev_rec_term_in_months, :serial_numbers, :ship_group,
17
+ :tax1_amt, :tax_rate1, :tax_rate2,
18
+ :vsoe_allocation, :vsoe_amount, :vsoe_deferral,
19
+ :vsoe_delivered, :vsoe_permit_discount, :vsoe_price,
19
20
  ].each do |field|
20
21
  expect(item).to have_field(field)
21
22
  end
@@ -23,6 +23,23 @@ describe NetSuite::Records::SalesOrder do
23
23
  end
24
24
  end
25
25
 
26
+ it 'has all the right fields with specific classes' do
27
+ {
28
+ billing_address: NetSuite::Records::Address,
29
+ custom_field_list: NetSuite::Records::CustomFieldList,
30
+ gift_cert_redemption_list: NetSuite::Records::GiftCertRedemptionList,
31
+ item_list: NetSuite::Records::SalesOrderItemList,
32
+ null_field_list: NetSuite::Records::NullFieldList,
33
+ promotions_list: NetSuite::Records::PromotionsList,
34
+ ship_group_list: NetSuite::Records::SalesOrderShipGroupList,
35
+ shipping_address: NetSuite::Records::Address,
36
+ transaction_bill_address: NetSuite::Records::BillAddress,
37
+ transaction_ship_address: NetSuite::Records::ShipAddress,
38
+ }.each do |field, klass|
39
+ expect(salesorder).to have_field(field, klass)
40
+ end
41
+ end
42
+
26
43
  it 'has all the right record refs' do
27
44
  [
28
45
  :account, :bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item,
@@ -174,6 +191,35 @@ describe NetSuite::Records::SalesOrder do
174
191
  end
175
192
  end
176
193
 
194
+ describe '#attach_file' do
195
+ let(:test_data) { { :email => 'test@example.com', :fax => '1234567890' } }
196
+ let(:file) { double('file') }
197
+
198
+ context 'when the response is successful' do
199
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
200
+
201
+ it 'returns true' do
202
+ sales_order = NetSuite::Records::SalesOrder.new(test_data)
203
+ expect(NetSuite::Actions::AttachFile).to receive(:call).
204
+ with([sales_order, file], {}).
205
+ and_return(response)
206
+ expect(sales_order.attach_file(file)).to be_truthy
207
+ end
208
+ end
209
+
210
+ context 'when the response is unsuccessful' do
211
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
212
+
213
+ it 'returns false' do
214
+ sales_order = NetSuite::Records::SalesOrder.new(test_data)
215
+ expect(NetSuite::Actions::AttachFile).to receive(:call).
216
+ with([sales_order, file], {}).
217
+ and_return(response)
218
+ expect(sales_order.attach_file(file)).to be_falsey
219
+ end
220
+ end
221
+ end
222
+
177
223
  describe '#delete' do
178
224
  let(:test_data) { { :internal_id => '1' } }
179
225
 
@@ -5,31 +5,136 @@ describe NetSuite::Records::ServiceResaleItem do
5
5
 
6
6
  it 'has the right fields' do
7
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
8
+ :amortization_period,
9
+ :available_to_partners,
10
+ :contingent_revenue_handling,
11
+ :cost,
12
+ :cost_estimate,
13
+ :cost_estimate_type,
14
+ :cost_estimate_units,
15
+ :cost_units,
16
+ :created_date,
17
+ :create_job,
18
+ :currency,
19
+ :defer_rev_rec,
20
+ :direct_revenue_posting,
21
+ :display_name,
22
+ :dont_show_price,
23
+ :enforce_min_qty_internally,
24
+ :exclude_from_sitemap,
25
+ :featured_description,
26
+ :generate_accruals,
27
+ :include_children,
28
+ :is_donation_item,
29
+ :is_fulfillable,
30
+ :is_gco_compliant,
31
+ :is_inactive,
32
+ :is_online,
33
+ :is_taxable,
34
+ :item_id,
35
+ :last_modified_date,
36
+ :manufacturing_charge_item,
37
+ :matrix_item_name_template,
38
+ :matrix_type,
39
+ :max_donation_amount,
40
+ :maximum_quantity,
41
+ :meta_tag_html,
42
+ :minimum_quantity,
43
+ :minimum_quantity_units,
44
+ :no_price_message,
45
+ :offer_support,
46
+ :on_special,
47
+ :out_of_stock_behavior,
48
+ :out_of_stock_message,
49
+ :overall_quantity_pricing_type,
50
+ :page_title,
51
+ :prices_include_tax,
52
+ :purchase_description,
53
+ :purchase_order_amount,
54
+ :purchase_order_quantity,
55
+ :purchase_order_quantity_diff,
56
+ :rate,
57
+ :receipt_amount,
58
+ :receipt_quantity,
59
+ :receipt_quantity_diff,
60
+ :related_items_description,
61
+ :residual,
62
+ :sales_description,
63
+ :search_keywords,
64
+ :show_default_donation_amount,
65
+ :sitemap_priority,
66
+ :soft_descriptor,
67
+ :specials_description,
68
+ :store_description,
69
+ :store_detailed_description,
70
+ :store_display_name,
71
+ :upc_code,
72
+ :url_component,
73
+ :use_marginal_rates,
74
+ :vendor_name,
75
+ :vsoe_deferral,
76
+ :vsoe_delivered,
77
+ :vsoe_permit_discount,
78
+ :vsoe_price,
79
+ :vsoe_sop_group,
17
80
  ].each do |field|
18
81
  expect(item).to have_field(field)
19
82
  end
83
+ end
20
84
 
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)
85
+ it 'has all the right fields with specific classes' do
86
+ {
87
+ custom_field_list: NetSuite::Records::CustomFieldList,
88
+ item_vendor_list: NetSuite::Records::ItemVendorList,
89
+ matrix_option_list: NetSuite::Records::MatrixOptionList,
90
+ pricing_matrix: NetSuite::Records::PricingMatrix,
91
+ subsidiary_list: NetSuite::Records::RecordRefList,
92
+ }.each do |field, klass|
93
+ expect(item).to have_field(field, klass)
94
+ end
25
95
  end
26
96
 
27
97
  it 'has the right record_refs' do
28
98
  [
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
99
+ :amortization_template,
100
+ :bill_exch_rate_variance_acct,
101
+ :billing_schedule,
102
+ :bill_price_variance_acct,
103
+ :bill_qty_variance_acct,
104
+ :klass,
105
+ :consumption_unit,
106
+ :cost_category,
107
+ :create_revenue_plans_on,
108
+ :custom_form,
109
+ :deferral_account,
110
+ :deferred_revenue_account,
111
+ :department,
112
+ :expense_account,
113
+ :income_account,
114
+ :interco_def_rev_account,
115
+ :interco_expense_account,
116
+ :interco_income_account,
117
+ :issue_product,
118
+ :item_revenue_category,
119
+ :location,
120
+ :parent,
121
+ :pricing_group,
122
+ :purchase_tax_code,
123
+ :purchase_unit,
124
+ :quantity_pricing_schedule,
125
+ :revenue_allocation_group,
126
+ :revenue_recognition_rule,
127
+ :rev_rec_forecast_rule,
128
+ :rev_reclass_f_x_account,
129
+ :rev_rec_schedule,
130
+ :sales_tax_code,
131
+ :sale_unit,
132
+ :store_display_image,
133
+ :store_display_thumbnail,
134
+ :store_item_template,
135
+ :tax_schedule,
136
+ :units_type,
137
+ :vendor,
33
138
  ].each do |record_ref|
34
139
  expect(item).to have_record_ref(record_ref)
35
140
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe NetSuite::Records::CustomerSubscription do
3
+ describe NetSuite::Records::Subscription do
4
4
 
5
5
  before do
6
6
  NetSuite::Configuration.api_version = '2014_2'
@@ -16,7 +16,7 @@ describe NetSuite::Records::CustomerSubscription do
16
16
  }
17
17
  end
18
18
 
19
- let(:list) { NetSuite::Records::CustomerSubscription.new(attributes) }
19
+ let(:list) { NetSuite::Records::Subscription.new(attributes) }
20
20
 
21
21
  it 'has all the right fields' do
22
22
  [
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe NetSuite::Records::CustomerSubscriptionsList do
4
- let(:list) { NetSuite::Records::CustomerSubscriptionsList.new }
3
+ describe NetSuite::Records::SubscriptionsList do
4
+ let(:list) { NetSuite::Records::SubscriptionsList.new }
5
5
 
6
6
  it 'has a subscriptions attribute' do
7
7
  expect(list.subscriptions).to be_kind_of(Array)
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::TranslationList do
4
+ let(:list) { NetSuite::Records::TranslationList.new }
5
+
6
+ it 'has a translations attribute' do
7
+ expect(list.translations).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.translations << NetSuite::Records::Translation.new(
13
+ locale: '_englishUK',
14
+ language: 'English (UK)',
15
+ display_name: 'display name',
16
+ sales_description: 'sales description'
17
+ )
18
+ end
19
+
20
+ it 'can represent itself as a SOAP record' do
21
+ record = {
22
+ "listAcct:translation" => [
23
+ {
24
+ "listAcct:locale" => "_englishUK",
25
+ "listAcct:language" => "English (UK)",
26
+ "listAcct:displayName" => "display name",
27
+ "listAcct:salesDescription" => "sales description"
28
+ }
29
+ ]
30
+ }
31
+ expect(list.to_record).to eql(record)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::Translation do
4
+ let(:translation) { NetSuite::Records::Translation.new }
5
+
6
+ it 'has dynamic fields' do
7
+ [
8
+ :description,
9
+ :display_name,
10
+ :featured_description,
11
+ :language,
12
+ :locale,
13
+ :locale_description,
14
+ :name,
15
+ :no_price_message,
16
+ :out_of_stock_message,
17
+ :page_title,
18
+ :replace_all,
19
+ :sales_description,
20
+ :specials_description,
21
+ :store_description,
22
+ :store_detailed_description,
23
+ :store_display_name
24
+ ].each do |field|
25
+ expect(translation).to have_field(field)
26
+ end
27
+ end
28
+ end
@@ -1,12 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Support::Fields do
4
- DummyRecord = Class.new.send(:include, NetSuite::Support::Fields)
5
- let(:klass) { DummyRecord }
4
+ let(:klass) do
5
+ Class.new do
6
+ include NetSuite::Support::Fields
7
+ end
8
+ end
6
9
  let(:instance) { klass.new }
7
10
 
8
- before { klass.fields.clear }
9
-
10
11
  describe '.fields' do
11
12
  context 'with arguments' do
12
13
  it 'calls .field with each argument passed to it' do
@@ -34,10 +35,21 @@ describe NetSuite::Support::Fields do
34
35
  end
35
36
 
36
37
  it 'errors when already a field' do
38
+ DummyRecord = klass
39
+
37
40
  klass.field :one
38
41
 
39
42
  expect { klass.field :one }.to raise_error('one already defined on DummyRecord')
40
43
  end
44
+
45
+ it 'errors when conflicting with a public method' do
46
+ DummyRecordWithMethod = Class.new(klass) do
47
+ def existing_method
48
+ end
49
+ end
50
+
51
+ expect { DummyRecordWithMethod.field :existing_method }.to raise_error('existing_method conflicts with a method defined on DummyRecordWithMethod')
52
+ end
41
53
  end
42
54
 
43
55
  describe '.read_only_fields' do
@@ -4,11 +4,14 @@ module Foo
4
4
  module Bar
5
5
  class Baz
6
6
  include NetSuite::Support::Fields
7
+ include NetSuite::Support::RecordRefs
7
8
  include NetSuite::Support::Records
9
+ include NetSuite::Namespaces::TranSales
8
10
 
9
- def attributes
10
- { :source => 'Google', :total => 100.0 }
11
- end
11
+ fields :source, :total
12
+ field :null_field_list, NetSuite::Records::NullFieldList
13
+
14
+ record_ref :related_record
12
15
  end
13
16
  end
14
17
  end
@@ -16,18 +19,41 @@ end
16
19
  describe NetSuite::Support::Records do
17
20
  let(:instance) { Foo::Bar::Baz.new }
18
21
 
19
- describe '#record_type' do
22
+ describe '#to_record' do
20
23
  it 'returns a hash of attributes to be used in a SOAP request' do
24
+ instance.source = 'Google'
25
+ instance.total = 100.0
26
+
21
27
  expect(instance.to_record).to eql({
22
- 'platformCore:source' => 'Google',
23
- 'platformCore:total' => 100.0
28
+ 'tranSales:source' => 'Google',
29
+ 'tranSales:total' => 100.0
30
+ })
31
+ end
32
+
33
+ it 'uses the records namespace for the outer elements namespace and the field values namespace for the inner elements namespace' do
34
+ instance.related_record = NetSuite::Records::RecordRef.new(name: 'blah')
35
+
36
+ expect(instance.to_record).to eq({
37
+ 'tranSales:relatedRecord' => {
38
+ 'platformCore:name' => 'blah',
39
+ },
40
+ })
41
+ end
42
+
43
+ it 'uses the fields namespace for the outer elements namespace for NullFieldList value' do
44
+ instance.null_field_list.name = 'source'
45
+
46
+ expect(instance.to_record).to eq({
47
+ 'platformCore:nullFieldList' => {
48
+ 'platformCore:name' => 'source',
49
+ },
24
50
  })
25
51
  end
26
52
  end
27
53
 
28
54
  describe '#record_type' do
29
55
  it 'returns a string of the record type to be used in a SOAP request' do
30
- expect(instance.record_type).to eql('platformCore:Baz')
56
+ expect(instance.record_type).to eql('tranSales:Baz')
31
57
  end
32
58
  end
33
59
 
@@ -1,6 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Support::SearchResult do
4
+ before(:all) { savon.mock! }
5
+ after(:all) { savon.unmock! }
6
+
4
7
  describe '#results' do
5
8
  context 'empty page' do
6
9
  it 'returns empty array' do
@@ -20,5 +23,14 @@ describe NetSuite::Support::SearchResult do
20
23
  expect(results).to eq []
21
24
  end
22
25
  end
26
+
27
+ it 'handles a recordList with a single element' do
28
+ response = File.read('spec/support/fixtures/search/single_search_result.xml')
29
+ savon.expects(:search).with(message: {}).returns(response)
30
+
31
+ results = NetSuite::Records::Account.search(basic: [])
32
+
33
+ expect(results.results.count).to eq 1
34
+ end
23
35
  end
24
36
  end
@@ -13,11 +13,19 @@ describe NetSuite::Utilities do
13
13
 
14
14
  no_dst_stamp = DateTime.parse('Sun, November 6 2017 00:00:00 -0000')
15
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')
16
+ if Gem.loaded_specs.has_key?('tzinfo')
17
+ expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
18
+ else
19
+ expect(formatted_date).to eq('2017-11-06T00:00:00-07:00')
20
+ end
17
21
 
18
22
  no_dst_stamp_with_time = DateTime.parse('Sun, November 6 2017 12:11:10 -0000')
19
23
  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')
24
+ if Gem.loaded_specs.has_key?('tzinfo')
25
+ expect(formatted_date).to eq('2017-11-06T00:00:00-08:00')
26
+ else
27
+ expect(formatted_date).to eq('2017-11-06T00:00:00-07:00')
28
+ end
21
29
  end
22
30
  end
23
31
  end
@@ -0,0 +1,20 @@
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_2020_2.platform.webservices.netsuite.com">
5
+ <platformMsgs:nsId>REDACTED</platformMsgs:nsId>
6
+ </platformMsgs:documentInfo>
7
+ </soapenv:Header>
8
+ <soapenv:Body>
9
+ <addResponse xmlns="urn:messages_2020_2.platform.webservices.netsuite.com">
10
+ <writeResponse>
11
+ <platformCore:status xmlns:platformCore="urn:core_2020_2.platform.webservices.netsuite.com" isSuccess="true">
12
+ <platformCore:statusDetail>
13
+ <platformCore:afterSubmitFailed>false</platformCore:afterSubmitFailed>
14
+ </platformCore:statusDetail>
15
+ </platformCore:status>
16
+ <baseRef xmlns:platformCore="urn:core_2020_2.platform.webservices.netsuite.com" internalId="23556" type="file" xsi:type="platformCore:RecordRef"/>
17
+ </writeResponse>
18
+ </addResponse>
19
+ </soapenv:Body>
20
+ </soapenv:Envelope>
@@ -1,15 +1,19 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
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
3
  <soapenv:Header>
4
- <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2011_2.platform.webservices.netsuite.com">
4
+ <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2018_2.platform.webservices.netsuite.com">
5
5
  <platformMsgs:nsId>WEBSERVICES_3392464_1220201115821392011296470399_67055c545d0</platformMsgs:nsId>
6
6
  </platformMsgs:documentInfo>
7
7
  </soapenv:Header>
8
8
  <soapenv:Body>
9
- <addResponse 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="999" type="invoice" xsi:type="ns2:RecordRef" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:core_2_5.platform.webservices.netsuite.com"/>
9
+ <addResponse xmlns="urn:messages_2018_2.platform.webservices.netsuite.com">
10
+ <writeResponse>
11
+ <platformCore:status isSuccess="true" xmlns:platformCore="urn:core_2018_2.platform.webservices.netsuite.com">
12
+ <platformCore:statusDetail>
13
+ <platformCore:afterSubmitFailed>false</platformCore:afterSubmitFailed>
14
+ </platformCore:statusDetail>
15
+ </platformCore:status>
16
+ <baseRef internalId="999" type="invoice" xsi:type="platformCore:RecordRef" xmlns:platformCore="urn:core_2018_2.platform.webservices.netsuite.com"/>
13
17
  </writeResponse>
14
18
  </addResponse>
15
19
  </soapenv:Body>
@@ -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
+ <attachResponse 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="999" type="salesOrder" xsi:type="ns2:RecordRef" xmlns:ns2="urn:core_2_5.platform.webservices.netsuite.com"/>
13
+ </writeResponse>
14
+ </attachResponse>
15
+ </soapenv:Body>
16
+ </soapenv:Envelope>
@@ -0,0 +1,20 @@
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
+ <attachResponse xmlns="urn:messages_2_5.platform.webservices.netsuite.com">
10
+ <writeResponse xmlns="urn:messages_2_5.platform.webservices.netsuite.com">
11
+ <platformCore:status xmlns:platformCore="urn:core_2011_2.platform.webservices.netsuite.com" isSuccess="false">
12
+ <platformCore:statusDetail type="ERROR">
13
+ <platformCore:code>INVALID</platformCore:code>
14
+ <platformCore:message>Invalid request.</platformCore:message>
15
+ </platformCore:statusDetail>
16
+ </platformCore:status>
17
+ </writeResponse>
18
+ </attachResponse>
19
+ </soapenv:Body>
20
+ </soapenv:Envelope>
@@ -0,0 +1,21 @@
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_2020_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_2020_2.platform.webservices.netsuite.com">
10
+ <writeResponse>
11
+ <platformCore:status xmlns:platformCore="urn:core_2020_2.platform.webservices.netsuite.com" isSuccess="false">
12
+ <platformCore:statusDetail type="ERROR">
13
+ <platformCore:code>INSUFFICIENT_PERMISSION</platformCore:code>
14
+ <platformCore:message>Permission Violation: You need a higher level of the 'Lists -&gt; Documents and Files' permission to access this page. Please contact your account administrator.</platformCore:message>
15
+ </platformCore:statusDetail>
16
+ </platformCore:status>
17
+ <baseRef xmlns:platformCore="urn:core_2020_2.platform.webservices.netsuite.com" internalId="118519" type="file" xsi:type="platformCore:RecordRef"/>
18
+ </writeResponse>
19
+ </deleteResponse>
20
+ </soapenv:Body>
21
+ </soapenv:Envelope>