netsuite 0.8.12 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/codeql-analysis.yml +3 -3
- data/HISTORY.md +21 -1
- data/lib/netsuite/actions/add.rb +2 -1
- data/lib/netsuite/actions/delete.rb +17 -0
- data/lib/netsuite/configuration.rb +16 -3
- data/lib/netsuite/records/assembly_item.rb +2 -1
- data/lib/netsuite/records/customer.rb +225 -23
- data/lib/netsuite/records/customer_refund.rb +1 -1
- data/lib/netsuite/records/description_item.rb +1 -1
- data/lib/netsuite/records/discount_item.rb +1 -1
- data/lib/netsuite/records/file.rb +1 -1
- data/lib/netsuite/records/gift_certificate_item.rb +1 -1
- data/lib/netsuite/records/item_availability.rb +46 -0
- data/lib/netsuite/records/item_fulfillment.rb +4 -1
- data/lib/netsuite/records/item_fulfillment_package_fed_ex.rb +28 -0
- data/lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb +32 -0
- data/lib/netsuite/records/item_fulfillment_package_ups.rb +27 -0
- data/lib/netsuite/records/item_fulfillment_package_ups_list.rb +32 -0
- data/lib/netsuite/records/item_fulfillment_package_usps.rb +26 -0
- data/lib/netsuite/records/item_fulfillment_package_usps_list.rb +32 -0
- data/lib/netsuite/records/item_group.rb +1 -1
- data/lib/netsuite/records/kit_item.rb +1 -1
- data/lib/netsuite/records/lot_numbered_assembly_item.rb +1 -1
- data/lib/netsuite/records/non_inventory_purchase_item.rb +1 -1
- data/lib/netsuite/records/non_inventory_resale_item.rb +1 -1
- data/lib/netsuite/records/non_inventory_sale_item.rb +1 -1
- data/lib/netsuite/records/other_charge_sale_item.rb +1 -1
- data/lib/netsuite/records/payment_item.rb +1 -1
- data/lib/netsuite/records/sales_order.rb +1 -0
- data/lib/netsuite/records/sales_order_item.rb +2 -1
- data/lib/netsuite/records/serialized_assembly_item.rb +1 -1
- data/lib/netsuite/records/serialized_inventory_item.rb +1 -1
- data/lib/netsuite/records/service_resale_item.rb +1 -1
- data/lib/netsuite/records/service_sale_item.rb +1 -1
- data/lib/netsuite/records/{customer_subscription.rb → subscription.rb} +1 -1
- data/lib/netsuite/records/subscriptions_list.rb +10 -0
- data/lib/netsuite/records/subtotal_item.rb +1 -1
- data/lib/netsuite/support/sublist.rb +1 -1
- data/lib/netsuite/utilities.rb +20 -13
- data/lib/netsuite/version.rb +1 -1
- data/lib/netsuite.rb +9 -2
- data/netsuite.gemspec +3 -0
- data/spec/netsuite/actions/add_spec.rb +4 -2
- data/spec/netsuite/actions/delete_spec.rb +74 -14
- data/spec/netsuite/actions/get_select_value_spec.rb +43 -0
- data/spec/netsuite/configuration_spec.rb +35 -0
- data/spec/netsuite/records/customer_spec.rb +287 -20
- data/spec/netsuite/records/item_availability_spec.rb +59 -0
- data/spec/netsuite/records/item_fulfillment_package_fed_ex_list_spec.rb +27 -0
- data/spec/netsuite/records/item_fulfillment_package_ups_list_spec.rb +27 -0
- data/spec/netsuite/records/item_fulfillment_package_usps_list_spec.rb +27 -0
- data/spec/netsuite/records/sales_order_item_spec.rb +4 -3
- data/spec/netsuite/records/sales_order_spec.rb +17 -0
- data/spec/netsuite/records/{customer_subscription_spec.rb → subscription_spec.rb} +2 -2
- data/spec/netsuite/records/{customer_subscriptions_list_spec.rb → subscriptions_list_spec.rb} +2 -2
- data/spec/support/fixtures/add/add_invoice.xml +9 -5
- data/spec/support/fixtures/delete/delete_customer_error.xml +21 -0
- data/spec/support/fixtures/delete/delete_customer_multiple_errors.xml +25 -0
- data/spec/support/fixtures/get_item_availability/get_item_availability.xml +46 -0
- data/spec/support/fixtures/get_select_value/empty_result.xml +22 -0
- data/spec/support/fixtures/get_select_value/item_fulfillment_ship_method.xml +43 -0
- metadata +39 -10
- data/lib/netsuite/records/customer_subscriptions_list.rb +0 -10
@@ -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,
|
@@ -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
|
|
data/lib/netsuite/utilities.rb
CHANGED
@@ -7,11 +7,20 @@ module NetSuite
|
|
7
7
|
# TODO need structured logger for various statements
|
8
8
|
|
9
9
|
def clear_cache!
|
10
|
-
|
11
|
-
|
10
|
+
Thread.current[:netsuite_gem_netsuite_get_record_cache] = {}
|
11
|
+
Thread.current[:netsuite_gem_netsuite_find_record_cache] = {}
|
12
|
+
|
12
13
|
DataCenter.clear_cache!
|
13
14
|
end
|
14
15
|
|
16
|
+
def netsuite_get_record_cache
|
17
|
+
Thread.current[:netsuite_gem_netsuite_get_record_cache] ||= {}
|
18
|
+
end
|
19
|
+
|
20
|
+
def netsuite_find_record_cache
|
21
|
+
Thread.current[:netsuite_gem_netsuite_find_record_cache] ||= {}
|
22
|
+
end
|
23
|
+
|
15
24
|
def append_memo(ns_record, added_memo, opts = {})
|
16
25
|
opts[:skip_if_exists] ||= false
|
17
26
|
|
@@ -177,6 +186,7 @@ module NetSuite
|
|
177
186
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ServiceResaleItem, ns_item_internal_id, opts)
|
178
187
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::GiftCertificateItem, ns_item_internal_id, opts)
|
179
188
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::KitItem, ns_item_internal_id, opts)
|
189
|
+
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ItemGroup, ns_item_internal_id, opts)
|
180
190
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedInventoryItem, ns_item_internal_id, opts)
|
181
191
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedAssemblyItem, ns_item_internal_id, opts)
|
182
192
|
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::LotNumberedAssemblyItem, ns_item_internal_id, opts)
|
@@ -193,11 +203,10 @@ module NetSuite
|
|
193
203
|
opts[:external_id] ||= false
|
194
204
|
|
195
205
|
if opts[:cache]
|
196
|
-
|
197
|
-
@netsuite_get_record_cache[record_klass.to_s] ||= {}
|
206
|
+
netsuite_get_record_cache[record_klass.to_s] ||= {}
|
198
207
|
|
199
|
-
if
|
200
|
-
return
|
208
|
+
if netsuite_get_record_cache[record_klass.to_s].has_key?(id.to_i)
|
209
|
+
return netsuite_get_record_cache[record_klass.to_s][id.to_i]
|
201
210
|
end
|
202
211
|
end
|
203
212
|
|
@@ -211,14 +220,14 @@ module NetSuite
|
|
211
220
|
end
|
212
221
|
|
213
222
|
if opts[:cache]
|
214
|
-
|
223
|
+
netsuite_get_record_cache[record_klass.to_s][id.to_i] = ns_record
|
215
224
|
end
|
216
225
|
|
217
226
|
return ns_record
|
218
227
|
rescue ::NetSuite::RecordNotFound
|
219
228
|
# log.warn("record not found", ns_record_type: record_klass.name, ns_record_id: id)
|
220
229
|
if opts[:cache]
|
221
|
-
|
230
|
+
netsuite_get_record_cache[record_klass.to_s][id.to_i] = nil
|
222
231
|
end
|
223
232
|
|
224
233
|
return nil
|
@@ -233,10 +242,8 @@ module NetSuite
|
|
233
242
|
# FIXME: Records that have the same name but different types will break
|
234
243
|
# the cache
|
235
244
|
names.each do |name|
|
236
|
-
|
237
|
-
|
238
|
-
if @netsuite_find_record_cache.has_key?(name)
|
239
|
-
return @netsuite_find_record_cache[name]
|
245
|
+
if netsuite_find_record_cache.has_key?(name)
|
246
|
+
return netsuite_find_record_cache[name]
|
240
247
|
end
|
241
248
|
|
242
249
|
# sniff for an email-like input; useful for employee/customer searches
|
@@ -262,7 +269,7 @@ module NetSuite
|
|
262
269
|
}) }
|
263
270
|
|
264
271
|
if search.results.first
|
265
|
-
return
|
272
|
+
return netsuite_find_record_cache[name] = search.results.first
|
266
273
|
end
|
267
274
|
end
|
268
275
|
|
data/lib/netsuite/version.rb
CHANGED
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
@@ -15,7 +15,10 @@ 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
23
|
gem.add_dependency 'savon', '>= 2.3.0'
|
21
24
|
|
@@ -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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
'
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
23
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Actions::GetSelectValue do
|
4
|
+
before(:all) { savon.mock! }
|
5
|
+
after(:all) { savon.unmock! }
|
6
|
+
|
7
|
+
describe 'fulfillment ship method' do
|
8
|
+
subject do
|
9
|
+
NetSuite::Records::BaseRefList.get_select_value(recordType: 'itemFulfillment', field: 'shipMethod')
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:response) { File.read('spec/support/fixtures/get_select_value/item_fulfillment_ship_method.xml') }
|
13
|
+
|
14
|
+
before do
|
15
|
+
savon.expects(:get_select_value).with(:message => {
|
16
|
+
pageIndex: 1,
|
17
|
+
fieldDescription: {
|
18
|
+
'platformCore:recordType' => 'itemFulfillment',
|
19
|
+
'platformCore:field' => 'shipMethod'
|
20
|
+
}
|
21
|
+
}).returns(response)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'makes a valid request to the NetSuite API' do
|
25
|
+
subject
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns a BaseRefList object' do
|
29
|
+
expect(subject).to be_kind_of(NetSuite::Records::BaseRefList)
|
30
|
+
expect(subject.base_refs[0].internal_id).to eq('94')
|
31
|
+
expect(subject.base_refs[0].name).to eq('Ground (Custom)')
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'with empty result' do
|
35
|
+
let(:response) { File.read('spec/support/fixtures/get_select_value/empty_result.xml') }
|
36
|
+
|
37
|
+
it 'returns an empty list' do
|
38
|
+
expect(subject).to be_kind_of(NetSuite::Records::BaseRefList)
|
39
|
+
expect(subject.base_refs).to be_empty
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -14,6 +14,20 @@ describe NetSuite::Configuration do
|
|
14
14
|
config.reset!
|
15
15
|
expect(config.attributes).to be_empty
|
16
16
|
end
|
17
|
+
|
18
|
+
it 'ensures that attributes are not shared between threads' do
|
19
|
+
config.attributes[:blah] = 'something'
|
20
|
+
expect(config.attributes[:blah]).to eq('something')
|
21
|
+
|
22
|
+
thread = Thread.new {
|
23
|
+
config.attributes[:blah] = 'something_else'
|
24
|
+
expect(config.attributes[:blah]).to eq('something_else')
|
25
|
+
}
|
26
|
+
|
27
|
+
thread.join
|
28
|
+
|
29
|
+
expect(config.attributes[:blah]).to eq('something')
|
30
|
+
end
|
17
31
|
end
|
18
32
|
|
19
33
|
describe '#filters' do
|
@@ -476,4 +490,25 @@ describe NetSuite::Configuration do
|
|
476
490
|
end
|
477
491
|
end
|
478
492
|
|
493
|
+
describe '#proxy' do
|
494
|
+
it 'defaults to nil' do
|
495
|
+
expect(config.proxy).to be_nil
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'can be set with proxy=' do
|
499
|
+
config.proxy = "https://my-proxy"
|
500
|
+
|
501
|
+
expect(config.proxy).to eql("https://my-proxy")
|
502
|
+
|
503
|
+
# ensure no exception is raised
|
504
|
+
config.connection
|
505
|
+
end
|
506
|
+
|
507
|
+
it 'can be set with proxy(value)' do
|
508
|
+
config.proxy("https://my-proxy")
|
509
|
+
|
510
|
+
expect(config.proxy).to eql("https://my-proxy")
|
511
|
+
end
|
512
|
+
end
|
513
|
+
|
479
514
|
end
|