Skip to content

Update rake requirement from ~> 12.3.3 to ~> 13.0.6 #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
29 changes: 29 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'rspec' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("rspec-core", "rspec")
7 changes: 7 additions & 0 deletions lib/netsuite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,18 @@ module Records
autoload :Invoice, 'netsuite/records/invoice'
autoload :InvoiceItem, 'netsuite/records/invoice_item'
autoload :InvoiceItemList, 'netsuite/records/invoice_item_list'
autoload :ItemAvailability, 'netsuite/records/item_availability'
autoload :ItemFulfillment, 'netsuite/records/item_fulfillment'
autoload :ItemFulfillmentItem, 'netsuite/records/item_fulfillment_item'
autoload :ItemFulfillmentItemList, 'netsuite/records/item_fulfillment_item_list'
autoload :ItemFulfillmentPackage, 'netsuite/records/item_fulfillment_package'
autoload :ItemFulfillmentPackageList, 'netsuite/records/item_fulfillment_package_list'
autoload :ItemFulfillmentPackageFedEx, 'netsuite/records/item_fulfillment_package_fed_ex'
autoload :ItemFulfillmentPackageUps, 'netsuite/records/item_fulfillment_package_ups'
autoload :ItemFulfillmentPackageUsps, 'netsuite/records/item_fulfillment_package_usps'
autoload :ItemFulfillmentPackageFedExList, 'netsuite/records/item_fulfillment_package_fed_ex_list'
autoload :ItemFulfillmentPackageUpsList, 'netsuite/records/item_fulfillment_package_ups_list'
autoload :ItemFulfillmentPackageUspsList, 'netsuite/records/item_fulfillment_package_usps_list'
autoload :ItemGroup, 'netsuite/records/item_group'
autoload :ItemMember, 'netsuite/records/item_member'
autoload :ItemMemberList, 'netsuite/records/item_member_list'
Expand Down
2 changes: 1 addition & 1 deletion lib/netsuite/actions/get_select_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def success?
end

def response_body
@response_body ||= response_hash[:base_ref_list]
@response_body ||= response_hash[:base_ref_list] || {base_ref: []}
end

def response_hash
Expand Down
21 changes: 17 additions & 4 deletions lib/netsuite/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def reset!
end

def attributes
@attributes ||= {}
Thread.current[:netsuite_configuration] ||= {}
end

def connection(params={}, credentials={})
Expand All @@ -21,7 +21,7 @@ def connection(params={}, credentials={})
read_timeout: read_timeout,
open_timeout: open_timeout,
namespaces: namespaces,
soap_header: auth_header(credentials).update(soap_header),
soap_header: auth_header(credentials).merge(soap_header),
pretty_print_xml: true,
filters: filters,
logger: logger,
Expand Down Expand Up @@ -50,11 +50,12 @@ def filters=(list)
end

def wsdl_cache
@wsdl_cache ||= {}
Thread.current[:netsuite_wsdl_cache] ||= {}

end

def clear_wsdl_cache
@wsdl_cache = {}
Thread.current[:netsuite_wsdl_cache] = {}
end

def cached_wsdl
Expand Down Expand Up @@ -185,6 +186,18 @@ def auth_header(credentials={})
token_auth(credentials)
else
user_auth(credentials)
end.merge(application_info_header(credentials))
end

def application_info_header(credentials={})
if credentials[:application_id].blank?
{}
else
{
'platformMsgs:ApplicationInfo' => {
'platformMsgs:applicationId' => credentials[:application_id]
}
}
end
end

Expand Down
51 changes: 51 additions & 0 deletions lib/netsuite/records/item_availability.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module NetSuite
module Records
class ItemAvailability
include Support::Fields
include Support::RecordRefs
include Support::Records

field :item, InventoryItem
field :location_id, Location
alias_method :location, :location_id

field :quantity_on_hand
field :on_hand_value_mli
field :reorder_point
field :quantity_on_order
field :quantity_committed
field :quantity_available

def initialize(attributes = {})
initialize_from_attributes_hash(attributes)
end

def self.get_for_inventory_items(items, credentials={})
ref_list = NetSuite::Records::RecordRefList.new(
record_ref: items.map do |item|
{internal_id: item.internal_id}
end
)
connection = NetSuite::Configuration.connection({}, credentials)
response = connection.call :get_item_availability, message: {
"platformMsgs:itemAvailabilityFilter" => {
"platformCore:item" => ref_list.to_record
}
}
return false unless response.success?

result = response.body[:get_item_availability_response][:get_item_availability_result]
unless result[:status][:@is_success] == "true"
return false
end
if result[:item_availability_list]
result[:item_availability_list][:item_availability].map do |row|
NetSuite::Records::ItemAvailability.new(row)
end
else
[]
end
end
end
end
end
3 changes: 3 additions & 0 deletions lib/netsuite/records/item_fulfillment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class ItemFulfillment

field :item_list, ItemFulfillmentItemList
field :package_list, ItemFulfillmentPackageList
field :package_fed_ex_list, ItemFulfillmentPackageFedExList
field :package_ups_list, ItemFulfillmentPackageUpsList
field :package_usps_list, ItemFulfillmentPackageUspsList
field :custom_field_list, CustomFieldList

attr_reader :internal_id
Expand Down
28 changes: 28 additions & 0 deletions lib/netsuite/records/item_fulfillment_package_fed_ex.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module NetSuite
module Records
class ItemFulfillmentPackageFedEx
include Support::Fields
include Support::Records
include Namespaces::TranSales

fields :authorization_number_fed_ex, :cod_amount_fed_ex, :dry_ice_weight_fed_ex, :insured_value_fed_ex, :is_alcohol_fed_ex,
:is_non_haz_lithium_fed_ex, :is_non_standard_container_fed_ex, :package_height_fed_ex, :package_length_fed_ex,
:package_tracking_number_fed_ex, :package_weight_fed_ex, :package_width_fed_ex, :priority_alert_content_fed_ex,
:reference1_fed_ex, :signature_releasefed_ex, :use_cod_fed_ex, :use_insured_value_fed_ex


def initialize(attributes_or_record = {})
case attributes_or_record
when Hash
initialize_from_attributes_hash(attributes_or_record)
when self.class
initialize_from_record(attributes_or_record)
end
end

def initialize_from_record(record)
self.attributes = record.send(:attributes)
end
end
end
end
32 changes: 32 additions & 0 deletions lib/netsuite/records/item_fulfillment_package_fed_ex_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module NetSuite
module Records
class ItemFulfillmentPackageFedExList
include Support::Fields
include Support::Records
include Namespaces::TranSales

fields :package_fed_ex

def initialize(attributes = {})
initialize_from_attributes_hash(attributes)
end

def package_fed_ex=(packages)
case packages
when Hash
self.packages << ItemFulfillmentPackageFedEx.new(packages)
when Array
packages.each { |package| self.packages << ItemFulfillmentPackageFedEx.new(package) }
end
end

def packages
@packages ||= []
end

def to_record
{ "#{record_namespace}:packageFedEx" => packages.map(&:to_record) }
end
end
end
end
27 changes: 27 additions & 0 deletions lib/netsuite/records/item_fulfillment_package_ups.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module NetSuite
module Records
class ItemFulfillmentPackageUps
include Support::Fields
include Support::Records
include Namespaces::TranSales

fields :additional_handling_ups, :cod_amount_ups, :cod_method_ups, :delivery_conf_ups, :insured_value_ups, :package_descr_ups,
:package_height_ups, :package_length_ups, :package_tracking_number_ups, :package_weight_ups, :package_width_ups,
:packaging_ups, :reference1_ups, :reference2_ups, :use_cod_ups


def initialize(attributes_or_record = {})
case attributes_or_record
when Hash
initialize_from_attributes_hash(attributes_or_record)
when self.class
initialize_from_record(attributes_or_record)
end
end

def initialize_from_record(record)
self.attributes = record.send(:attributes)
end
end
end
end
32 changes: 32 additions & 0 deletions lib/netsuite/records/item_fulfillment_package_ups_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module NetSuite
module Records
class ItemFulfillmentPackageUpsList
include Support::Fields
include Support::Records
include Namespaces::TranSales

fields :package_ups

def initialize(attributes = {})
initialize_from_attributes_hash(attributes)
end

def package_ups=(packages)
case packages
when Hash
self.packages << ItemFulfillmentPackageUps.new(packages)
when Array
packages.each { |package| self.packages << ItemFulfillmentPackageUps.new(package) }
end
end

def packages
@packages ||= []
end

def to_record
{ "#{record_namespace}:packageUps" => packages.map(&:to_record) }
end
end
end
end
26 changes: 26 additions & 0 deletions lib/netsuite/records/item_fulfillment_package_usps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module NetSuite
module Records
class ItemFulfillmentPackageUsps
include Support::Fields
include Support::Records
include Namespaces::TranSales

fields :insured_value_usps, :package_descr_usps, :package_height_usps, :package_length_usps,
:package_tracking_number_usps, :package_weight_usps, :package_width_usps, :reference1_usps, :reference2_usps, :use_insured_value_usps


def initialize(attributes_or_record = {})
case attributes_or_record
when Hash
initialize_from_attributes_hash(attributes_or_record)
when self.class
initialize_from_record(attributes_or_record)
end
end

def initialize_from_record(record)
self.attributes = record.send(:attributes)
end
end
end
end
32 changes: 32 additions & 0 deletions lib/netsuite/records/item_fulfillment_package_usps_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module NetSuite
module Records
class ItemFulfillmentPackageUspsList
include Support::Fields
include Support::Records
include Namespaces::TranSales

fields :package_usps

def initialize(attributes = {})
initialize_from_attributes_hash(attributes)
end

def package_usps=(packages)
case packages
when Hash
self.packages << ItemFulfillmentPackageUsps.new(packages)
when Array
packages.each { |package| self.packages << ItemFulfillmentPackageUsps.new(package) }
end
end

def packages
@packages ||= []
end

def to_record
{ "#{record_namespace}:packageUsps" => packages.map(&:to_record) }
end
end
end
end
3 changes: 2 additions & 1 deletion lib/netsuite/records/sales_order_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class SalesOrderItem
:rev_rec_start_date, :rev_rec_term_in_months, :serial_numbers,
:shipping_cost, :tax1_amt, :tax_rate1, :tax_rate2,
:vsoe_allocation, :vsoe_amount, :vsoe_deferral,
:vsoe_delivered, :vsoe_permit_discount, :vsoe_price
:vsoe_delivered, :vsoe_permit_discount, :vsoe_price,
:ship_group

field :custom_field_list, CustomFieldList

Expand Down
1 change: 1 addition & 0 deletions lib/netsuite/utilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def get_item(ns_item_internal_id, opts = {})
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ServiceResaleItem, ns_item_internal_id, opts)
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::GiftCertificateItem, ns_item_internal_id, opts)
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::KitItem, ns_item_internal_id, opts)
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::ItemGroup, ns_item_internal_id, opts)
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedInventoryItem, ns_item_internal_id, opts)
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::SerializedAssemblyItem, ns_item_internal_id, opts)
ns_item ||= NetSuite::Utilities.get_record(NetSuite::Records::LotNumberedAssemblyItem, ns_item_internal_id, opts)
Expand Down
2 changes: 1 addition & 1 deletion lib/netsuite/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module NetSuite
VERSION = '0.8.12'
VERSION = '0.10.0'
end
2 changes: 1 addition & 1 deletion netsuite.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Gem::Specification.new do |gem|
gem.add_dependency 'savon', '>= 2.3.0'

gem.add_development_dependency 'rspec', '~> 3.11.0'
gem.add_development_dependency 'rake', '~> 12.3.3'
gem.add_development_dependency 'rake', '~> 13.0.6'
end
Loading