netsuite 0.6.9 → 0.7.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.
- data/lib/netsuite.rb +7 -0
- data/lib/netsuite/configuration.rb +1 -0
- data/lib/netsuite/namespaces/comm_general.rb +11 -0
- data/lib/netsuite/records/assembly_item.rb +1 -0
- data/lib/netsuite/records/description_item.rb +34 -0
- data/lib/netsuite/records/gift_cert_redemption.rb +0 -3
- data/lib/netsuite/records/inventory_item.rb +2 -1
- data/lib/netsuite/records/invoice.rb +3 -0
- data/lib/netsuite/records/item_vendor.rb +15 -0
- data/lib/netsuite/records/item_vendor_list.rb +11 -0
- data/lib/netsuite/records/note.rb +33 -0
- data/lib/netsuite/records/note_type.rb +27 -0
- data/lib/netsuite/records/subtotal_item.rb +35 -0
- data/lib/netsuite/records/term.rb +1 -0
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/records/assembly_item_spec.rb +26 -0
- data/spec/netsuite/records/basic_record_spec.rb +5 -1
- data/spec/netsuite/records/inventory_item_spec.rb +40 -3
- data/spec/netsuite/records/invoice_spec.rb +101 -0
- data/spec/netsuite/records/item_vendor_list_spec.rb +30 -0
- data/spec/netsuite/records/item_vendor_spec.rb +15 -0
- data/spec/netsuite/records/note_spec.rb +134 -0
- data/spec/netsuite/records/note_type_spec.rb +88 -0
- metadata +17 -2
data/lib/netsuite.rb
CHANGED
@@ -23,6 +23,7 @@ module NetSuite
|
|
23
23
|
autoload :TranCust, 'netsuite/namespaces/tran_cust'
|
24
24
|
autoload :TranEmp, 'netsuite/namespaces/tran_emp'
|
25
25
|
autoload :TranGeneral, 'netsuite/namespaces/tran_general'
|
26
|
+
autoload :CommGeneral, 'netsuite/namespaces/comm_general'
|
26
27
|
autoload :TranInvt, 'netsuite/namespaces/tran_invt'
|
27
28
|
autoload :TranSales, 'netsuite/namespaces/tran_sales'
|
28
29
|
autoload :TranPurch, 'netsuite/namespaces/tran_purch'
|
@@ -125,6 +126,7 @@ module NetSuite
|
|
125
126
|
autoload :DepositOtherList, 'netsuite/records/deposit_other_list'
|
126
127
|
autoload :DepositCashBack, 'netsuite/records/deposit_cash_back'
|
127
128
|
autoload :DepositCashBackList, 'netsuite/records/deposit_cash_back_list'
|
129
|
+
autoload :DescriptionItem, 'netsuite/records/description_item'
|
128
130
|
autoload :DiscountItem, 'netsuite/records/discount_item'
|
129
131
|
autoload :Duration, 'netsuite/records/duration'
|
130
132
|
autoload :Employee, 'netsuite/records/employee'
|
@@ -154,6 +156,8 @@ module NetSuite
|
|
154
156
|
autoload :ItemReceipt, 'netsuite/records/item_receipt'
|
155
157
|
autoload :ItemReceiptItemList, 'netsuite/records/item_receipt_item_list'
|
156
158
|
autoload :ItemReceiptItem, 'netsuite/records/item_receipt_item'
|
159
|
+
autoload :ItemVendor, 'netsuite/records/item_vendor'
|
160
|
+
autoload :ItemVendorList, 'netsuite/records/item_vendor_list'
|
157
161
|
autoload :Job, 'netsuite/records/job'
|
158
162
|
autoload :JobStatus, 'netsuite/records/job_status'
|
159
163
|
autoload :JournalEntry, 'netsuite/records/journal_entry'
|
@@ -167,6 +171,8 @@ module NetSuite
|
|
167
171
|
autoload :NonInventorySaleItem, 'netsuite/records/non_inventory_sale_item'
|
168
172
|
autoload :NonInventoryPurchaseItem, 'netsuite/records/non_inventory_purchase_item'
|
169
173
|
autoload :NonInventoryResaleItem, 'netsuite/records/non_inventory_resale_item'
|
174
|
+
autoload :Note, 'netsuite/records/note'
|
175
|
+
autoload :NoteType, 'netsuite/records/note_type'
|
170
176
|
autoload :Opportunity, 'netsuite/records/opportunity'
|
171
177
|
autoload :OpportunityItem, 'netsuite/records/opportunity_item'
|
172
178
|
autoload :OpportunityItemList, 'netsuite/records/opportunity_item_list'
|
@@ -195,6 +201,7 @@ module NetSuite
|
|
195
201
|
autoload :ShipAddress, 'netsuite/records/ship_address'
|
196
202
|
autoload :SiteCategory, 'netsuite/records/site_category'
|
197
203
|
autoload :Subsidiary, 'netsuite/records/subsidiary'
|
204
|
+
autoload :SubtotalItem, 'netsuite/records/subtotal_item'
|
198
205
|
autoload :SupportCase, 'netsuite/records/support_case'
|
199
206
|
autoload :TaxType, 'netsuite/records/tax_type'
|
200
207
|
autoload :TaxGroup, 'netsuite/records/tax_group'
|
@@ -166,6 +166,7 @@ module NetSuite
|
|
166
166
|
'xmlns:tranInvt' => "urn:inventory_#{api_version}.transactions.webservices.netsuite.com",
|
167
167
|
'xmlns:listSupport' => "urn:support_#{api_version}.lists.webservices.netsuite.com",
|
168
168
|
'xmlns:tranGeneral' => "urn:general_#{api_version}.transactions.webservices.netsuite.com",
|
169
|
+
'xmlns:commGeneral' => "urn:communication_#{api_version}.general.webservices.netsuite.com",
|
169
170
|
'xmlns:listMkt' => "urn:marketing_#{api_version}.lists.webservices.netsuite.com",
|
170
171
|
'xmlns:listWebsite' => "urn:website_#{api_version}.lists.webservices.netsuite.com",
|
171
172
|
'xmlns:fileCabinet' => "urn:filecabinet_#{api_version}.documents.webservices.netsuite.com",
|
@@ -43,6 +43,7 @@ module NetSuite
|
|
43
43
|
field :custom_field_list, CustomFieldList
|
44
44
|
field :bin_number_list, BinNumberList
|
45
45
|
field :locations_list, LocationsList
|
46
|
+
field :item_vendor_list, ItemVendorList
|
46
47
|
field :pricing_matrix, PricingMatrix
|
47
48
|
field :member_list, MemberList
|
48
49
|
field :subsidiary_list, RecordRefList
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class SubtotalItem
|
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, :delete, :search, :update, :upsert
|
11
|
+
|
12
|
+
fields :available_to_partners, :created_date, :description, :display_name, :include_children, :is_inactive, :item_id, :last_modified_date
|
13
|
+
|
14
|
+
record_refs :custom_form, :department, :issue_product, :klass, :location
|
15
|
+
|
16
|
+
field :custom_field_list, CustomFieldList
|
17
|
+
field :subsidiary_list, RecordRefList
|
18
|
+
# TODO field :translations_list, TranslationList
|
19
|
+
|
20
|
+
attr_reader :internal_id
|
21
|
+
attr_accessor :external_id
|
22
|
+
|
23
|
+
def initialize(attributes = {})
|
24
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
25
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
26
|
+
initialize_from_attributes_hash(attributes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.search_class_name
|
30
|
+
"Item"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -13,10 +13,7 @@ module NetSuite
|
|
13
13
|
|
14
14
|
record_refs :auth_code
|
15
15
|
|
16
|
-
attr_reader :internal_id
|
17
|
-
|
18
16
|
def initialize(attributes = {})
|
19
|
-
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
20
17
|
initialize_from_attributes_hash(attributes)
|
21
18
|
end
|
22
19
|
|
@@ -57,12 +57,13 @@ module NetSuite
|
|
57
57
|
field :custom_field_list, CustomFieldList
|
58
58
|
field :bin_number_list, BinNumberList
|
59
59
|
field :locations_list, LocationsList
|
60
|
+
field :item_vendor_list, ItemVendorList
|
60
61
|
field :matrix_option_list, MatrixOptionList
|
61
62
|
field :subsidiary_list, RecordRefList
|
62
63
|
|
63
64
|
# for Assembly/Kit
|
64
65
|
field :member_list, MemberList
|
65
|
-
|
66
|
+
|
66
67
|
attr_reader :internal_id
|
67
68
|
attr_accessor :external_id
|
68
69
|
|
@@ -36,6 +36,8 @@ module NetSuite
|
|
36
36
|
field :transaction_ship_address, ShipAddress
|
37
37
|
field :item_list, InvoiceItemList
|
38
38
|
field :custom_field_list, CustomFieldList
|
39
|
+
field :shipping_address, Address
|
40
|
+
field :billing_address, Address
|
39
41
|
|
40
42
|
read_only_fields :sub_total, :discount_total, :total, :recognized_revenue, :amount_remaining, :amount_paid,
|
41
43
|
:alt_shipping_cost, :gift_cert_applied, :handling_cost, :alt_handling_cost
|
@@ -46,6 +48,7 @@ module NetSuite
|
|
46
48
|
|
47
49
|
attr_reader :internal_id
|
48
50
|
attr_accessor :external_id
|
51
|
+
attr_accessor :search_joins
|
49
52
|
|
50
53
|
def initialize(attributes = {})
|
51
54
|
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class ItemVendor
|
4
|
+
include Support::Fields
|
5
|
+
include Support::Records
|
6
|
+
include Namespaces::ListAcct
|
7
|
+
|
8
|
+
fields :vendor, :purchase_price, :preferred_vendor
|
9
|
+
|
10
|
+
def initialize(attributes = {})
|
11
|
+
initialize_from_attributes_hash(attributes)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class Note
|
4
|
+
include Support::Records
|
5
|
+
include Support::Fields
|
6
|
+
|
7
|
+
include Support::Actions
|
8
|
+
include Support::RecordRefs
|
9
|
+
include Namespaces::CommGeneral
|
10
|
+
|
11
|
+
# https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/schema/record/note.html
|
12
|
+
|
13
|
+
actions :get, :get_list, :add, :update, :upsert, :upsert_list, :delete, :delete_list, :search
|
14
|
+
|
15
|
+
fields :direction, :lastModifiedDate, :note, :noteDate, :title, :topic
|
16
|
+
|
17
|
+
record_refs :noteType, :activity, :author, :customForm, :entity, :folder, :item, :media, :record, :recordType, :transaction
|
18
|
+
|
19
|
+
field :custom_field_list, CustomFieldList
|
20
|
+
|
21
|
+
attr_reader :internal_id
|
22
|
+
attr_accessor :external_id
|
23
|
+
|
24
|
+
def initialize(attributes = {})
|
25
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
26
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
27
|
+
|
28
|
+
initialize_from_attributes_hash(attributes)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class NoteType
|
4
|
+
include Support::Records
|
5
|
+
include Support::Fields
|
6
|
+
include Support::Actions
|
7
|
+
include Namespaces::ListAcct
|
8
|
+
|
9
|
+
# https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2016_1/schema/record/notetype.html
|
10
|
+
|
11
|
+
actions :get, :search
|
12
|
+
|
13
|
+
fields :name, :description, :is_inactive
|
14
|
+
|
15
|
+
attr_reader :internal_id
|
16
|
+
attr_accessor :external_id
|
17
|
+
|
18
|
+
def initialize(attributes = {})
|
19
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
20
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
21
|
+
|
22
|
+
initialize_from_attributes_hash(attributes)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module NetSuite
|
2
|
+
module Records
|
3
|
+
class DescriptionItem
|
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, :delete, :search, :update, :upsert
|
11
|
+
|
12
|
+
fields :available_to_partners, :created_date, :description, :include_children, :is_inactive, :item_id, :last_modified_date
|
13
|
+
|
14
|
+
record_refs :custom_form, :department, :issue_product, :klass, :location
|
15
|
+
|
16
|
+
field :custom_field_list, CustomFieldList
|
17
|
+
field :subsidiary_list, RecordRefList
|
18
|
+
# TODO field :translations_list, TranslationList
|
19
|
+
|
20
|
+
attr_reader :internal_id
|
21
|
+
attr_accessor :external_id
|
22
|
+
|
23
|
+
def initialize(attributes = {})
|
24
|
+
@internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
|
25
|
+
@external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
|
26
|
+
initialize_from_attributes_hash(attributes)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.search_class_name
|
30
|
+
"Item"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/lib/netsuite/version.rb
CHANGED
@@ -35,4 +35,30 @@ describe NetSuite::Records::AssemblyItem do
|
|
35
35
|
expect(item.subsidiary_list.record_ref[1].internal_id).to eq(2)
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe '#item_vendor_list' do
|
40
|
+
it 'can be set from attributes' do
|
41
|
+
attributes = {
|
42
|
+
:item_vendor => {
|
43
|
+
:vendor=>{
|
44
|
+
:name=>"Spring Water",
|
45
|
+
:"@xmlns:platform_core"=>"urn:core_2016_1.platform.webservices.netsuite.com",
|
46
|
+
:@internal_id=>"20"
|
47
|
+
},
|
48
|
+
:purchase_price=>"16.14",
|
49
|
+
:preferred_vendor=>true
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
item.item_vendor_list = attributes
|
54
|
+
expect(item.item_vendor_list).to be_kind_of(NetSuite::Records::ItemVendorList)
|
55
|
+
expect(item.item_vendor_list.item_vendors.length).to eql(1)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'can be set from a ItemVendorList object' do
|
59
|
+
item_vendor_list = NetSuite::Records::ItemVendorList.new
|
60
|
+
item.item_vendor_list = item_vendor_list
|
61
|
+
expect(item.item_vendor_list).to eql(item_vendor_list)
|
62
|
+
end
|
63
|
+
end
|
38
64
|
end
|
@@ -34,7 +34,11 @@ describe 'basic records' do
|
|
34
34
|
NetSuite::Records::ContactRole,
|
35
35
|
NetSuite::Records::PaymentItem,
|
36
36
|
NetSuite::Records::CreditMemo,
|
37
|
-
NetSuite::Records::
|
37
|
+
NetSuite::Records::InventoryItem,
|
38
|
+
NetSuite::Records::DescriptionItem,
|
39
|
+
NetSuite::Records::SubtotalItem,
|
40
|
+
NetSuite::Records::Term,
|
41
|
+
NetSuite::Records::Note,
|
38
42
|
]
|
39
43
|
}
|
40
44
|
|
@@ -60,8 +60,29 @@ describe NetSuite::Records::InventoryItem do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
describe '#item_vendor_list' do
|
63
|
-
it 'can be set from attributes'
|
64
|
-
|
63
|
+
it 'can be set from attributes' do
|
64
|
+
attributes = {
|
65
|
+
:item_vendor => {
|
66
|
+
:vendor=>{
|
67
|
+
:name=>"Spring Water",
|
68
|
+
:"@xmlns:platform_core"=>"urn:core_2016_1.platform.webservices.netsuite.com",
|
69
|
+
:@internal_id=>"20"
|
70
|
+
},
|
71
|
+
:purchase_price=>"16.14",
|
72
|
+
:preferred_vendor=>true
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
item.item_vendor_list = attributes
|
77
|
+
expect(item.item_vendor_list).to be_kind_of(NetSuite::Records::ItemVendorList)
|
78
|
+
expect(item.item_vendor_list.item_vendors.length).to eql(1)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'can be set from a ItemVendorList object' do
|
82
|
+
item_vendor_list = NetSuite::Records::ItemVendorList.new
|
83
|
+
item.item_vendor_list = item_vendor_list
|
84
|
+
expect(item.item_vendor_list).to eql(item_vendor_list)
|
85
|
+
end
|
65
86
|
end
|
66
87
|
|
67
88
|
describe '#site_category_list' do
|
@@ -80,8 +101,24 @@ describe NetSuite::Records::InventoryItem do
|
|
80
101
|
end
|
81
102
|
|
82
103
|
describe '#locations_list' do
|
104
|
+
let(:response) {
|
105
|
+
NetSuite::Response.new(
|
106
|
+
:success => true,
|
107
|
+
:body => {
|
108
|
+
:locations_list => {:locations => %w(loc1 loc2) }
|
109
|
+
}
|
110
|
+
)
|
111
|
+
}
|
112
|
+
|
83
113
|
it 'can be set from attributes'
|
84
|
-
it 'can be set from an InventoryItemLocationsList object'
|
114
|
+
it 'can be set from an InventoryItemLocationsList object' do
|
115
|
+
expect(NetSuite::Actions::Get).to receive(:call)
|
116
|
+
.with([NetSuite::Records::InventoryItem, :internal_id => 20], {})
|
117
|
+
.and_return(response)
|
118
|
+
item = NetSuite::Records::InventoryItem.get(20)
|
119
|
+
expect(item).to be_kind_of(NetSuite::Records::InventoryItem)
|
120
|
+
expect(item.locations_list.locations).to eql(%w(loc1 loc2))
|
121
|
+
end
|
85
122
|
end
|
86
123
|
|
87
124
|
describe '#matrix_option_list' do
|
@@ -132,6 +132,62 @@ describe NetSuite::Records::Invoice do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
describe '#shipping_address' do
|
136
|
+
it 'can be set from attributes' do
|
137
|
+
attributes = {
|
138
|
+
:country => "_unitedStates",
|
139
|
+
:attention => "William Sanders",
|
140
|
+
:addressee => "William Sanders",
|
141
|
+
:addr1 => "test1",
|
142
|
+
:addr2 => "test2",
|
143
|
+
:city => "San Francisco",
|
144
|
+
:state => "CA",
|
145
|
+
:zip => "94131",
|
146
|
+
:addr_text => "William Sanders<br>William Sanders<br>test1<br>test2<br>San Francisco CA 94131",
|
147
|
+
:override => false,
|
148
|
+
:"@xmlns:platform_common" => "urn:common_2016_1.platform.webservices.netsuite.com"
|
149
|
+
}
|
150
|
+
|
151
|
+
invoice.shipping_address = attributes
|
152
|
+
expect(invoice.shipping_address).to be_kind_of(NetSuite::Records::Address)
|
153
|
+
expect(invoice.shipping_address.addressee).to eql("William Sanders")
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'can be set from a ItemVendorList object' do
|
157
|
+
shipping_address = NetSuite::Records::Address.new
|
158
|
+
invoice.shipping_address = shipping_address
|
159
|
+
expect(invoice.shipping_address).to eql(shipping_address)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#billing_address' do
|
164
|
+
it 'can be set from attributes' do
|
165
|
+
attributes = {
|
166
|
+
:country => "_unitedStates",
|
167
|
+
:attention => "William Sanders",
|
168
|
+
:addressee => "William Sanders",
|
169
|
+
:addr1 => "test1",
|
170
|
+
:addr2 => "test2",
|
171
|
+
:city => "San Francisco",
|
172
|
+
:state => "CA",
|
173
|
+
:zip => "94131",
|
174
|
+
:addr_text => "William Sanders<br>William Sanders<br>test1<br>test2<br>San Francisco CA 94131",
|
175
|
+
:override => false,
|
176
|
+
:"@xmlns:platform_common" => "urn:common_2016_1.platform.webservices.netsuite.com"
|
177
|
+
}
|
178
|
+
|
179
|
+
invoice.billing_address = attributes
|
180
|
+
expect(invoice.billing_address).to be_kind_of(NetSuite::Records::Address)
|
181
|
+
expect(invoice.billing_address.addressee).to eql("William Sanders")
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'can be set from a ItemVendorList object' do
|
185
|
+
billing_address = NetSuite::Records::Address.new
|
186
|
+
invoice.billing_address = billing_address
|
187
|
+
expect(invoice.billing_address).to eql(billing_address)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
135
191
|
describe '.get' do
|
136
192
|
context 'when the response is successful' do
|
137
193
|
let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
|
@@ -156,6 +212,51 @@ describe NetSuite::Records::Invoice do
|
|
156
212
|
end
|
157
213
|
end
|
158
214
|
|
215
|
+
describe '.search' do
|
216
|
+
context 'when the response is successful' do
|
217
|
+
let(:response) do
|
218
|
+
NetSuite::Response.new(
|
219
|
+
:success => true,
|
220
|
+
:body => {
|
221
|
+
:status => { :@is_success => 'true' },
|
222
|
+
:total_records => '1',
|
223
|
+
:search_row_list => {
|
224
|
+
:search_row => {
|
225
|
+
:basic => {
|
226
|
+
:alt_name => {:search_value=>'A Awesome Name'},
|
227
|
+
:"@xmlns:platform_common"=>'urn:common_2012_1.platform.webservices.netsuite.com'},
|
228
|
+
:"@xsi:type" => 'listRel:ItemSearchRow'
|
229
|
+
}
|
230
|
+
}
|
231
|
+
}
|
232
|
+
)
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'returns an Invoice instance populated with the data from the response object' do
|
236
|
+
allow(NetSuite::Actions::Search).to receive(:call).and_return(response)
|
237
|
+
|
238
|
+
invoice = NetSuite::Records::Invoice.search(
|
239
|
+
criteria: {
|
240
|
+
basic: [
|
241
|
+
{
|
242
|
+
field: 'type',
|
243
|
+
operator: 'anyOf',
|
244
|
+
type: 'SearchEnumMultiSelectField',
|
245
|
+
value: ['_invoice']
|
246
|
+
}
|
247
|
+
]
|
248
|
+
},
|
249
|
+
columns: {
|
250
|
+
'tranSales:basic' => [
|
251
|
+
'platformCommon:internalId/' => {}
|
252
|
+
]
|
253
|
+
}
|
254
|
+
).results[0]
|
255
|
+
expect(invoice).to be_kind_of(NetSuite::Records::Invoice)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
159
260
|
describe '.initialize' do
|
160
261
|
context 'when the request is successful' do
|
161
262
|
it 'returns an initialized invoice from the customer entity' do
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::ItemVendorList do
|
4
|
+
let(:list) { NetSuite::Records::ItemVendorList.new }
|
5
|
+
|
6
|
+
it 'has a item_vendors attribute' do
|
7
|
+
expect(list.item_vendors).to be_kind_of(Array)
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '#to_record' do
|
11
|
+
before do
|
12
|
+
list.item_vendors << NetSuite::Records::ItemVendor.new(
|
13
|
+
:vendor => {:name => 'Spring Water'}
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'can represent itself as a SOAP record' do
|
18
|
+
record = {
|
19
|
+
"listAcct:itemVendor"=>[
|
20
|
+
{"listAcct:vendor"=>{
|
21
|
+
:name=>"Spring Water"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}
|
26
|
+
|
27
|
+
expect(list.to_record).to eql(record)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::ItemVendor do
|
4
|
+
let(:vendor) { NetSuite::Records::ItemVendor.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:vendor, :purchase_price, :preferred_vendor
|
9
|
+
].each do |field|
|
10
|
+
expect(vendor).to have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has all the right record refs'
|
15
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::Note do
|
4
|
+
let(:note) { NetSuite::Records::Note.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:direction, :lastModifiedDate, :note, :noteDate, :title, :topic
|
9
|
+
].each do |field|
|
10
|
+
expect(note).to have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'has the right record_refs' do
|
15
|
+
[
|
16
|
+
:noteType, :activity, :author, :customForm, :entity, :folder, :item, :media, :record, :recordType, :transaction
|
17
|
+
].each do |record_ref|
|
18
|
+
expect(note).to have_record_ref(record_ref)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#custom_field_list' do
|
23
|
+
it 'can be set from attributes' do
|
24
|
+
attributes = {
|
25
|
+
:custom_field => {
|
26
|
+
:value => 10,
|
27
|
+
:internal_id => 'custfield_something'
|
28
|
+
}
|
29
|
+
}
|
30
|
+
note.custom_field_list = attributes
|
31
|
+
expect(note.custom_field_list).to be_kind_of(NetSuite::Records::CustomFieldList)
|
32
|
+
expect(note.custom_field_list.custom_fields.length).to eql(1)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'can be set from a CustomFieldList object' do
|
36
|
+
custom_field_list = NetSuite::Records::CustomFieldList.new
|
37
|
+
note.custom_field_list = custom_field_list
|
38
|
+
expect(note.custom_field_list).to eql(custom_field_list)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '.get' do
|
43
|
+
context 'when the response is successful' do
|
44
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :note => 'Test Note', :direction => '_outgoing' }) }
|
45
|
+
|
46
|
+
it 'returns a note instance populated with the data from the response object' do
|
47
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Note, {:internal_id => 1}], {}).and_return(response)
|
48
|
+
note = NetSuite::Records::Note.get(:internal_id => 1)
|
49
|
+
expect(note).to be_kind_of(NetSuite::Records::Note)
|
50
|
+
expect(note.note).to eq 'Test Note'
|
51
|
+
expect(note.direction).to eq '_outgoing'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when the response is unsuccessful' do
|
56
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
57
|
+
|
58
|
+
it 'raises a RecordNotFound exception' do
|
59
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::Note, {:internal_id => 1}], {}).and_return(response)
|
60
|
+
expect {
|
61
|
+
NetSuite::Records::Note.get(:internal_id => 1)
|
62
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
63
|
+
/NetSuite::Records::Note with OPTIONS=(.*) could not be found/)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#add' do
|
69
|
+
let(:note) { NetSuite::Records::Note.new(:note => 'TEST note', :entity => NetSuite::Records::RecordRef.new(internalId: 1, type: 'Customer') ) }
|
70
|
+
|
71
|
+
context 'when the response is successful' do
|
72
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
73
|
+
|
74
|
+
it 'returns true' do
|
75
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
76
|
+
with([note], {}).
|
77
|
+
and_return(response)
|
78
|
+
expect(note.add).to be_truthy
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when the response is unsuccessful' do
|
83
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
84
|
+
|
85
|
+
it 'returns false' do
|
86
|
+
expect(NetSuite::Actions::Add).to receive(:call).
|
87
|
+
with([note], {}).
|
88
|
+
and_return(response)
|
89
|
+
expect(note.add).to be_falsey
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe '#delete' do
|
95
|
+
context 'when the response is successful' do
|
96
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
|
97
|
+
|
98
|
+
it 'returns true' do
|
99
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
100
|
+
with([note], {}).
|
101
|
+
and_return(response)
|
102
|
+
expect(note.delete).to be_truthy
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'when the response is unsuccessful' do
|
107
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
108
|
+
|
109
|
+
it 'returns false' do
|
110
|
+
expect(NetSuite::Actions::Delete).to receive(:call).
|
111
|
+
with([note], {}).
|
112
|
+
and_return(response)
|
113
|
+
expect(note.delete).to be_falsey
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe '#to_record' do
|
119
|
+
let(:note) { NetSuite::Records::Note.new(:note => 'TEST note', :direction => '_outgoing' ) }
|
120
|
+
|
121
|
+
it 'returns a hash of attributes that can be used in a SOAP request' do
|
122
|
+
expect(note.to_record).to eql({
|
123
|
+
'commGeneral:note' => 'TEST note',
|
124
|
+
'commGeneral:direction' => '_outgoing',
|
125
|
+
})
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe '#record_type' do
|
130
|
+
it 'returns a string type for the record to be used in a SOAP request' do
|
131
|
+
expect(note.record_type).to eql('commGeneral:Note')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe NetSuite::Records::NoteType do
|
4
|
+
let(:note_type) { NetSuite::Records::NoteType.new }
|
5
|
+
|
6
|
+
it 'has all the right fields' do
|
7
|
+
[
|
8
|
+
:name, :description, :is_inactive
|
9
|
+
].each do |field|
|
10
|
+
expect(note_type).to have_field(field)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.get' do
|
15
|
+
context 'when the response is successful' do
|
16
|
+
let(:response) { NetSuite::Response.new(:success => true, :body => { :name => 'E-mail', :is_inactive => false }) }
|
17
|
+
|
18
|
+
it 'returns a note_type instance populated with the data from the response object' do
|
19
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::NoteType, {:internal_id => 1}], {}).and_return(response)
|
20
|
+
note_type = NetSuite::Records::NoteType.get(:internal_id => 1)
|
21
|
+
expect(note_type).to be_kind_of(NetSuite::Records::NoteType)
|
22
|
+
expect(note_type.name).to eq 'E-mail'
|
23
|
+
expect(note_type.is_inactive).to be_falsy
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'when the response is unsuccessful' do
|
28
|
+
let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
|
29
|
+
|
30
|
+
it 'raises a RecordNotFound exception' do
|
31
|
+
expect(NetSuite::Actions::Get).to receive(:call).with([NetSuite::Records::NoteType, {:internal_id => 1}], {}).and_return(response)
|
32
|
+
expect {
|
33
|
+
NetSuite::Records::NoteType.get(:internal_id => 1)
|
34
|
+
}.to raise_error(NetSuite::RecordNotFound,
|
35
|
+
/NetSuite::Records::NoteType with OPTIONS=(.*) could not be found/)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.search' do
|
41
|
+
context 'when the response is successful' do
|
42
|
+
|
43
|
+
it 'returns a NoteType instance populated with the data from the response object' do
|
44
|
+
body = {
|
45
|
+
total_records: 1,
|
46
|
+
record_list: {
|
47
|
+
record: [
|
48
|
+
{name: 'E-mail', :is_inactive => false },
|
49
|
+
]
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
allow(NetSuite::Actions::Search).to receive(:call).with(
|
54
|
+
[NetSuite::Records::NoteType, {:is_inactive => false}], {}
|
55
|
+
).and_return(
|
56
|
+
NetSuite::Response.new(:success => true, :body => body)
|
57
|
+
)
|
58
|
+
|
59
|
+
search_result = NetSuite::Records::NoteType.search(:is_inactive => false)
|
60
|
+
|
61
|
+
expect(search_result).to be_a NetSuite::Support::SearchResult
|
62
|
+
expect(search_result.total_records).to eq 1
|
63
|
+
|
64
|
+
period1 = search_result.results.first
|
65
|
+
|
66
|
+
expect(period1).to be_a NetSuite::Records::NoteType
|
67
|
+
expect(period1.name).to eq 'E-mail'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#to_record' do
|
73
|
+
let(:note_type) { NetSuite::Records::NoteType.new(:name => 'E-mail', :is_inactive => false) }
|
74
|
+
|
75
|
+
it 'returns a hash of attributes that can be used in a SOAP request' do
|
76
|
+
expect(note_type.to_record).to eql({
|
77
|
+
'listAcct:name' => 'E-mail',
|
78
|
+
'listAcct:isInactive' => false,
|
79
|
+
})
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#record_type' do
|
84
|
+
it 'returns a string type for the record to be used in a SOAP request' do
|
85
|
+
expect(note_type.record_type).to eql('listAcct:NoteType')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: netsuite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: savon
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/netsuite/core_ext/string/lower_camelcase.rb
|
79
79
|
- lib/netsuite/errors.rb
|
80
80
|
- lib/netsuite/namespaces/act_sched.rb
|
81
|
+
- lib/netsuite/namespaces/comm_general.rb
|
81
82
|
- lib/netsuite/namespaces/file_cabinet.rb
|
82
83
|
- lib/netsuite/namespaces/list_acct.rb
|
83
84
|
- lib/netsuite/namespaces/list_emp.rb
|
@@ -163,6 +164,7 @@ files:
|
|
163
164
|
- lib/netsuite/records/deposit_other_list.rb
|
164
165
|
- lib/netsuite/records/deposit_payment.rb
|
165
166
|
- lib/netsuite/records/deposit_payment_list.rb
|
167
|
+
- lib/netsuite/records/description_item.rb
|
166
168
|
- lib/netsuite/records/discount_item.rb
|
167
169
|
- lib/netsuite/records/duration.rb
|
168
170
|
- lib/netsuite/records/employee.rb
|
@@ -192,6 +194,8 @@ files:
|
|
192
194
|
- lib/netsuite/records/item_receipt.rb
|
193
195
|
- lib/netsuite/records/item_receipt_item.rb
|
194
196
|
- lib/netsuite/records/item_receipt_item_list.rb
|
197
|
+
- lib/netsuite/records/item_vendor.rb
|
198
|
+
- lib/netsuite/records/item_vendor_list.rb
|
195
199
|
- lib/netsuite/records/job.rb
|
196
200
|
- lib/netsuite/records/job_status.rb
|
197
201
|
- lib/netsuite/records/journal_entry.rb
|
@@ -205,6 +209,8 @@ files:
|
|
205
209
|
- lib/netsuite/records/non_inventory_purchase_item.rb
|
206
210
|
- lib/netsuite/records/non_inventory_resale_item.rb
|
207
211
|
- lib/netsuite/records/non_inventory_sale_item.rb
|
212
|
+
- lib/netsuite/records/note.rb
|
213
|
+
- lib/netsuite/records/note_type.rb
|
208
214
|
- lib/netsuite/records/opportunity.rb
|
209
215
|
- lib/netsuite/records/opportunity_item.rb
|
210
216
|
- lib/netsuite/records/opportunity_item_list.rb
|
@@ -233,6 +239,7 @@ files:
|
|
233
239
|
- lib/netsuite/records/ship_address.rb
|
234
240
|
- lib/netsuite/records/site_category.rb
|
235
241
|
- lib/netsuite/records/subsidiary.rb
|
242
|
+
- lib/netsuite/records/subtotal_item.rb
|
236
243
|
- lib/netsuite/records/support_case.rb
|
237
244
|
- lib/netsuite/records/task.rb
|
238
245
|
- lib/netsuite/records/tax_group.rb
|
@@ -346,6 +353,8 @@ files:
|
|
346
353
|
- spec/netsuite/records/item_fulfillment_spec.rb
|
347
354
|
- spec/netsuite/records/item_group_spec.rb
|
348
355
|
- spec/netsuite/records/item_member_list_spec.rb
|
356
|
+
- spec/netsuite/records/item_vendor_list_spec.rb
|
357
|
+
- spec/netsuite/records/item_vendor_spec.rb
|
349
358
|
- spec/netsuite/records/job_spec.rb
|
350
359
|
- spec/netsuite/records/journal_entry_line_list_spec.rb
|
351
360
|
- spec/netsuite/records/journal_entry_line_spec.rb
|
@@ -354,6 +363,8 @@ files:
|
|
354
363
|
- spec/netsuite/records/location_spec.rb
|
355
364
|
- spec/netsuite/records/matrix_option_list_spec.rb
|
356
365
|
- spec/netsuite/records/non_inventory_sale_item_spec.rb
|
366
|
+
- spec/netsuite/records/note_spec.rb
|
367
|
+
- spec/netsuite/records/note_type_spec.rb
|
357
368
|
- spec/netsuite/records/payment_item_spec.rb
|
358
369
|
- spec/netsuite/records/payment_method_spec.rb
|
359
370
|
- spec/netsuite/records/phone_call_spec.rb
|
@@ -530,6 +541,8 @@ test_files:
|
|
530
541
|
- spec/netsuite/records/item_fulfillment_spec.rb
|
531
542
|
- spec/netsuite/records/item_group_spec.rb
|
532
543
|
- spec/netsuite/records/item_member_list_spec.rb
|
544
|
+
- spec/netsuite/records/item_vendor_list_spec.rb
|
545
|
+
- spec/netsuite/records/item_vendor_spec.rb
|
533
546
|
- spec/netsuite/records/job_spec.rb
|
534
547
|
- spec/netsuite/records/journal_entry_line_list_spec.rb
|
535
548
|
- spec/netsuite/records/journal_entry_line_spec.rb
|
@@ -538,6 +551,8 @@ test_files:
|
|
538
551
|
- spec/netsuite/records/location_spec.rb
|
539
552
|
- spec/netsuite/records/matrix_option_list_spec.rb
|
540
553
|
- spec/netsuite/records/non_inventory_sale_item_spec.rb
|
554
|
+
- spec/netsuite/records/note_spec.rb
|
555
|
+
- spec/netsuite/records/note_type_spec.rb
|
541
556
|
- spec/netsuite/records/payment_item_spec.rb
|
542
557
|
- spec/netsuite/records/payment_method_spec.rb
|
543
558
|
- spec/netsuite/records/phone_call_spec.rb
|