netsuite 0.8.12 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codeql-analysis.yml +3 -3
  3. data/Gemfile +7 -0
  4. data/HISTORY.md +24 -0
  5. data/README.md +26 -0
  6. data/lib/netsuite/actions/add.rb +2 -1
  7. data/lib/netsuite/actions/delete.rb +17 -0
  8. data/lib/netsuite/configuration.rb +37 -4
  9. data/lib/netsuite/records/assembly_item.rb +2 -1
  10. data/lib/netsuite/records/customer.rb +225 -23
  11. data/lib/netsuite/records/customer_refund.rb +1 -1
  12. data/lib/netsuite/records/description_item.rb +1 -1
  13. data/lib/netsuite/records/discount_item.rb +1 -1
  14. data/lib/netsuite/records/file.rb +1 -1
  15. data/lib/netsuite/records/gift_certificate_item.rb +1 -1
  16. data/lib/netsuite/records/item_availability.rb +46 -0
  17. data/lib/netsuite/records/item_fulfillment.rb +4 -1
  18. data/lib/netsuite/records/item_fulfillment_package_fed_ex.rb +28 -0
  19. data/lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb +32 -0
  20. data/lib/netsuite/records/item_fulfillment_package_ups.rb +27 -0
  21. data/lib/netsuite/records/item_fulfillment_package_ups_list.rb +32 -0
  22. data/lib/netsuite/records/item_fulfillment_package_usps.rb +26 -0
  23. data/lib/netsuite/records/item_fulfillment_package_usps_list.rb +32 -0
  24. data/lib/netsuite/records/item_group.rb +1 -1
  25. data/lib/netsuite/records/kit_item.rb +1 -1
  26. data/lib/netsuite/records/lot_numbered_assembly_item.rb +1 -1
  27. data/lib/netsuite/records/non_inventory_purchase_item.rb +1 -1
  28. data/lib/netsuite/records/non_inventory_resale_item.rb +1 -1
  29. data/lib/netsuite/records/non_inventory_sale_item.rb +1 -1
  30. data/lib/netsuite/records/other_charge_sale_item.rb +1 -1
  31. data/lib/netsuite/records/payment_item.rb +1 -1
  32. data/lib/netsuite/records/sales_order.rb +1 -0
  33. data/lib/netsuite/records/sales_order_item.rb +2 -1
  34. data/lib/netsuite/records/serialized_assembly_item.rb +1 -1
  35. data/lib/netsuite/records/serialized_inventory_item.rb +1 -1
  36. data/lib/netsuite/records/service_resale_item.rb +1 -1
  37. data/lib/netsuite/records/service_sale_item.rb +1 -1
  38. data/lib/netsuite/records/{customer_subscription.rb → subscription.rb} +1 -1
  39. data/lib/netsuite/records/subscriptions_list.rb +10 -0
  40. data/lib/netsuite/records/subtotal_item.rb +1 -1
  41. data/lib/netsuite/support/sublist.rb +1 -1
  42. data/lib/netsuite/utilities.rb +35 -13
  43. data/lib/netsuite/version.rb +1 -1
  44. data/lib/netsuite.rb +9 -2
  45. data/netsuite.gemspec +6 -3
  46. data/spec/netsuite/actions/add_spec.rb +4 -2
  47. data/spec/netsuite/actions/delete_spec.rb +74 -14
  48. data/spec/netsuite/actions/get_select_value_spec.rb +43 -0
  49. data/spec/netsuite/configuration_spec.rb +62 -3
  50. data/spec/netsuite/records/customer_spec.rb +287 -20
  51. data/spec/netsuite/records/item_availability_spec.rb +59 -0
  52. data/spec/netsuite/records/item_fulfillment_package_fed_ex_list_spec.rb +27 -0
  53. data/spec/netsuite/records/item_fulfillment_package_ups_list_spec.rb +27 -0
  54. data/spec/netsuite/records/item_fulfillment_package_usps_list_spec.rb +27 -0
  55. data/spec/netsuite/records/sales_order_item_spec.rb +4 -3
  56. data/spec/netsuite/records/sales_order_spec.rb +17 -0
  57. data/spec/netsuite/records/{customer_subscription_spec.rb → subscription_spec.rb} +2 -2
  58. data/spec/netsuite/records/{customer_subscriptions_list_spec.rb → subscriptions_list_spec.rb} +2 -2
  59. data/spec/support/fixtures/add/add_invoice.xml +9 -5
  60. data/spec/support/fixtures/delete/delete_customer_error.xml +21 -0
  61. data/spec/support/fixtures/delete/delete_customer_multiple_errors.xml +25 -0
  62. data/spec/support/fixtures/get_item_availability/get_item_availability.xml +46 -0
  63. data/spec/support/fixtures/get_select_value/empty_result.xml +22 -0
  64. data/spec/support/fixtures/get_select_value/item_fulfillment_ship_method.xml +43 -0
  65. metadata +46 -9
  66. data/lib/netsuite/records/customer_subscriptions_list.rb +0 -10
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentPackageFedExList
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranSales
7
+
8
+ fields :package_fed_ex
9
+
10
+ def initialize(attributes = {})
11
+ initialize_from_attributes_hash(attributes)
12
+ end
13
+
14
+ def package_fed_ex=(packages)
15
+ case packages
16
+ when Hash
17
+ self.packages << ItemFulfillmentPackageFedEx.new(packages)
18
+ when Array
19
+ packages.each { |package| self.packages << ItemFulfillmentPackageFedEx.new(package) }
20
+ end
21
+ end
22
+
23
+ def packages
24
+ @packages ||= []
25
+ end
26
+
27
+ def to_record
28
+ { "#{record_namespace}:packageFedEx" => packages.map(&:to_record) }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentPackageUps
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranSales
7
+
8
+ fields :additional_handling_ups, :cod_amount_ups, :cod_method_ups, :delivery_conf_ups, :insured_value_ups, :package_descr_ups,
9
+ :package_height_ups, :package_length_ups, :package_tracking_number_ups, :package_weight_ups, :package_width_ups,
10
+ :packaging_ups, :reference1_ups, :reference2_ups, :use_cod_ups
11
+
12
+
13
+ def initialize(attributes_or_record = {})
14
+ case attributes_or_record
15
+ when Hash
16
+ initialize_from_attributes_hash(attributes_or_record)
17
+ when self.class
18
+ initialize_from_record(attributes_or_record)
19
+ end
20
+ end
21
+
22
+ def initialize_from_record(record)
23
+ self.attributes = record.send(:attributes)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentPackageUpsList
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranSales
7
+
8
+ fields :package_ups
9
+
10
+ def initialize(attributes = {})
11
+ initialize_from_attributes_hash(attributes)
12
+ end
13
+
14
+ def package_ups=(packages)
15
+ case packages
16
+ when Hash
17
+ self.packages << ItemFulfillmentPackageUps.new(packages)
18
+ when Array
19
+ packages.each { |package| self.packages << ItemFulfillmentPackageUps.new(package) }
20
+ end
21
+ end
22
+
23
+ def packages
24
+ @packages ||= []
25
+ end
26
+
27
+ def to_record
28
+ { "#{record_namespace}:packageUps" => packages.map(&:to_record) }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,26 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentPackageUsps
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranSales
7
+
8
+ fields :insured_value_usps, :package_descr_usps, :package_height_usps, :package_length_usps,
9
+ :package_tracking_number_usps, :package_weight_usps, :package_width_usps, :reference1_usps, :reference2_usps, :use_insured_value_usps
10
+
11
+
12
+ def initialize(attributes_or_record = {})
13
+ case attributes_or_record
14
+ when Hash
15
+ initialize_from_attributes_hash(attributes_or_record)
16
+ when self.class
17
+ initialize_from_record(attributes_or_record)
18
+ end
19
+ end
20
+
21
+ def initialize_from_record(record)
22
+ self.attributes = record.send(:attributes)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentPackageUspsList
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranSales
7
+
8
+ fields :package_usps
9
+
10
+ def initialize(attributes = {})
11
+ initialize_from_attributes_hash(attributes)
12
+ end
13
+
14
+ def package_usps=(packages)
15
+ case packages
16
+ when Hash
17
+ self.packages << ItemFulfillmentPackageUsps.new(packages)
18
+ when Array
19
+ packages.each { |package| self.packages << ItemFulfillmentPackageUsps.new(package) }
20
+ end
21
+ end
22
+
23
+ def packages
24
+ @packages ||= []
25
+ end
26
+
27
+ def to_record
28
+ { "#{record_namespace}:packageUsps" => packages.map(&:to_record) }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert
11
11
 
12
12
  fields :available_to_partners, :created_date, :description, :display_name, :include_children, :include_start_end_lines,
13
13
  :is_inactive, :is_vsoe_bundle, :item_id, :last_modified_date, :print_items, :upc_code, :vendor_name
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert
11
11
 
12
12
  fields :available_to_partners, :cost_estimate, :created_date, :defer_rev_rec, :description, :display_name,
13
13
  :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description, :handling_cost,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :get_select_value, :add, :delete, :update, :upsert, :upsert_list, :search
10
+ actions :get, :get_deleted, :get_list, :get_select_value, :add, :delete, :update, :update_list, :upsert, :upsert_list, :search
11
11
 
12
12
  fields :auto_lead_time, :auto_preferred_stock_level, :auto_reorder_point, :available_to_partners, :average_cost, :build_entire_assembly,
13
13
  :copy_description, :cost, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :cost_units, :costing_method,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update_list, :upsert
11
11
 
12
12
  fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture,
13
13
  :created_date, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :upsert, :update
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :upsert, :update, :update_list
11
11
 
12
12
  fields :amortization_period,
13
13
  :available_to_partners,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert
11
11
 
12
12
  fields :available_to_partners,
13
13
  :contingent_revenue_handling,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :update, :delete, :upsert, :search
10
+ actions :get, :get_deleted, :get_list, :add, :update, :update_list, :delete, :upsert, :search
11
11
 
12
12
  attr_reader :internal_id
13
13
  attr_accessor :external_id
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert
11
11
 
12
12
  fields :available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :item_id, :last_modified_date, :undep_funds
13
13
 
@@ -33,6 +33,7 @@ module NetSuite
33
33
  field :gift_cert_redemption_list, GiftCertRedemptionList
34
34
  field :ship_group_list, SalesOrderShipGroupList
35
35
  field :promotions_list, PromotionsList
36
+ field :null_field_list, NullFieldList
36
37
 
37
38
  read_only_fields :applied, :discount_total, :sub_total, :tax_total, :total, :unapplied,
38
39
  :est_gross_profit_percent
@@ -17,7 +17,8 @@ module NetSuite
17
17
  :rev_rec_start_date, :rev_rec_term_in_months, :serial_numbers,
18
18
  :shipping_cost, :tax1_amt, :tax_rate1, :tax_rate2,
19
19
  :vsoe_allocation, :vsoe_amount, :vsoe_deferral,
20
- :vsoe_delivered, :vsoe_permit_discount, :vsoe_price
20
+ :vsoe_delivered, :vsoe_permit_discount, :vsoe_price,
21
+ :ship_group
21
22
 
22
23
  field :custom_field_list, CustomFieldList
23
24
 
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert
11
11
 
12
12
  fields :alternate_demand_source_item,
13
13
  :asset_account,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert
11
11
 
12
12
  record_refs :soft_descriptor,
13
13
  :stock_unit,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :update, :delete, :upsert, :search
10
+ actions :get, :get_deleted, :get_list, :add, :update, :update_list, :delete, :upsert, :search
11
11
 
12
12
  fields :amortization_period,
13
13
  :available_to_partners,
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :update, :delete, :upsert, :search
10
+ actions :get, :get_deleted, :get_list, :add, :update, :update_list, :delete, :upsert, :search
11
11
 
12
12
  fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :create_job, :created_date,
13
13
  :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap, :featured_description,
@@ -1,6 +1,6 @@
1
1
  module NetSuite
2
2
  module Records
3
- class CustomerSubscription
3
+ class Subscription
4
4
  include Support::Fields
5
5
  include Support::Records
6
6
  include Support::RecordRefs
@@ -0,0 +1,10 @@
1
+ module NetSuite
2
+ module Records
3
+ class SubscriptionsList < Support::Sublist
4
+ include Namespaces::ListRel
5
+
6
+ sublist :subscriptions, Subscription
7
+
8
+ end
9
+ end
10
+ end
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListAcct
9
9
 
10
- actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :upsert
10
+ actions :get, :get_deleted, :get_list, :add, :delete, :search, :update, :update_list, :upsert
11
11
 
12
12
  fields :available_to_partners, :created_date, :description, :include_children, :is_inactive, :item_id, :last_modified_date
13
13
 
@@ -31,7 +31,7 @@ module NetSuite
31
31
  end
32
32
 
33
33
  def initialize(attributes = {})
34
- initialize_from_attributes_hash(attributes)
34
+ initialize_from_attributes_hash(attributes || {})
35
35
  end
36
36
 
37
37
  def to_record
@@ -7,11 +7,33 @@ module NetSuite
7
7
  # TODO need structured logger for various statements
8
8
 
9
9
  def clear_cache!
10
- @netsuite_get_record_cache = {}
11
- @netsuite_find_record_cache = {}
10
+ if NetSuite::Configuration.multi_tenant?
11
+ Thread.current[:netsuite_gem_netsuite_get_record_cache] = {}
12
+ Thread.current[:netsuite_gem_netsuite_find_record_cache] = {}
13
+ else
14
+ @netsuite_get_record_cache = {}
15
+ @netsuite_find_record_cache = {}
16
+ end
17
+
12
18
  DataCenter.clear_cache!
13
19
  end
14
20
 
21
+ def netsuite_get_record_cache
22
+ if NetSuite::Configuration.multi_tenant?
23
+ Thread.current[:netsuite_gem_netsuite_get_record_cache] ||= {}
24
+ else
25
+ @netsuite_get_record_cache ||= {}
26
+ end
27
+ end
28
+
29
+ def netsuite_find_record_cache
30
+ if NetSuite::Configuration.multi_tenant?
31
+ Thread.current[:netsuite_gem_netsuite_find_record_cache] ||= {}
32
+ else
33
+ @netsuite_find_record_cache ||= {}
34
+ end
35
+ end
36
+
15
37
  def append_memo(ns_record, added_memo, opts = {})
16
38
  opts[:skip_if_exists] ||= false
17
39
 
@@ -103,6 +125,8 @@ module NetSuite
103
125
  exceptions_to_retry << OpenSSL::SSL::SSLErrorWaitReadable if defined?(OpenSSL::SSL::SSLErrorWaitReadable)
104
126
 
105
127
  # depends on the http library chosen
128
+ exceptions_to_retry << HTTPI::SSLError if defined?(HTTPI::SSLError)
129
+ exceptions_to_retry << HTTPI::TimeoutError if defined?(HTTPI::TimeoutError)
106
130
  exceptions_to_retry << HTTPClient::TimeoutError if defined?(HTTPClient::TimeoutError)
107
131
  exceptions_to_retry << HTTPClient::ConnectTimeoutError if defined?(HTTPClient::ConnectTimeoutError)
108
132
  exceptions_to_retry << HTTPClient::ReceiveTimeoutError if defined?(HTTPClient::ReceiveTimeoutError)
@@ -177,6 +201,7 @@ module NetSuite
177
201
  ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ServiceResaleItem, ns_item_internal_id, opts)
178
202
  ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::GiftCertificateItem, ns_item_internal_id, opts)
179
203
  ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::KitItem, ns_item_internal_id, opts)
204
+ ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ItemGroup, ns_item_internal_id, opts)
180
205
  ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedInventoryItem, ns_item_internal_id, opts)
181
206
  ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedAssemblyItem, ns_item_internal_id, opts)
182
207
  ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::LotNumberedAssemblyItem, ns_item_internal_id, opts)
@@ -193,11 +218,10 @@ module NetSuite
193
218
  opts[:external_id] ||= false
194
219
 
195
220
  if opts[:cache]
196
- @netsuite_get_record_cache ||= {}
197
- @netsuite_get_record_cache[record_klass.to_s] ||= {}
221
+ netsuite_get_record_cache[record_klass.to_s] ||= {}
198
222
 
199
- if @netsuite_get_record_cache[record_klass.to_s].has_key?(id.to_i)
200
- return @netsuite_get_record_cache[record_klass.to_s][id.to_i]
223
+ if netsuite_get_record_cache[record_klass.to_s].has_key?(id.to_i)
224
+ return netsuite_get_record_cache[record_klass.to_s][id.to_i]
201
225
  end
202
226
  end
203
227
 
@@ -211,14 +235,14 @@ module NetSuite
211
235
  end
212
236
 
213
237
  if opts[:cache]
214
- @netsuite_get_record_cache[record_klass.to_s][id.to_i] = ns_record
238
+ netsuite_get_record_cache[record_klass.to_s][id.to_i] = ns_record
215
239
  end
216
240
 
217
241
  return ns_record
218
242
  rescue ::NetSuite::RecordNotFound
219
243
  # log.warn("record not found", ns_record_type: record_klass.name, ns_record_id: id)
220
244
  if opts[:cache]
221
- @netsuite_get_record_cache[record_klass.to_s][id.to_i] = nil
245
+ netsuite_get_record_cache[record_klass.to_s][id.to_i] = nil
222
246
  end
223
247
 
224
248
  return nil
@@ -233,10 +257,8 @@ module NetSuite
233
257
  # FIXME: Records that have the same name but different types will break
234
258
  # the cache
235
259
  names.each do |name|
236
- @netsuite_find_record_cache ||= {}
237
-
238
- if @netsuite_find_record_cache.has_key?(name)
239
- return @netsuite_find_record_cache[name]
260
+ if netsuite_find_record_cache.has_key?(name)
261
+ return netsuite_find_record_cache[name]
240
262
  end
241
263
 
242
264
  # sniff for an email-like input; useful for employee/customer searches
@@ -262,7 +284,7 @@ module NetSuite
262
284
  }) }
263
285
 
264
286
  if search.results.first
265
- return @netsuite_find_record_cache[name] = search.results.first
287
+ return netsuite_find_record_cache[name] = search.results.first
266
288
  end
267
289
  end
268
290
 
@@ -1,3 +1,3 @@
1
1
  module NetSuite
2
- VERSION = '0.8.12'
2
+ VERSION = '0.9.1'
3
3
  end
data/lib/netsuite.rb CHANGED
@@ -133,8 +133,6 @@ module NetSuite
133
133
  autoload :CustomerRefundApplyList, 'netsuite/records/customer_refund_apply_list'
134
134
  autoload :CustomerRefundDeposit, 'netsuite/records/customer_refund_deposit'
135
135
  autoload :CustomerRefundDepositList, 'netsuite/records/customer_refund_deposit_list'
136
- autoload :CustomerSubscription, 'netsuite/records/customer_subscription'
137
- autoload :CustomerSubscriptionsList, 'netsuite/records/customer_subscriptions_list'
138
136
  autoload :CustomerStatus, 'netsuite/records/customer_status'
139
137
  autoload :CustomerPartner, 'netsuite/records/customer_partner'
140
138
  autoload :CustomerSalesTeam, 'netsuite/records/customer_sales_team'
@@ -193,11 +191,18 @@ module NetSuite
193
191
  autoload :Invoice, 'netsuite/records/invoice'
194
192
  autoload :InvoiceItem, 'netsuite/records/invoice_item'
195
193
  autoload :InvoiceItemList, 'netsuite/records/invoice_item_list'
194
+ autoload :ItemAvailability, 'netsuite/records/item_availability'
196
195
  autoload :ItemFulfillment, 'netsuite/records/item_fulfillment'
197
196
  autoload :ItemFulfillmentItem, 'netsuite/records/item_fulfillment_item'
198
197
  autoload :ItemFulfillmentItemList, 'netsuite/records/item_fulfillment_item_list'
199
198
  autoload :ItemFulfillmentPackage, 'netsuite/records/item_fulfillment_package'
200
199
  autoload :ItemFulfillmentPackageList, 'netsuite/records/item_fulfillment_package_list'
200
+ autoload :ItemFulfillmentPackageFedEx, 'netsuite/records/item_fulfillment_package_fed_ex'
201
+ autoload :ItemFulfillmentPackageUps, 'netsuite/records/item_fulfillment_package_ups'
202
+ autoload :ItemFulfillmentPackageUsps, 'netsuite/records/item_fulfillment_package_usps'
203
+ autoload :ItemFulfillmentPackageFedExList, 'netsuite/records/item_fulfillment_package_fed_ex_list'
204
+ autoload :ItemFulfillmentPackageUpsList, 'netsuite/records/item_fulfillment_package_ups_list'
205
+ autoload :ItemFulfillmentPackageUspsList, 'netsuite/records/item_fulfillment_package_usps_list'
201
206
  autoload :ItemGroup, 'netsuite/records/item_group'
202
207
  autoload :ItemMember, 'netsuite/records/item_member'
203
208
  autoload :ItemMemberList, 'netsuite/records/item_member_list'
@@ -271,6 +276,8 @@ module NetSuite
271
276
  autoload :SerializedInventoryItemLocationsList, 'netsuite/records/serialized_inventory_item_locations_list'
272
277
  autoload :ShipAddress, 'netsuite/records/ship_address'
273
278
  autoload :SiteCategory, 'netsuite/records/site_category'
279
+ autoload :Subscription, 'netsuite/records/subscription'
280
+ autoload :SubscriptionsList, 'netsuite/records/subscriptions_list'
274
281
  autoload :Subsidiary, 'netsuite/records/subsidiary'
275
282
  autoload :SubtotalItem, 'netsuite/records/subtotal_item'
276
283
  autoload :SupportCase, 'netsuite/records/support_case'
data/netsuite.gemspec CHANGED
@@ -3,8 +3,8 @@ require File.expand_path('../lib/netsuite/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.licenses = ['MIT']
6
- gem.authors = ['Ryan Moran', 'Michael Bianco']
7
- gem.email = ['ryan.moran@gmail.com', 'mike@mikebian.co']
6
+ gem.authors = ['Ryan Moran', 'Michael Bianco', 'Chris Gunther']
7
+ gem.email = ['ryan.moran@gmail.com', 'mike@mikebian.co', 'chris@room118solutions.com']
8
8
  gem.description = %q{NetSuite SuiteTalk API Wrapper}
9
9
  gem.summary = %q{NetSuite SuiteTalk API (SOAP) Wrapper}
10
10
  gem.homepage = 'https://github.com/NetSweet/netsuite'
@@ -15,9 +15,12 @@ Gem::Specification.new do |gem|
15
15
  gem.name = 'netsuite'
16
16
  gem.require_paths = ['lib']
17
17
  gem.version = NetSuite::VERSION
18
+ gem.required_ruby_version = '>= 2.1'
18
19
  gem.metadata['changelog_uri'] = 'https://github.com/netsweet/netsuite/blob/master/HISTORY.md'
20
+ gem.metadata['mailing_list_uri'] = 'http://opensuite-slackin.herokuapp.com'
21
+ gem.metadata['rubygems_mfa_required'] = 'true'
19
22
 
20
- gem.add_dependency 'savon', '>= 2.3.0'
23
+ gem.add_dependency 'savon', '>= 2.3.0', '!= 2.13.0'
21
24
 
22
25
  gem.add_development_dependency 'rspec', '~> 3.11.0'
23
26
  gem.add_development_dependency 'rake', '~> 12.3.3'
@@ -53,10 +53,11 @@ describe NetSuite::Actions::Add do
53
53
  NetSuite::Actions::Add.call([invoice])
54
54
  end
55
55
 
56
- it 'returns a valid Response object' do
56
+ it 'returns a valid Response object with no errors' do
57
57
  response = NetSuite::Actions::Add.call([invoice])
58
58
  expect(response).to be_kind_of(NetSuite::Response)
59
59
  expect(response).to be_success
60
+ expect(response.errors).to be_empty
60
61
  end
61
62
  end
62
63
 
@@ -136,10 +137,11 @@ describe NetSuite::Actions::Add do
136
137
  NetSuite::Actions::Add.call([file])
137
138
  end
138
139
 
139
- it 'returns a valid Response object' do
140
+ it 'returns a valid Response object with no errors' do
140
141
  response = NetSuite::Actions::Add.call([file])
141
142
  expect(response).to be_kind_of(NetSuite::Response)
142
143
  expect(response).to be_success
144
+ expect(response.errors).to be_empty
143
145
  end
144
146
 
145
147
  it 'properly extracts internal ID from response' do
@@ -9,24 +9,84 @@ describe NetSuite::Actions::Delete do
9
9
  NetSuite::Records::Customer.new(:internal_id => '980', :entity_id => 'Shutter Fly', :company_name => 'Shutter Fly, Inc.')
10
10
  end
11
11
 
12
- before do
13
- savon.expects(:delete).with(:message => {
14
- 'platformMsgs:baseRef' => {
15
- '@internalId' => '980',
16
- '@type' => 'customer',
17
- '@xsi:type' => 'platformCore:RecordRef'
18
- },
19
- }).returns(File.read('spec/support/fixtures/delete/delete_customer.xml'))
12
+ context 'when successful' do
13
+ before do
14
+ savon.expects(:delete).with(:message => {
15
+ 'platformMsgs:baseRef' => {
16
+ '@internalId' => '980',
17
+ '@type' => 'customer',
18
+ '@xsi:type' => 'platformCore:RecordRef'
19
+ },
20
+ }).returns(File.read('spec/support/fixtures/delete/delete_customer.xml'))
21
+ end
22
+
23
+ it 'makes a valid request to the NetSuite API' do
24
+ NetSuite::Actions::Delete.call([customer])
25
+ end
26
+
27
+ it 'returns a valid Response object' do
28
+ response = NetSuite::Actions::Delete.call([customer])
29
+ expect(response).to be_kind_of(NetSuite::Response)
30
+ expect(response).to be_success
31
+ end
20
32
  end
21
33
 
22
- it 'makes a valid request to the NetSuite API' do
23
- NetSuite::Actions::Delete.call([customer])
34
+ context 'when not successful' do
35
+ before do
36
+ savon.expects(:delete).with(:message => {
37
+ 'platformMsgs:baseRef' => {
38
+ '@xsi:type' => 'platformCore:RecordRef',
39
+ '@internalId' => '980',
40
+ '@type' => 'customer',
41
+ },
42
+ }).returns(File.read('spec/support/fixtures/delete/delete_customer_error.xml'))
43
+ end
44
+
45
+ it 'provides an error method on the object with details about the error' do
46
+ customer.delete
47
+ error = customer.errors.first
48
+
49
+ expect(error).to be_kind_of(NetSuite::Error)
50
+ expect(error.type).to eq('ERROR')
51
+ expect(error.code).to eq('INSUFFICIENT_PERMISSION')
52
+ expect(error.message).to eq("Permission Violation: You need a higher level of the 'Lists -> Documents and Files' permission to access this page. Please contact your account administrator.")
53
+ end
54
+
55
+ it 'provides an error method on the response' do
56
+ response = NetSuite::Actions::Delete.call([customer])
57
+ expect(response.errors.first).to be_kind_of(NetSuite::Error)
58
+ end
24
59
  end
25
60
 
26
- it 'returns a valid Response object' do
27
- response = NetSuite::Actions::Delete.call([customer])
28
- expect(response).to be_kind_of(NetSuite::Response)
29
- expect(response).to be_success
61
+ context 'when not successful with multiple errors' do
62
+ before do
63
+ savon.expects(:delete).with(:message => {
64
+ 'platformMsgs:baseRef' => {
65
+ '@xsi:type' => 'platformCore:RecordRef',
66
+ '@internalId' => '980',
67
+ '@type' => 'customer',
68
+ },
69
+ }).returns(File.read('spec/support/fixtures/delete/delete_customer_multiple_errors.xml'))
70
+ end
71
+
72
+ it 'provides an error method on the object with details about the error' do
73
+ customer.delete
74
+ expect(customer.errors.length).to eq(2)
75
+
76
+ error = customer.errors.first
77
+
78
+ expect(error).to be_kind_of(NetSuite::Error)
79
+ expect(error.type).to eq('ERROR')
80
+ expect(error.code).to eq('INSUFFICIENT_PERMISSION')
81
+ expect(error.message).to eq("Permission Violation: You need a higher level of the 'Lists -> Documents and Files' permission to access this page. Please contact your account administrator.")
82
+
83
+ error = customer.errors[1]
84
+
85
+ expect(error).to be_kind_of(NetSuite::Error)
86
+ expect(error.type).to eq('ERROR')
87
+ expect(error.code).to eq('SOMETHING_ELSE')
88
+ expect(error.message).to eq('Another error.')
89
+ end
30
90
  end
31
91
  end
32
92