netsuite 0.7.9 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) 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 +164 -61
  6. data/circle.yml +33 -13
  7. data/lib/netsuite.rb +55 -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 +3 -0
  15. data/lib/netsuite/records/assembly_build.rb +39 -0
  16. data/lib/netsuite/records/assembly_component.rb +28 -0
  17. data/lib/netsuite/records/assembly_component_list.rb +12 -0
  18. data/lib/netsuite/records/assembly_item.rb +1 -0
  19. data/lib/netsuite/records/assembly_unbuild.rb +40 -0
  20. data/lib/netsuite/records/bin_number.rb +18 -0
  21. data/lib/netsuite/records/bin_number_list.rb +1 -20
  22. data/lib/netsuite/records/bin_transfer.rb +38 -0
  23. data/lib/netsuite/records/bin_transfer_inventory.rb +20 -0
  24. data/lib/netsuite/records/bin_transfer_inventory_list.rb +10 -0
  25. data/lib/netsuite/records/cash_refund.rb +101 -3
  26. data/lib/netsuite/records/cash_refund_item.rb +1 -1
  27. data/lib/netsuite/records/cash_sale.rb +1 -0
  28. data/lib/netsuite/records/classification.rb +5 -2
  29. data/lib/netsuite/records/contact.rb +2 -1
  30. data/lib/netsuite/records/contact_addressbook.rb +64 -0
  31. data/lib/netsuite/records/contact_addressbook_list.rb +11 -0
  32. data/lib/netsuite/records/credit_memo.rb +1 -0
  33. data/lib/netsuite/records/currency_rate.rb +4 -3
  34. data/lib/netsuite/records/custom_field_list.rb +16 -3
  35. data/lib/netsuite/records/custom_record.rb +3 -3
  36. data/lib/netsuite/records/custom_record_ref.rb +1 -0
  37. data/lib/netsuite/records/customer.rb +5 -4
  38. data/lib/netsuite/records/customer_credit_cards.rb +36 -0
  39. data/lib/netsuite/records/customer_credit_cards_list.rb +10 -0
  40. data/lib/netsuite/records/customer_deposit.rb +6 -2
  41. data/lib/netsuite/records/customer_deposit_apply.rb +17 -0
  42. data/lib/netsuite/records/customer_deposit_apply_list.rb +12 -0
  43. data/lib/netsuite/records/customer_payment.rb +1 -0
  44. data/lib/netsuite/records/customer_sales_team.rb +24 -0
  45. data/lib/netsuite/records/customer_sales_team_list.rb +9 -0
  46. data/lib/netsuite/records/customer_status.rb +29 -0
  47. data/lib/netsuite/records/customer_subscription.rb +18 -0
  48. data/lib/netsuite/records/customer_subscriptions_list.rb +10 -0
  49. data/lib/netsuite/records/deposit_other.rb +0 -10
  50. data/lib/netsuite/records/employee.rb +3 -2
  51. data/lib/netsuite/records/entity_custom_field.rb +53 -0
  52. data/lib/netsuite/records/estimate.rb +42 -0
  53. data/lib/netsuite/records/estimate_item.rb +40 -0
  54. data/lib/netsuite/records/estimate_item_list.rb +11 -0
  55. data/lib/netsuite/records/inbound_shipment.rb +33 -0
  56. data/lib/netsuite/records/inbound_shipment_item.rb +39 -0
  57. data/lib/netsuite/records/inbound_shipment_item_list.rb +11 -0
  58. data/lib/netsuite/records/inter_company_journal_entry.rb +48 -0
  59. data/lib/netsuite/records/inter_company_journal_entry_line.rb +28 -0
  60. data/lib/netsuite/records/inter_company_journal_entry_line_list.rb +14 -0
  61. data/lib/netsuite/records/inventory_adjustment.rb +1 -1
  62. data/lib/netsuite/records/inventory_adjustment_inventory.rb +2 -2
  63. data/lib/netsuite/records/inventory_item.rb +2 -2
  64. data/lib/netsuite/records/inventory_number.rb +35 -0
  65. data/lib/netsuite/records/inventory_number_locations.rb +16 -0
  66. data/lib/netsuite/records/inventory_number_locations_list.rb +10 -0
  67. data/lib/netsuite/records/inventory_transfer.rb +2 -2
  68. data/lib/netsuite/records/inventory_transfer_inventory_list.rb +0 -2
  69. data/lib/netsuite/records/invoice.rb +4 -4
  70. data/lib/netsuite/records/item_fulfillment.rb +2 -1
  71. data/lib/netsuite/records/job.rb +2 -1
  72. data/lib/netsuite/records/lot_numbered_assembly_item.rb +64 -0
  73. data/lib/netsuite/records/lot_numbered_inventory_item.rb +116 -0
  74. data/lib/netsuite/records/matrix_option_list.rb +12 -4
  75. data/lib/netsuite/records/message.rb +30 -0
  76. data/lib/netsuite/records/non_inventory_resale_item.rb +3 -2
  77. data/lib/netsuite/records/non_inventory_sale_item.rb +2 -1
  78. data/lib/netsuite/records/other_charge_sale_item.rb +2 -2
  79. data/lib/netsuite/records/partner.rb +1 -1
  80. data/lib/netsuite/records/price.rb +17 -0
  81. data/lib/netsuite/records/price_level.rb +26 -0
  82. data/lib/netsuite/records/price_list.rb +9 -0
  83. data/lib/netsuite/records/pricing.rb +20 -0
  84. data/lib/netsuite/records/pricing_matrix.rb +2 -2
  85. data/lib/netsuite/records/promotions.rb +26 -0
  86. data/lib/netsuite/records/promotions_list.rb +9 -0
  87. data/lib/netsuite/records/return_authorization.rb +3 -2
  88. data/lib/netsuite/records/return_authorization_item.rb +43 -0
  89. data/lib/netsuite/records/return_authorization_item_list.rb +11 -0
  90. data/lib/netsuite/records/sales_order.rb +1 -0
  91. data/lib/netsuite/records/sales_order_item.rb +12 -5
  92. data/lib/netsuite/records/sales_role.rb +26 -0
  93. data/lib/netsuite/records/sales_tax_item.rb +3 -1
  94. data/lib/netsuite/records/serialized_assembly_item.rb +239 -0
  95. data/lib/netsuite/records/serialized_inventory_item.rb +2 -2
  96. data/lib/netsuite/records/serialized_inventory_item_location.rb +37 -0
  97. data/lib/netsuite/records/serialized_inventory_item_locations_list.rb +10 -0
  98. data/lib/netsuite/records/serialized_inventory_item_numbers.rb +15 -0
  99. data/lib/netsuite/records/serialized_inventory_item_numbers_list.rb +10 -0
  100. data/lib/netsuite/records/service_resale_item.rb +1 -1
  101. data/lib/netsuite/records/service_sale_item.rb +2 -1
  102. data/lib/netsuite/records/subsidiary.rb +1 -0
  103. data/lib/netsuite/records/support_case.rb +1 -1
  104. data/lib/netsuite/records/support_case_type.rb +26 -0
  105. data/lib/netsuite/records/task.rb +2 -1
  106. data/lib/netsuite/records/tax_group.rb +3 -1
  107. data/lib/netsuite/records/transaction_body_custom_field.rb +61 -0
  108. data/lib/netsuite/records/transaction_column_custom_field.rb +59 -0
  109. data/lib/netsuite/records/transfer_order_item.rb +2 -2
  110. data/lib/netsuite/records/vendor.rb +1 -0
  111. data/lib/netsuite/records/vendor_bill.rb +2 -1
  112. data/lib/netsuite/records/vendor_credit.rb +2 -0
  113. data/lib/netsuite/records/work_order.rb +8 -0
  114. data/lib/netsuite/support/actions.rb +2 -0
  115. data/lib/netsuite/support/country.rb +27 -14
  116. data/lib/netsuite/support/search_result.rb +20 -5
  117. data/lib/netsuite/utilities.rb +100 -43
  118. data/lib/netsuite/version.rb +2 -2
  119. data/netsuite.gemspec +5 -4
  120. data/spec/netsuite/actions/login_spec.rb +23 -0
  121. data/spec/netsuite/actions/update_list_spec.rb +107 -0
  122. data/spec/netsuite/actions/update_spec.rb +42 -0
  123. data/spec/netsuite/configuration_spec.rb +79 -6
  124. data/spec/netsuite/records/address_spec.rb +10 -0
  125. data/spec/netsuite/records/basic_record_spec.rb +18 -1
  126. data/spec/netsuite/records/bin_number_spec.rb +23 -0
  127. data/spec/netsuite/records/classification_spec.rb +10 -1
  128. data/spec/netsuite/records/custom_field_list_spec.rb +46 -5
  129. data/spec/netsuite/records/custom_record_spec.rb +1 -1
  130. data/spec/netsuite/records/customer_credit_cards_list_spec.rb +23 -0
  131. data/spec/netsuite/records/customer_sales_team_list_spec.rb +41 -0
  132. data/spec/netsuite/records/customer_spec.rb +44 -2
  133. data/spec/netsuite/records/customer_subscription_spec.rb +41 -0
  134. data/spec/netsuite/records/customer_subscriptions_list_spec.rb +19 -0
  135. data/spec/netsuite/records/employee_spec.rb +2 -2
  136. data/spec/netsuite/records/entity_custom_field_spec.rb +34 -0
  137. data/spec/netsuite/records/estimate_item_list_spec.rb +26 -0
  138. data/spec/netsuite/records/estimate_item_spec.rb +40 -0
  139. data/spec/netsuite/records/estimate_spec.rb +216 -0
  140. data/spec/netsuite/records/inter_company_journal_entry_line_list_spec.rb +26 -0
  141. data/spec/netsuite/records/inter_company_journal_entry_line_spec.rb +60 -0
  142. data/spec/netsuite/records/inter_company_journal_entry_spec.rb +156 -0
  143. data/spec/netsuite/records/inventory_item_spec.rb +57 -0
  144. data/spec/netsuite/records/inventory_transfer_spec.rb +21 -0
  145. data/spec/netsuite/records/invoice_spec.rb +4 -4
  146. data/spec/netsuite/records/matrix_option_list_spec.rb +15 -5
  147. data/spec/netsuite/records/message_spec.rb +49 -0
  148. data/spec/netsuite/records/non_inventory_resale_item_spec.rb +165 -0
  149. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +1 -1
  150. data/spec/netsuite/records/partner_spec.rb +141 -0
  151. data/spec/netsuite/records/price_level_spec.rb +16 -0
  152. data/spec/netsuite/records/pricing_matrix_spec.rb +15 -13
  153. data/spec/netsuite/records/return_authorization_item_list_spec.rb +26 -0
  154. data/spec/netsuite/records/return_authorization_item_spec.rb +43 -0
  155. data/spec/netsuite/records/sales_order_item_spec.rb +11 -5
  156. data/spec/netsuite/records/service_resale_item_spec.rb +134 -0
  157. data/spec/netsuite/records/support_case_type_spec.rb +22 -0
  158. data/spec/netsuite/records/transaction_body_custom_field_spec.rb +32 -0
  159. data/spec/netsuite/records/transaction_column_custom_field_spec.rb +32 -0
  160. data/spec/netsuite/records/vendor_credit_spec.rb +29 -0
  161. data/spec/netsuite/support/search_result_spec.rb +24 -0
  162. data/spec/netsuite/utilities_spec.rb +50 -0
  163. data/spec/spec_helper.rb +5 -4
  164. data/spec/support/fixtures/update_list/update_list_items.xml +22 -0
  165. data/spec/support/fixtures/update_list/update_list_one_item.xml +18 -0
  166. data/spec/support/fixtures/update_list/update_list_with_errors.xml +32 -0
  167. metadata +123 -8
@@ -326,15 +326,11 @@ describe NetSuite::Configuration do
326
326
 
327
327
  describe "#credentials" do
328
328
  context "when none are defined" do
329
- skip "should properly create the auth credentials" do
330
-
331
- end
329
+ skip "should properly create the auth credentials"
332
330
  end
333
331
 
334
332
  context "when they are defined" do
335
- it "should properly replace the default auth credentials" do
336
-
337
- end
333
+ skip "should properly replace the default auth credentials"
338
334
  end
339
335
  end
340
336
 
@@ -371,4 +367,81 @@ describe NetSuite::Configuration do
371
367
  end
372
368
  end
373
369
 
370
+ describe "#log" do
371
+ it 'allows a file path to be set as the log destination' do
372
+ file_path = Tempfile.new.path
373
+ config.log = file_path
374
+ config.logger.info "foo"
375
+
376
+ log_contents = open(file_path).read
377
+ expect(log_contents).to include("foo")
378
+ end
379
+
380
+ it 'allows an IO device to bet set as the log destination' do
381
+ stream = StringIO.new
382
+ config.log = stream
383
+ config.logger.info "foo"
384
+
385
+ expect(stream.string).to include("foo")
386
+ end
387
+ end
388
+
389
+ describe '#log_level' do
390
+ it 'defaults to :debug' do
391
+ expect(config.log_level).to eq(:debug)
392
+ end
393
+
394
+ it 'can be initially set to any log level' do
395
+ config.log_level(:info)
396
+
397
+ expect(config.log_level).to eq(:info)
398
+ end
399
+
400
+ it 'can override itself' do
401
+ config.log_level = :info
402
+
403
+ expect(config.log_level).to eq(:info)
404
+
405
+ config.log_level(:debug)
406
+
407
+ expect(config.log_level).to eq(:debug)
408
+ end
409
+ end
410
+
411
+ describe '#log_level=' do
412
+ it 'can set the initial log_level' do
413
+ config.log_level = :info
414
+
415
+ expect(config.log_level).to eq(:info)
416
+ end
417
+
418
+ it 'can override a previously set log level' do
419
+ config.log_level = :info
420
+
421
+ expect(config.log_level).to eq(:info)
422
+
423
+ config.log_level = :debug
424
+
425
+ expect(config.log_level).to eq(:debug)
426
+ end
427
+ end
428
+
429
+ describe 'timeouts' do
430
+ it 'has defaults' do
431
+ expect(config.read_timeout).to eql(60)
432
+ expect(config.open_timeout).to be_nil
433
+ end
434
+
435
+ it 'sets timeouts' do
436
+ config.read_timeout = 100
437
+ config.open_timeout = 60
438
+
439
+ expect(config.read_timeout).to eql(100)
440
+ expect(config.open_timeout).to eql(60)
441
+
442
+ # ensure no exception is raised
443
+ config.connection
444
+ end
445
+ end
446
+
374
447
  end
@@ -134,6 +134,16 @@ describe NetSuite::Records::Address do
134
134
  expect(addressbook.country.to_record).to eql ""
135
135
  expect(addressbook.to_record["platformCommon:country"]).to eql ""
136
136
  end
137
+
138
+ it 'changes the netsuite identifier based on the current API version' do
139
+ NetSuite::Configuration.api_version = '2015_1'
140
+ addressbook = NetSuite::Records::Address.new country: "GB"
141
+ expect(addressbook.to_record["platformCommon:country"]).to eql "_unitedKingdomGB"
142
+ NetSuite::Configuration.api_version = '2018_1'
143
+
144
+ addressbook = NetSuite::Records::Address.new country: "GB"
145
+ expect(addressbook.to_record["platformCommon:country"]).to eql "_unitedKingdom"
146
+ end
137
147
  end
138
148
 
139
149
  end
@@ -4,6 +4,8 @@ describe 'basic records' do
4
4
  let(:basic_record_list) {
5
5
  [
6
6
  NetSuite::Records::Currency,
7
+ NetSuite::Records::CashSale,
8
+ NetSuite::Records::CashRefund,
7
9
  NetSuite::Records::Location,
8
10
  NetSuite::Records::JobStatus,
9
11
  NetSuite::Records::TimeBill,
@@ -23,6 +25,7 @@ describe 'basic records' do
23
25
  NetSuite::Records::CustomerDeposit,
24
26
  NetSuite::Records::NonInventoryPurchaseItem,
25
27
  NetSuite::Records::NonInventoryResaleItem,
28
+ NetSuite::Records::LotNumberedInventoryItem,
26
29
  NetSuite::Records::TaxGroup,
27
30
  NetSuite::Records::Folder,
28
31
  NetSuite::Records::CustomerCategory,
@@ -46,7 +49,21 @@ describe 'basic records' do
46
49
  NetSuite::Records::SerializedInventoryItem,
47
50
  NetSuite::Records::DepositApplication,
48
51
  NetSuite::Records::InventoryAdjustment,
49
- NetSuite::Records::VendorReturnAuthorization
52
+ NetSuite::Records::VendorReturnAuthorization,
53
+ NetSuite::Records::AssemblyBuild,
54
+ NetSuite::Records::AssemblyUnbuild,
55
+ NetSuite::Records::AssemblyComponent,
56
+ NetSuite::Records::InventoryNumber,
57
+ NetSuite::Records::PriceLevel,
58
+ NetSuite::Records::LotNumberedAssemblyItem,
59
+ NetSuite::Records::InboundShipment,
60
+ NetSuite::Records::InterCompanyJournalEntry,
61
+ NetSuite::Records::BinTransfer,
62
+ NetSuite::Records::SerializedAssemblyItem,
63
+ NetSuite::Records::CustomerStatus,
64
+ NetSuite::Records::TransactionBodyCustomField,
65
+ NetSuite::Records::TransactionColumnCustomField,
66
+ NetSuite::Records::EntityCustomField
50
67
  ]
51
68
  }
52
69
 
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::BinNumber do
4
+ it "has all the right fields" do
5
+ bin_number = described_class.new
6
+
7
+ [:preferred_bin, :location].each do |field|
8
+ expect(bin_number).to have_field(field)
9
+ end
10
+ end
11
+
12
+ it "has all the right record refs" do
13
+ bin_number = described_class.new
14
+
15
+ expect(bin_number).to have_record_ref(:bin_number)
16
+ end
17
+
18
+ it "has the right namespace" do
19
+ bin_number = described_class.new
20
+
21
+ expect(bin_number.record_namespace).to eq('listAcct')
22
+ end
23
+ end
@@ -5,12 +5,21 @@ describe NetSuite::Records::Classification do
5
5
 
6
6
  it 'has all the right fields' do
7
7
  [
8
- :name, :include_children, :is_inactive, :class_translation_list, :custom_field_list
8
+ :name, :include_children, :is_inactive, :class_translation_list
9
9
  ].each do |field|
10
10
  expect(classification).to have_field(field)
11
11
  end
12
12
 
13
13
  expect(classification.subsidiary_list.class).to eq(NetSuite::Records::RecordRefList)
14
+ expect(classification.custom_field_list.class).to eq(NetSuite::Records::CustomFieldList)
15
+ end
16
+
17
+ it 'has all the right record refs' do
18
+ [
19
+ :parent
20
+ ].each do |record_ref|
21
+ expect(classification).to have_record_ref(record_ref)
22
+ end
14
23
  end
15
24
 
16
25
  describe '.get' do
@@ -6,7 +6,7 @@ describe NetSuite::Records::CustomFieldList do
6
6
  it 'has a custom_fields attribute' do
7
7
  expect(list.custom_fields).to be_kind_of(Array)
8
8
  end
9
-
9
+
10
10
  it 'accepts a collection of CustomField records' do
11
11
  field = NetSuite::Records::CustomField.new({:value=>{:internal_id=>"5", :type_id=>"103"},
12
12
  :script_id=>"custitem_item_category", :"@xsi:type"=>"platformCore:SelectCustomFieldRef"})
@@ -37,9 +37,17 @@ describe NetSuite::Records::CustomFieldList do
37
37
  context 'writing convience methods' do
38
38
  it "should create a custom field entry when none exists" do
39
39
  list.custrecord_somefield = 'a value'
40
- list.custom_fields.size.should == 1
41
- list.custom_fields.first.value.should == 'a value'
42
- list.custom_fields.first.type.should == 'platformCore:StringCustomFieldRef'
40
+ custom_fields = list.custom_fields
41
+
42
+ expect(custom_fields.size).to eq(1)
43
+ expect(custom_fields.first.value).to eq('a value')
44
+ expect(custom_fields.first.type).to eq('platformCore:StringCustomFieldRef')
45
+ end
46
+
47
+ # https://github.com/NetSweet/netsuite/issues/325
48
+ it 'should create a custom field entry when some fields exist without scriptIds' do
49
+ list.custom_fields << NetSuite::Records::CustomField.new
50
+ list.custrecord_somefield = 123
43
51
  end
44
52
  end
45
53
 
@@ -110,7 +118,7 @@ describe NetSuite::Records::CustomFieldList do
110
118
  end
111
119
 
112
120
  it "should raise an error if custom field entry does not exist" do
113
- expect{ list.nonexisting_custom_field }.to raise_error
121
+ expect{ list.nonexisting_custom_field }.to raise_error(NoMethodError)
114
122
  end
115
123
  end
116
124
  end
@@ -174,6 +182,20 @@ describe NetSuite::Records::CustomFieldList do
174
182
  script_id: "custbody_salesclassification",
175
183
  type: "platformCore:StringCustomFieldRef",
176
184
  value: "foobar"
185
+ },
186
+ {
187
+ script_id: 'custbody_multipleselectfield',
188
+ type: "platformCore:MultiSelectCustomFieldRef",
189
+ value: [
190
+ {
191
+ internal_id: 405,
192
+ type_id: 157
193
+ },
194
+ {
195
+ internal_id: 419,
196
+ type_id: 157
197
+ }
198
+ ]
177
199
  }
178
200
  ]
179
201
  }
@@ -194,9 +216,28 @@ describe NetSuite::Records::CustomFieldList do
194
216
  "@xsi:type" => "platformCore:StringCustomFieldRef",
195
217
  "platformCore:value" => "foobar",
196
218
  },
219
+ {
220
+ '@scriptId' => 'custbody_multipleselectfield',
221
+ '@xsi:type' => 'platformCore:MultiSelectCustomFieldRef',
222
+ 'platformCore:value' => [
223
+ {
224
+ :@internalId => 405,
225
+ :@typeId => "157"
226
+ },
227
+ {
228
+ :@internalId => 419,
229
+ :@typeId => "157"
230
+ }
231
+ ]
232
+ }
197
233
  ]
198
234
  }
199
235
 
236
+ # field accessors are tested elsewhere, but let's run tests here to check various field types
237
+ expect(list).to respond_to(:custbody_multipleselectfield)
238
+ expect(list).to respond_to(:custbody_salesclassification)
239
+ expect(list).to respond_to(:custentity_registeredonline)
240
+
200
241
  expect(list.to_record).to eql(record)
201
242
  expect(list.to_record.length).to eq(1)
202
243
  end
@@ -18,7 +18,7 @@ describe NetSuite::Records::CustomRecord do
18
18
 
19
19
  it 'has all the right record_refs' do
20
20
  [
21
- :custom_form, :owner
21
+ :custom_form, :owner, :rec_type, :parent
22
22
  ].each do |record_ref|
23
23
  expect(record).to have_record_ref(record_ref)
24
24
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::CustomerCreditCardsList do
4
+ let(:list) { NetSuite::Records::CustomerCreditCardsList.new }
5
+
6
+ it 'has a credit_cards attribute' do
7
+ expect(list.credit_cards).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ it 'can represent itself as a SOAP record' do
12
+ list.replace_all = true
13
+
14
+ record = {
15
+ 'listRel:creditCards' => [],
16
+ 'listRel:replaceAll' => true
17
+ }
18
+
19
+ expect(list.to_record).to eql(record)
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::CustomerSalesTeamList do
4
+ let(:list) { NetSuite::Records::CustomerSalesTeamList.new }
5
+
6
+ it 'has an customer_sales_team attribute' do
7
+ expect(list.sales_team).to be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ it 'can represent itself as a SOAP record' do
12
+ list.replace_all = true
13
+
14
+ record = {
15
+ 'listRel:salesTeam' => [],
16
+ 'listRel:replaceAll' => true
17
+ }
18
+ expect(list.to_record).to eql(record)
19
+ end
20
+ end
21
+
22
+ describe "#replace_all" do
23
+ it "can be changed via accessor" do
24
+ list.replace_all = false
25
+
26
+ expect(list.replace_all).to eql(false)
27
+ end
28
+
29
+ it "coerces to a boolean" do
30
+ list.replace_all = "goober"
31
+
32
+ record = {
33
+ 'listRel:salesTeam' => [],
34
+ 'listRel:replaceAll' => true
35
+ }
36
+
37
+ expect(list.to_record).to eql(record)
38
+ end
39
+ end
40
+
41
+ end
@@ -8,7 +8,7 @@ describe NetSuite::Records::Customer do
8
8
  :account_number, :aging, :alt_email, :alt_name, :alt_phone, :balance, :bill_pay,
9
9
  :buying_reason, :buying_time_frame, :campaign_category, :click_stream, :comments, :company_name,
10
10
  :consol_aging, :consol_balance, :consol_days_overdue, :consol_deposit_balance, :consol_overdue_balance,
11
- :consol_unbilled_orders, :contrib_pct, :credit_cards_list, :credit_hold_override, :credit_limit,
11
+ :consol_unbilled_orders, :contrib_pct, :credit_hold_override, :credit_limit,
12
12
  :date_created, :days_overdue, :default_address,
13
13
  :deposit_balance, :download_list, :email, :email_preference, :email_transactions, :end_date, :entity_id,
14
14
  :estimated_budget, :fax, :fax_transactions, :first_name, :first_visit, :give_access, :global_subscription_status,
@@ -17,7 +17,7 @@ describe NetSuite::Records::Customer do
17
17
  :opening_balance, :opening_balance_account, :opening_balance_date, :overdue_balance,
18
18
  :password, :password2, :phone, :phonetic_name, :pref_cc_processor,:print_on_check_as,
19
19
  :print_transactions, :referrer, :reminder_days, :representing_subsidiary, :require_pwd_change, :resale_number,
20
- :sales_group, :sales_readiness, :sales_team_list, :salutation, :send_email, :ship_complete,
20
+ :sales_group, :sales_readiness, :salutation, :send_email, :ship_complete,
21
21
  :stage, :start_date, :sync_partner_teams, :tax_exempt, :taxable,
22
22
  :third_party_acct, :third_party_country, :third_party_zipcode, :title, :unbilled_orders, :url,
23
23
  :vat_reg_number, :visits, :web_lead
@@ -65,6 +65,27 @@ describe NetSuite::Records::Customer do
65
65
  end
66
66
  end
67
67
 
68
+ describe '#credit_cards_list' do
69
+ it 'can be set from attributes' do
70
+ customer.credit_cards_list = {
71
+ :credit_cards => {
72
+ :internal_id => '1234567',
73
+ :cc_default => true,
74
+ :cc_expire_date => '2099-12-01T00:00:00.000-08:00'
75
+ }
76
+ }
77
+
78
+ expect(customer.credit_cards_list).to be_kind_of(NetSuite::Records::CustomerCreditCardsList)
79
+ expect(customer.credit_cards_list.credit_cards.length).to eql(1)
80
+ end
81
+
82
+ it 'can be set from a CustomerCreditCardsList object' do
83
+ customer_credit_cards_list = NetSuite::Records::CustomerCreditCardsList.new
84
+ customer.credit_cards_list = customer_credit_cards_list
85
+ expect(customer.credit_cards_list).to eql(customer_credit_cards_list)
86
+ end
87
+ end
88
+
68
89
  describe '#custom_field_list' do
69
90
  it 'can be set from attributes' do
70
91
  attributes = {
@@ -85,6 +106,27 @@ describe NetSuite::Records::Customer do
85
106
  end
86
107
  end
87
108
 
109
+ describe '#subscriptions_list' do
110
+ it 'can be set from attributes' do
111
+ customer.subscriptions_list = {
112
+ subscriptions: [
113
+ {
114
+ :subscribed => true
115
+ }
116
+ ]
117
+ }
118
+ expect(customer.subscriptions_list).to be_kind_of(NetSuite::Records::CustomerSubscriptionsList)
119
+ expect(customer.subscriptions_list.subscriptions.length).to eql(1)
120
+ end
121
+
122
+ it 'can be set from a CustomerSubscriptionsList object' do
123
+ customer_subscriptions_list = NetSuite::Records::CustomerSubscriptionsList.new
124
+ customer.subscriptions_list = customer_subscriptions_list
125
+ expect(customer.subscriptions_list).to eql(customer_subscriptions_list)
126
+ end
127
+ end
128
+
129
+
88
130
  describe '.get' do
89
131
  context 'when the response is successful' do
90
132
  let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::CustomerSubscription do
4
+
5
+ before do
6
+ NetSuite::Configuration.api_version = '2014_2'
7
+ end
8
+
9
+ let(:attributes) do
10
+ {
11
+ :subscription => {
12
+ :subscribed => true,
13
+ :subscription => NetSuite::Records::RecordRef.new(internal_id: '123123', name: 'My Sub'),
14
+ :last_modified_date => DateTime.new(2018, 1, 1, 0, 0, 0)
15
+ }
16
+ }
17
+ end
18
+
19
+ let(:list) { NetSuite::Records::CustomerSubscription.new(attributes) }
20
+
21
+ it 'has all the right fields' do
22
+ [
23
+ :subscribed, :last_modified_date
24
+ ].each do |field|
25
+ expect(list).to have_field(field)
26
+ end
27
+
28
+ expect(list.subscription).to_not be_nil
29
+ end
30
+
31
+ describe '#initialize' do
32
+ context 'when taking in a hash of attributes' do
33
+ it 'sets the attributes for the object given the attributes hash' do
34
+ expect(list.subscription.subscribed).to eql(true)
35
+ expect(list.subscription.subscription.internal_id).to eql('123123')
36
+ expect(list.subscription.subscription.name).to eql('My Sub')
37
+ expect(list.subscription.last_modified_date).to_not be_nil
38
+ end
39
+ end
40
+ end
41
+ end