netsuite 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/lib/netsuite.rb +6 -2
- data/lib/netsuite/configuration.rb +2 -8
- data/lib/netsuite/records/base_ref_list.rb +3 -19
- data/lib/netsuite/records/billing_schedule_milestone_list.rb +4 -23
- data/lib/netsuite/records/billing_schedule_recurrence_list.rb +4 -23
- data/lib/netsuite/records/bin_number_list.rb +5 -23
- data/lib/netsuite/records/cash_refund_item_list.rb +3 -23
- data/lib/netsuite/records/cash_sale_item_list.rb +3 -15
- data/lib/netsuite/records/customer_payment_apply_list.rb +3 -22
- data/lib/netsuite/records/customer_refund_apply_list.rb +3 -20
- data/lib/netsuite/records/deposit_payment_list.rb +3 -4
- data/lib/netsuite/records/gift_certificate_item.rb +84 -0
- data/lib/netsuite/records/inventory_transfer_inventory_list.rb +2 -23
- data/lib/netsuite/records/item_fulfillment_package_list.rb +3 -19
- data/lib/netsuite/records/journal_entry_line_list.rb +3 -23
- data/lib/netsuite/records/member_list.rb +3 -22
- data/lib/netsuite/records/other_charge_sale_item.rb +73 -0
- data/lib/netsuite/records/record_ref_list.rb +2 -20
- data/lib/netsuite/records/units_type_uom_list.rb +2 -23
- data/lib/netsuite/records/vendor.rb +4 -1
- data/lib/netsuite/records/vendor_bill_item_list.rb +3 -23
- data/lib/netsuite/records/vendor_payment_apply_list.rb +3 -23
- data/lib/netsuite/records/work_order_item_list.rb +3 -23
- data/lib/netsuite/rest/utilities/request.rb +53 -0
- data/lib/netsuite/rest/utilities/roles.rb +45 -0
- data/lib/netsuite/utilities.rb +20 -0
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/actions/search_spec.rb +1 -1
- data/spec/netsuite/configuration_spec.rb +3 -3
- data/spec/netsuite/records/basic_record_spec.rb +2 -0
- data/spec/netsuite/records/custom_record_spec.rb +1 -1
- data/spec/netsuite/records/invoice_item_spec.rb +1 -1
- data/spec/netsuite/records/journal_entry_spec.rb +1 -1
- data/spec/netsuite/records/vendor_bill_expense_spec.rb +1 -1
- data/spec/netsuite/records/vendor_bill_item_spec.rb +2 -2
- data/spec/netsuite/utilities/request_spec.rb +29 -0
- data/spec/netsuite/utilities/roles_spec.rb +98 -0
- data/{wsdl/2011_2.wsdl → spec/support/2015.wsdl} +190 -56
- data/spec/support/configuration.rb +1 -0
- metadata +12 -4
- data/wsdl/2012_1.wsdl +0 -2283
@@ -1,33 +1,12 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class InventoryTransferInventoryList
|
3
|
+
class InventoryTransferInventoryList < Support::Sublist
|
4
4
|
include Support::RecordRefs
|
5
5
|
include Support::Records
|
6
|
-
include Support::Fields
|
7
6
|
include Namespaces::TranInvt
|
8
7
|
|
9
|
-
|
8
|
+
sublist :inventory, InventoryTransferInventory
|
10
9
|
|
11
|
-
def initialize(attributes = {})
|
12
|
-
initialize_from_attributes_hash(attributes)
|
13
|
-
end
|
14
|
-
|
15
|
-
def inventory=(items)
|
16
|
-
case items
|
17
|
-
when Hash
|
18
|
-
self.inventory << InventoryTransferInventory.new(items)
|
19
|
-
when Array
|
20
|
-
items.each { |item| self.inventory << InventoryTransferInventory.new(item) }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def inventory
|
25
|
-
@inventory ||= []
|
26
|
-
end
|
27
|
-
|
28
|
-
def to_record
|
29
|
-
{ "#{record_namespace}:inventory" => inventory.map(&:to_record) }
|
30
|
-
end
|
31
10
|
end
|
32
11
|
end
|
33
12
|
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class ItemFulfillmentPackageList
|
4
|
-
include Support::Fields
|
5
|
-
include Support::Records
|
3
|
+
class ItemFulfillmentPackageList < Support::Sublist
|
6
4
|
include Namespaces::TranSales
|
7
5
|
|
8
|
-
|
6
|
+
sublist :package, ItemFulfillmentPackage
|
9
7
|
|
10
8
|
def initialize(attributes = {})
|
11
9
|
if attributes.keys != [:package] && attributes.first
|
@@ -32,22 +30,8 @@ module NetSuite
|
|
32
30
|
initialize_from_attributes_hash(attributes)
|
33
31
|
end
|
34
32
|
|
35
|
-
|
36
|
-
case packages
|
37
|
-
when Hash
|
38
|
-
self.packages << ItemFulfillmentPackage.new(packages)
|
39
|
-
when Array
|
40
|
-
packages.each { |package| self.packages << ItemFulfillmentPackage.new(package) }
|
41
|
-
end
|
42
|
-
end
|
33
|
+
alias :packages :package
|
43
34
|
|
44
|
-
def packages
|
45
|
-
@packages ||= []
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_record
|
49
|
-
{ "#{record_namespace}:package" => packages.map(&:to_record) }
|
50
|
-
end
|
51
35
|
end
|
52
36
|
end
|
53
37
|
end
|
@@ -1,31 +1,11 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class JournalEntryLineList
|
4
|
-
include Support::Fields
|
3
|
+
class JournalEntryLineList < Support::Sublist
|
5
4
|
include Namespaces::TranGeneral
|
6
|
-
|
7
|
-
fields :line
|
8
5
|
|
9
|
-
|
10
|
-
initialize_from_attributes_hash(attributes)
|
11
|
-
end
|
6
|
+
sublist :line, JournalEntryLine
|
12
7
|
|
13
|
-
|
14
|
-
case lines
|
15
|
-
when Hash
|
16
|
-
self.lines << JournalEntryLine.new(lines)
|
17
|
-
when Array
|
18
|
-
lines.each { |line| self.lines << JournalEntryLine.new(line) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def lines
|
23
|
-
@items ||= []
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_record
|
27
|
-
{ "#{record_namespace}:line" => lines.map(&:to_record) }
|
28
|
-
end
|
8
|
+
alias :lines :line
|
29
9
|
|
30
10
|
end
|
31
11
|
end
|
@@ -1,32 +1,13 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class MemberList
|
4
|
-
include Support::Fields
|
3
|
+
class MemberList < Support::Sublist
|
5
4
|
include Support::Records
|
6
5
|
include Namespaces::ListAcct
|
7
6
|
|
8
|
-
fields :replace_all
|
7
|
+
fields :replace_all
|
9
8
|
|
10
|
-
|
11
|
-
initialize_from_attributes_hash(attrs)
|
12
|
-
end
|
9
|
+
sublist :item_member, ItemMember
|
13
10
|
|
14
|
-
def item_member=(items)
|
15
|
-
case items
|
16
|
-
when Hash
|
17
|
-
self.item_member << ItemMember.new(items)
|
18
|
-
when Array
|
19
|
-
items.each { |ref| self.item_member << ItemMember.new(ref) }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def item_member
|
24
|
-
@item_member ||= []
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_record
|
28
|
-
{ "#{record_namespace}:itemMember" => item_member.map(&:to_record) }
|
29
|
-
end
|
30
11
|
end
|
31
12
|
end
|
32
13
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class OtherChargeSaleItem
|
4
|
+
include Support::Fields
|
5
|
+
include Support::RecordRefs
|
6
|
+
include Support::Records
|
7
|
+
include Support::Actions
|
8
|
+
include Namespaces::ListAcct
|
9
|
+
|
10
|
+
actions :get, :get_list, :add, :update, :delete, :upsert, :search
|
11
|
+
|
12
|
+
attr_reader :internal_id
|
13
|
+
attr_accessor :external_id
|
14
|
+
|
15
|
+
fields :accounting_book_detail_list,
|
16
|
+
:available_to_partners,
|
17
|
+
:cost_estimate,
|
18
|
+
:cost_estimate_type,
|
19
|
+
:cost_estimate_units,
|
20
|
+
:created_date,
|
21
|
+
:display_name,
|
22
|
+
:enforce_min_qty_internally,
|
23
|
+
:include_children,
|
24
|
+
:is_fulfillable,
|
25
|
+
:is_gco_compliant,
|
26
|
+
:is_inactive,
|
27
|
+
:is_online,
|
28
|
+
:is_taxable,
|
29
|
+
:item_id,
|
30
|
+
:last_modified_date,
|
31
|
+
:minimum_quantity,
|
32
|
+
:minimum_quantity_units,
|
33
|
+
:offer_support,
|
34
|
+
:overall_quantity_pricing_type,
|
35
|
+
:prices_include_tax,
|
36
|
+
:pricing_group,
|
37
|
+
:purchase_tax_code,
|
38
|
+
:quantity_pricing_schedule,
|
39
|
+
:rate,
|
40
|
+
:sales_description,
|
41
|
+
:soft_descriptor,
|
42
|
+
:upc_code,
|
43
|
+
:use_marginal_rates,
|
44
|
+
:vsoe_deferral,
|
45
|
+
:vsoe_delivered,
|
46
|
+
:vsoe_permit_discount,
|
47
|
+
:vsoe_price,
|
48
|
+
:vsoe_sop_group
|
49
|
+
|
50
|
+
record_refs :billing_schedule, :klass, :cost_category, :custom_form, :deferred_revenue_account,
|
51
|
+
:department, :income_account, :issue_product, :location, :matrix_type, :rev_rec_schedule,
|
52
|
+
:units_type, :sales_tax_code, :sale_unit, :tax_schedule, :parent
|
53
|
+
|
54
|
+
field :custom_field_list, CustomFieldList
|
55
|
+
# :pricing_matrix,
|
56
|
+
# :translations_list,
|
57
|
+
# :matrix_option_list,
|
58
|
+
# :item_options_list
|
59
|
+
# :subsidiary_list,
|
60
|
+
|
61
|
+
def initialize(attributes = {})
|
62
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
63
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
64
|
+
initialize_from_attributes_hash(attributes)
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.search_class_name
|
68
|
+
"Item"
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -1,28 +1,10 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class RecordRefList
|
4
|
-
include Support::Fields
|
3
|
+
class RecordRefList < Support::Sublist
|
5
4
|
include Support::Records
|
6
5
|
include Namespaces::PlatformCore
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
def initialize(attrs = {})
|
11
|
-
initialize_from_attributes_hash(attrs)
|
12
|
-
end
|
13
|
-
|
14
|
-
def record_ref=(items)
|
15
|
-
case items
|
16
|
-
when Hash
|
17
|
-
self.record_ref << RecordRef.new(items)
|
18
|
-
when Array
|
19
|
-
items.each { |ref| self.record_ref << RecordRef.new(ref) }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def record_ref
|
24
|
-
@record_ref ||= []
|
25
|
-
end
|
7
|
+
sublist :record_ref, RecordRef
|
26
8
|
|
27
9
|
def to_record
|
28
10
|
{
|
@@ -1,31 +1,10 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class UnitsTypeUomList
|
4
|
-
include Support::Fields
|
3
|
+
class UnitsTypeUomList < Support::Sublist
|
5
4
|
include Namespaces::ListAcct
|
6
5
|
|
7
|
-
|
6
|
+
sublist :uom, UnitsTypeUom
|
8
7
|
|
9
|
-
def initialize(attributes = {})
|
10
|
-
initialize_from_attributes_hash(attributes)
|
11
|
-
end
|
12
|
-
|
13
|
-
def uom=(items)
|
14
|
-
case items
|
15
|
-
when Hash
|
16
|
-
self.uom << UnitsTypeUom.new(items)
|
17
|
-
when Array
|
18
|
-
items.each { |item| self.uom << UnitsTypeUom.new(item) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def uom
|
23
|
-
@uom ||= []
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_record
|
27
|
-
{ "#{record_namespace}:uom" => uom.map(&:to_record) }
|
28
|
-
end
|
29
8
|
end
|
30
9
|
end
|
31
10
|
end
|
@@ -7,7 +7,7 @@ module NetSuite
|
|
7
7
|
include Support::Actions
|
8
8
|
include Namespaces::ListRel
|
9
9
|
|
10
|
-
actions :get, :get_list, :add, :update, :delete, :search
|
10
|
+
actions :get, :get_list, :add, :update, :upsert, :delete, :search
|
11
11
|
|
12
12
|
fields :account_number, :alt_email, :alt_name, :alt_phone, :balance,
|
13
13
|
:balance_primary, :bcn, :bill_pay, :comments, :company_name, :credit_limit,
|
@@ -25,6 +25,9 @@ module NetSuite
|
|
25
25
|
# TODO should change name to VendorAddressBookList
|
26
26
|
field :addressbook_list, CustomerAddressbookList
|
27
27
|
|
28
|
+
read_only_fields :balance_primary, :balance, :last_modified_date, :unbilled_orders,
|
29
|
+
:unbilled_orders_primary
|
30
|
+
|
28
31
|
record_refs :custom_form, :category, :image, :subsidiary, :representing_subsidiary,
|
29
32
|
:expense_account, :payables_account, :terms, :opening_balance_account, :currency, :work_calendar,
|
30
33
|
:tax_item
|
@@ -1,31 +1,11 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class VendorBillItemList
|
4
|
-
include Support::Fields
|
3
|
+
class VendorBillItemList < Support::Sublist
|
5
4
|
include Namespaces::TranPurch
|
6
5
|
|
7
|
-
|
6
|
+
sublist :item, VendorBillItem
|
8
7
|
|
9
|
-
|
10
|
-
initialize_from_attributes_hash(attributes)
|
11
|
-
end
|
12
|
-
|
13
|
-
def item=(items)
|
14
|
-
case items
|
15
|
-
when Hash
|
16
|
-
self.items << VendorBillItem.new(items)
|
17
|
-
when Array
|
18
|
-
items.each { |item| self.items << VendorBillItem.new(item) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def items
|
23
|
-
@items ||= []
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_record
|
27
|
-
{ "#{record_namespace}:item" => items.map(&:to_record) }
|
28
|
-
end
|
8
|
+
alias :items :item
|
29
9
|
|
30
10
|
end
|
31
11
|
end
|
@@ -1,31 +1,11 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class VendorPaymentApplyList
|
4
|
-
include Support::Fields
|
3
|
+
class VendorPaymentApplyList < Support::Sublist
|
5
4
|
include Namespaces::TranPurch
|
6
5
|
|
7
|
-
|
6
|
+
sublist :apply, VendorPaymentApply
|
8
7
|
|
9
|
-
|
10
|
-
initialize_from_attributes_hash(attributes)
|
11
|
-
end
|
12
|
-
|
13
|
-
def apply=(applies)
|
14
|
-
case applies
|
15
|
-
when Hash
|
16
|
-
@applies = [VendorPaymentApply.new(applies)]
|
17
|
-
when Array
|
18
|
-
@applies = applies.map { |apply| VendorPaymentApply.new(apply) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def applies
|
23
|
-
@applies ||= []
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_record
|
27
|
-
{ "#{record_namespace}:apply" => applies.map(&:to_record) }
|
28
|
-
end
|
8
|
+
alias :applies :apply
|
29
9
|
|
30
10
|
end
|
31
11
|
end
|
@@ -1,31 +1,11 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
|
-
class WorkOrderItemList
|
4
|
-
include Support::Fields
|
3
|
+
class WorkOrderItemList < Support::Sublist
|
5
4
|
include Namespaces::TranInvt
|
6
5
|
|
7
|
-
|
6
|
+
sublist :item, WorkOrderItem
|
8
7
|
|
9
|
-
|
10
|
-
initialize_from_attributes_hash(attributes)
|
11
|
-
end
|
12
|
-
|
13
|
-
def item=(items)
|
14
|
-
case items
|
15
|
-
when Hash
|
16
|
-
self.items << WorkOrderItem.new(items)
|
17
|
-
when Array
|
18
|
-
items.each { |item| self.items << WorkOrderItem.new(item) }
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def items
|
23
|
-
@items ||= []
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_record
|
27
|
-
{ "#{record_namespace}:item" => items.map(&:to_record) }
|
28
|
-
end
|
8
|
+
alias :items :item
|
29
9
|
end
|
30
10
|
end
|
31
11
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module NetSuite
|
6
|
+
module Rest
|
7
|
+
module Utilities
|
8
|
+
class Request
|
9
|
+
|
10
|
+
BASE_API = "https://rest.netsuite.com/rest"
|
11
|
+
DEFAULT_TIMEOUT = 30
|
12
|
+
USE_SSL = true
|
13
|
+
|
14
|
+
class << self
|
15
|
+
|
16
|
+
def get(options)
|
17
|
+
email = encode(options.fetch :email)
|
18
|
+
signature = encode(options.fetch :password)
|
19
|
+
uri = options.fetch(:uri)
|
20
|
+
response = make_request(:get, uri, email, signature)
|
21
|
+
[response.code, JSON.parse(response.body)]
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def make_request(method_name, uri, email, signature)
|
27
|
+
uri = URI(BASE_API + uri)
|
28
|
+
klass = Module.const_get "Net::HTTP::#{method_name.to_s.capitalize}"
|
29
|
+
method = klass.new(uri)
|
30
|
+
method['AUTHORIZATION'] = auth_header(email, signature)
|
31
|
+
|
32
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
33
|
+
http.use_ssl = USE_SSL
|
34
|
+
http.read_timeout = DEFAULT_TIMEOUT
|
35
|
+
http.start {|http| http.request(method)}
|
36
|
+
end
|
37
|
+
|
38
|
+
def auth_header(email, signature)
|
39
|
+
"NLAuth nlauth_email=#{email},nlauth_signature=#{signature}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def encode(unencoded_string)
|
43
|
+
URI.escape(
|
44
|
+
unencoded_string,
|
45
|
+
/[#{URI::PATTERN::RESERVED}]/
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|