netsuite 0.0.12 → 0.0.13
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.
- data/lib/netsuite.rb +2 -0
- data/lib/netsuite/records/custom_field_list.rb +7 -0
- data/lib/netsuite/records/customer.rb +4 -0
- data/lib/netsuite/records/customer_addressbook.rb +47 -0
- data/lib/netsuite/records/customer_addressbook_list.rb +11 -33
- data/lib/netsuite/records/invoice.rb +5 -6
- data/lib/netsuite/records/invoice_item_list.rb +0 -6
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/records/custom_field_list_spec.rb +5 -0
- data/spec/netsuite/records/customer_addressbook_list_spec.rb +4 -81
- data/spec/netsuite/records/customer_addressbook_spec.rb +96 -0
- data/spec/netsuite/records/invoice_item_list_spec.rb +2 -2
- data/spec/netsuite/records/invoice_spec.rb +7 -1
- metadata +9 -3
data/lib/netsuite.rb
CHANGED
@@ -26,7 +26,9 @@ require 'netsuite/actions/initialize'
|
|
26
26
|
|
27
27
|
# RECORDS
|
28
28
|
require 'netsuite/records/bill_address'
|
29
|
+
require 'netsuite/records/custom_field_list'
|
29
30
|
require 'netsuite/records/customer'
|
31
|
+
require 'netsuite/records/customer_addressbook'
|
30
32
|
require 'netsuite/records/customer_addressbook_list'
|
31
33
|
require 'netsuite/records/invoice'
|
32
34
|
require 'netsuite/records/record_ref'
|
@@ -38,6 +38,10 @@ module NetSuite
|
|
38
38
|
attributes[:addressbook_list] = CustomerAddressbookList.new(attrs)
|
39
39
|
end
|
40
40
|
|
41
|
+
def addressbook_list
|
42
|
+
attributes[:addressbook_list] ||= CustomerAddressbookList.new
|
43
|
+
end
|
44
|
+
|
41
45
|
def self.get(id)
|
42
46
|
response = Actions::Get.call(id, self)
|
43
47
|
if response.success?
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class CustomerAddressbook
|
4
|
+
include Support::Fields
|
5
|
+
include Support::Records
|
6
|
+
include Namespaces::ListRel
|
7
|
+
|
8
|
+
fields :default_shipping, :default_billing, :is_residential, :label, :attention, :addressee,
|
9
|
+
:phone, :addr1, :addr2, :addr3, :city, :zip, :country, :addr_text, :override, :state
|
10
|
+
|
11
|
+
attr_reader :internal_id
|
12
|
+
attr_accessor :external_id
|
13
|
+
|
14
|
+
def initialize(attributes_or_record = {})
|
15
|
+
case attributes_or_record
|
16
|
+
when self.class
|
17
|
+
initialize_from_record(attributes_or_record)
|
18
|
+
when Hash
|
19
|
+
attributes_or_record = attributes_or_record[:addressbook] if attributes_or_record[:addressbook]
|
20
|
+
@internal_id = attributes_or_record.delete(:internal_id)
|
21
|
+
initialize_from_attributes_hash(attributes_or_record)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize_from_record(obj)
|
26
|
+
self.default_shipping = obj.default_shipping
|
27
|
+
self.default_billing = obj.default_billing
|
28
|
+
self.is_residential = obj.is_residential
|
29
|
+
self.label = obj.label
|
30
|
+
self.attention = obj.attention
|
31
|
+
self.addressee = obj.addressee
|
32
|
+
self.phone = obj.phone
|
33
|
+
self.addr1 = obj.addr1
|
34
|
+
self.addr2 = obj.addr2
|
35
|
+
self.addr3 = obj.addr3
|
36
|
+
self.city = obj.city
|
37
|
+
self.zip = obj.zip
|
38
|
+
self.country = obj.country
|
39
|
+
self.addr_text = obj.addr_text
|
40
|
+
self.override = obj.override
|
41
|
+
self.state = obj.state
|
42
|
+
@internal_id = obj.internal_id
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -1,45 +1,23 @@
|
|
1
1
|
module NetSuite
|
2
2
|
module Records
|
3
3
|
class CustomerAddressbookList
|
4
|
-
include Support::Fields
|
5
|
-
include Support::Records
|
6
4
|
include Namespaces::ListRel
|
7
5
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
attr_reader :internal_id
|
12
|
-
attr_accessor :external_id
|
13
|
-
|
14
|
-
def initialize(attributes_or_record = {})
|
15
|
-
case attributes_or_record
|
16
|
-
when self.class
|
17
|
-
initialize_from_record(attributes_or_record)
|
6
|
+
def initialize(attributes = {})
|
7
|
+
case attributes[:addressbook]
|
18
8
|
when Hash
|
19
|
-
|
20
|
-
|
21
|
-
|
9
|
+
addressbooks << CustomerAddressbook.new(attributes[:addressbook])
|
10
|
+
when Array
|
11
|
+
attributes[:addressbook].each { |addressbook| addressbooks << CustomerAddressbook.new(addressbook) }
|
22
12
|
end
|
23
13
|
end
|
24
14
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
self.addressee = obj.addressee
|
32
|
-
self.phone = obj.phone
|
33
|
-
self.addr1 = obj.addr1
|
34
|
-
self.addr2 = obj.addr2
|
35
|
-
self.addr3 = obj.addr3
|
36
|
-
self.city = obj.city
|
37
|
-
self.zip = obj.zip
|
38
|
-
self.country = obj.country
|
39
|
-
self.addr_text = obj.addr_text
|
40
|
-
self.override = obj.override
|
41
|
-
self.state = obj.state
|
42
|
-
@internal_id = obj.internal_id
|
15
|
+
def addressbooks
|
16
|
+
@addressbooks ||= []
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_record
|
20
|
+
{ "#{record_namespace}:addressbook" => addressbooks.map(&:to_record) }
|
43
21
|
end
|
44
22
|
|
45
23
|
end
|
@@ -7,7 +7,7 @@ module NetSuite
|
|
7
7
|
include Namespaces::TranSales
|
8
8
|
|
9
9
|
fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :balance, :bill_address,
|
10
|
-
:billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name,
|
10
|
+
:billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name,
|
11
11
|
:deferred_revenue, :department, :discount_amount, :discount_date, :discount_item, :discount_rate,
|
12
12
|
:due_date, :email, :end_date, :est_gross_profit, :est_gross_profit_percent, :exchange_rate,
|
13
13
|
:exclude_commission, :exp_cost_disc_amount, :exp_cost_disc_print, :exp_cost_disc_rate, :exp_cost_disc_tax_1_amt,
|
@@ -52,6 +52,10 @@ module NetSuite
|
|
52
52
|
attributes[:item_list] ||= InvoiceItemList.new
|
53
53
|
end
|
54
54
|
|
55
|
+
def custom_field_list
|
56
|
+
attributes[:custom_field_list] ||= CustomFieldList.new
|
57
|
+
end
|
58
|
+
|
55
59
|
def self.get(id)
|
56
60
|
response = Actions::Get.call(id, self)
|
57
61
|
if response.success?
|
@@ -75,11 +79,6 @@ module NetSuite
|
|
75
79
|
response.success?
|
76
80
|
end
|
77
81
|
|
78
|
-
def to_record
|
79
|
-
attributes.delete(:custom_field_list)
|
80
|
-
super
|
81
|
-
end
|
82
|
-
|
83
82
|
end
|
84
83
|
end
|
85
84
|
end
|
@@ -6,12 +6,6 @@ module NetSuite
|
|
6
6
|
def items
|
7
7
|
@items ||= []
|
8
8
|
end
|
9
|
-
private :items
|
10
|
-
|
11
|
-
def add_item(item, attributes = {})
|
12
|
-
attributes.merge!(:item => item)
|
13
|
-
items << InvoiceItem.new(attributes)
|
14
|
-
end
|
15
9
|
|
16
10
|
def to_record
|
17
11
|
{ "#{record_namespace}:item" => items.map(&:to_record) }
|
data/lib/netsuite/version.rb
CHANGED
@@ -1,96 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe NetSuite::Records::CustomerAddressbookList do
|
4
|
-
let(:
|
5
|
-
{
|
6
|
-
:addressbook => {
|
7
|
-
:addr1 => '123 Happy Lane',
|
8
|
-
:addr_text => "123 Happy Lane\nLos Angeles CA 90007",
|
9
|
-
:city => 'Los Angeles',
|
10
|
-
:country => '_unitedStates',
|
11
|
-
:default_billing => true,
|
12
|
-
:default_shipping => true,
|
13
|
-
:internal_id => '567',
|
14
|
-
:is_residential => false,
|
15
|
-
:label => '123 Happy Lane',
|
16
|
-
:override => false,
|
17
|
-
:state => 'CA',
|
18
|
-
:zip => '90007'
|
19
|
-
}
|
20
|
-
}
|
21
|
-
end
|
22
|
-
let(:list) { NetSuite::Records::CustomerAddressbookList.new(attributes) }
|
4
|
+
let(:list) { NetSuite::Records::CustomerAddressbookList.new }
|
23
5
|
|
24
|
-
it 'has
|
25
|
-
|
26
|
-
:default_shipping, :default_billing, :is_residential, :label, :attention, :addressee,
|
27
|
-
:phone, :addr1, :addr2, :addr3, :city, :zip, :country, :addr_text, :override, :state
|
28
|
-
].each do |field|
|
29
|
-
list.should have_field(field)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe '#initialize' do
|
34
|
-
context 'when taking in a hash of attributes' do
|
35
|
-
it 'sets the attributes for the object given the attributes hash' do
|
36
|
-
list.addr1.should eql('123 Happy Lane')
|
37
|
-
list.addr_text.should eql("123 Happy Lane\nLos Angeles CA 90007")
|
38
|
-
list.city.should eql('Los Angeles')
|
39
|
-
list.country.should eql('_unitedStates')
|
40
|
-
list.default_billing.should be_true
|
41
|
-
list.default_shipping.should be_true
|
42
|
-
list.is_residential.should be_false
|
43
|
-
list.label.should eql('123 Happy Lane')
|
44
|
-
list.override.should be_false
|
45
|
-
list.state.should eql('CA')
|
46
|
-
list.zip.should eql('90007')
|
47
|
-
list.internal_id.should eql('567')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when taking in a CustomerAddressbookList instance' do
|
52
|
-
it 'sets the attributes for the object given the record attributes' do
|
53
|
-
old_list = NetSuite::Records::CustomerAddressbookList.new(attributes)
|
54
|
-
list = NetSuite::Records::CustomerAddressbookList.new(old_list)
|
55
|
-
list.addr1.should eql('123 Happy Lane')
|
56
|
-
list.addr_text.should eql("123 Happy Lane\nLos Angeles CA 90007")
|
57
|
-
list.city.should eql('Los Angeles')
|
58
|
-
list.country.should eql('_unitedStates')
|
59
|
-
list.default_billing.should be_true
|
60
|
-
list.default_shipping.should be_true
|
61
|
-
list.is_residential.should be_false
|
62
|
-
list.label.should eql('123 Happy Lane')
|
63
|
-
list.override.should be_false
|
64
|
-
list.state.should eql('CA')
|
65
|
-
list.zip.should eql('90007')
|
66
|
-
list.internal_id.should eql('567')
|
67
|
-
end
|
68
|
-
end
|
6
|
+
it 'has an addressbooks attribute' do
|
7
|
+
list.addressbooks.should be_kind_of(Array)
|
69
8
|
end
|
70
9
|
|
71
10
|
describe '#to_record' do
|
72
11
|
it 'can represent itself as a SOAP record' do
|
73
12
|
record = {
|
74
|
-
'listRel:
|
75
|
-
'listRel:addrText' => "123 Happy Lane\nLos Angeles CA 90007",
|
76
|
-
'listRel:city' => 'Los Angeles',
|
77
|
-
'listRel:country' => '_unitedStates',
|
78
|
-
'listRel:defaultBilling' => true,
|
79
|
-
'listRel:defaultShipping' => true,
|
80
|
-
'listRel:isResidential' => false,
|
81
|
-
'listRel:label' => '123 Happy Lane',
|
82
|
-
'listRel:override' => false,
|
83
|
-
'listRel:state' => 'CA',
|
84
|
-
'listRel:zip' => '90007'
|
13
|
+
'listRel:addressbook' => []
|
85
14
|
}
|
86
15
|
list.to_record.should eql(record)
|
87
16
|
end
|
88
17
|
end
|
89
18
|
|
90
|
-
describe '#record_type' do
|
91
|
-
it 'returns a string of the record SOAP type' do
|
92
|
-
list.record_type.should eql('listRel:CustomerAddressbookList')
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
19
|
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::CustomerAddressbook do
|
4
|
+
let(:attributes) do
|
5
|
+
{
|
6
|
+
:addressbook => {
|
7
|
+
:addr1 => '123 Happy Lane',
|
8
|
+
:addr_text => "123 Happy Lane\nLos Angeles CA 90007",
|
9
|
+
:city => 'Los Angeles',
|
10
|
+
:country => '_unitedStates',
|
11
|
+
:default_billing => true,
|
12
|
+
:default_shipping => true,
|
13
|
+
:internal_id => '567',
|
14
|
+
:is_residential => false,
|
15
|
+
:label => '123 Happy Lane',
|
16
|
+
:override => false,
|
17
|
+
:state => 'CA',
|
18
|
+
:zip => '90007'
|
19
|
+
}
|
20
|
+
}
|
21
|
+
end
|
22
|
+
let(:list) { NetSuite::Records::CustomerAddressbook.new(attributes) }
|
23
|
+
|
24
|
+
it 'has all the right fields' do
|
25
|
+
[
|
26
|
+
:default_shipping, :default_billing, :is_residential, :label, :attention, :addressee,
|
27
|
+
:phone, :addr1, :addr2, :addr3, :city, :zip, :country, :addr_text, :override, :state
|
28
|
+
].each do |field|
|
29
|
+
list.should have_field(field)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#initialize' do
|
34
|
+
context 'when taking in a hash of attributes' do
|
35
|
+
it 'sets the attributes for the object given the attributes hash' do
|
36
|
+
list.addr1.should eql('123 Happy Lane')
|
37
|
+
list.addr_text.should eql("123 Happy Lane\nLos Angeles CA 90007")
|
38
|
+
list.city.should eql('Los Angeles')
|
39
|
+
list.country.should eql('_unitedStates')
|
40
|
+
list.default_billing.should be_true
|
41
|
+
list.default_shipping.should be_true
|
42
|
+
list.is_residential.should be_false
|
43
|
+
list.label.should eql('123 Happy Lane')
|
44
|
+
list.override.should be_false
|
45
|
+
list.state.should eql('CA')
|
46
|
+
list.zip.should eql('90007')
|
47
|
+
list.internal_id.should eql('567')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'when taking in a CustomerAddressbookList instance' do
|
52
|
+
it 'sets the attributes for the object given the record attributes' do
|
53
|
+
old_list = NetSuite::Records::CustomerAddressbook.new(attributes)
|
54
|
+
list = NetSuite::Records::CustomerAddressbook.new(old_list)
|
55
|
+
list.addr1.should eql('123 Happy Lane')
|
56
|
+
list.addr_text.should eql("123 Happy Lane\nLos Angeles CA 90007")
|
57
|
+
list.city.should eql('Los Angeles')
|
58
|
+
list.country.should eql('_unitedStates')
|
59
|
+
list.default_billing.should be_true
|
60
|
+
list.default_shipping.should be_true
|
61
|
+
list.is_residential.should be_false
|
62
|
+
list.label.should eql('123 Happy Lane')
|
63
|
+
list.override.should be_false
|
64
|
+
list.state.should eql('CA')
|
65
|
+
list.zip.should eql('90007')
|
66
|
+
list.internal_id.should eql('567')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#to_record' do
|
72
|
+
it 'can represent itself as a SOAP record' do
|
73
|
+
record = {
|
74
|
+
'listRel:addr1' => '123 Happy Lane',
|
75
|
+
'listRel:addrText' => "123 Happy Lane\nLos Angeles CA 90007",
|
76
|
+
'listRel:city' => 'Los Angeles',
|
77
|
+
'listRel:country' => '_unitedStates',
|
78
|
+
'listRel:defaultBilling' => true,
|
79
|
+
'listRel:defaultShipping' => true,
|
80
|
+
'listRel:isResidential' => false,
|
81
|
+
'listRel:label' => '123 Happy Lane',
|
82
|
+
'listRel:override' => false,
|
83
|
+
'listRel:state' => 'CA',
|
84
|
+
'listRel:zip' => '90007'
|
85
|
+
}
|
86
|
+
list.to_record.should eql(record)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#record_type' do
|
91
|
+
it 'returns a string of the record SOAP type' do
|
92
|
+
list.record_type.should eql('listRel:CustomerAddressbook')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -5,8 +5,8 @@ describe NetSuite::Records::InvoiceItemList do
|
|
5
5
|
let(:item) { NetSuite::Records::InvoiceItem.new }
|
6
6
|
|
7
7
|
it 'can have items be added to it' do
|
8
|
-
list.
|
9
|
-
item_list = list.
|
8
|
+
list.items << item
|
9
|
+
item_list = list.items
|
10
10
|
item_list.should be_kind_of(Array)
|
11
11
|
item_list.length.should eql(1)
|
12
12
|
item_list.each { |i| i.should be_kind_of(NetSuite::Records::InvoiceItem) }
|
@@ -8,7 +8,7 @@ describe NetSuite::Records::Invoice do
|
|
8
8
|
it 'has all the right fields' do
|
9
9
|
[
|
10
10
|
:alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :balance, :bill_address,
|
11
|
-
:billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name,
|
11
|
+
:billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name,
|
12
12
|
:deferred_revenue, :department, :discount_amount, :discount_date, :discount_item, :discount_rate,
|
13
13
|
:due_date, :email, :end_date, :est_gross_profit, :est_gross_profit_percent, :exchange_rate,
|
14
14
|
:exclude_commission, :exp_cost_disc_amount, :exp_cost_disc_print, :exp_cost_disc_rate, :exp_cost_disc_tax_1_amt,
|
@@ -48,6 +48,12 @@ describe NetSuite::Records::Invoice do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
+
describe '#custom_field_list' do
|
52
|
+
it 'returns a CustomFieldList object that contains many CustomFields' do
|
53
|
+
invoice.custom_field_list.should be_kind_of(NetSuite::Records::CustomFieldList)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
51
57
|
describe 'item_list' do
|
52
58
|
context 'when the attributes constitute an Array of items' do
|
53
59
|
it 'builds an InvoiceItemList for each list item_list field' do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netsuite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Moran
|
@@ -112,7 +112,9 @@ files:
|
|
112
112
|
- lib/netsuite/namespaces/tran_sales.rb
|
113
113
|
- lib/netsuite/records/bill_address.rb
|
114
114
|
- lib/netsuite/records/classification.rb
|
115
|
+
- lib/netsuite/records/custom_field_list.rb
|
115
116
|
- lib/netsuite/records/customer.rb
|
117
|
+
- lib/netsuite/records/customer_addressbook.rb
|
116
118
|
- lib/netsuite/records/customer_addressbook_list.rb
|
117
119
|
- lib/netsuite/records/invoice.rb
|
118
120
|
- lib/netsuite/records/invoice_item.rb
|
@@ -134,7 +136,9 @@ files:
|
|
134
136
|
- spec/netsuite/configuration_spec.rb
|
135
137
|
- spec/netsuite/records/bill_address_spec.rb
|
136
138
|
- spec/netsuite/records/classification_spec.rb
|
139
|
+
- spec/netsuite/records/custom_field_list_spec.rb
|
137
140
|
- spec/netsuite/records/customer_addressbook_list_spec.rb
|
141
|
+
- spec/netsuite/records/customer_addressbook_spec.rb
|
138
142
|
- spec/netsuite/records/customer_spec.rb
|
139
143
|
- spec/netsuite/records/invoice_item_list_spec.rb
|
140
144
|
- spec/netsuite/records/invoice_item_spec.rb
|
@@ -201,7 +205,9 @@ test_files:
|
|
201
205
|
- spec/netsuite/configuration_spec.rb
|
202
206
|
- spec/netsuite/records/bill_address_spec.rb
|
203
207
|
- spec/netsuite/records/classification_spec.rb
|
208
|
+
- spec/netsuite/records/custom_field_list_spec.rb
|
204
209
|
- spec/netsuite/records/customer_addressbook_list_spec.rb
|
210
|
+
- spec/netsuite/records/customer_addressbook_spec.rb
|
205
211
|
- spec/netsuite/records/customer_spec.rb
|
206
212
|
- spec/netsuite/records/invoice_item_list_spec.rb
|
207
213
|
- spec/netsuite/records/invoice_item_spec.rb
|