netsuite 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/netsuite.rb CHANGED
@@ -22,6 +22,7 @@ require 'netsuite/records/customer_addressbook_list'
22
22
  require 'netsuite/records/invoice'
23
23
  require 'netsuite/records/record_ref'
24
24
  require 'netsuite/records/ship_address'
25
+ require 'netsuite/records/non_inventory_sale_item'
25
26
 
26
27
  module NetSuite
27
28
 
@@ -26,10 +26,10 @@ module NetSuite
26
26
  :to_be_printed, :total, :total_cost_estimate, :tracking_numbers, :tran_date, :tran_id, :tran_is_vsoe_bundle,
27
27
  :transaction_bill_address, :transaction_ship_address, :vat_reg_num, :vsoe_auto_calc
28
28
 
29
- attr_reader :internal_id, :external_id
30
-
31
29
  record_refs :account, :bill_address_list, :custom_form, :entity, :posting_period, :ship_address_list
32
30
 
31
+ attr_reader :internal_id, :external_id
32
+
33
33
  def initialize(attributes = {})
34
34
  @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
35
35
  @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
@@ -0,0 +1,43 @@
1
+ module NetSuite
2
+ module Records
3
+ class NonInventorySaleItem
4
+ include FieldSupport
5
+ include RecordRefSupport
6
+
7
+ fields :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture,
8
+ :created_date, :custom_field_list, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap,
9
+ :featured_description, :handling_cost, :handling_cost_units, :include_children, :is_donation_item, :is_fulfillable,
10
+ :is_gco_compliant, :is_inactive, :is_online, :is_taxable, :item_id, :last_modified_date, :manufacturer,
11
+ :manufacturer_addr1, :manufacturer_city, :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id,
12
+ :manufacturer_zip, :matrix_option_list, :matrix_type, :max_donation_amount, :meta_tag_html, :minimum_quantity,
13
+ :minimum_quantity_units, :mpn, :mult_manufacture_addr, :nex_tag_category, :no_price_message, :offer_support,
14
+ :on_special, :out_of_stock_behavior, :out_of_stock_message, :overall_quantity_pricing_type, :page_title,
15
+ :preference_criterion, :presentation_item_list, :prices_include_tax, :pricing_matrix, :producer, :product_feed_list,
16
+ :rate, :related_items_description, :sales_description, :schedule_b_code, :schedule_b_number, :schedule_b_quantity,
17
+ :search_keywords, :ship_individually, :shipping_cost, :shipping_cost_units, :shopping_dot_com_category,
18
+ :shopzilla_category_id, :show_default_donation_amount, :site_category_list, :sitemap_priority, :soft_descriptor,
19
+ :specials_description, :stock_description, :store_description, :store_detailed_description, :store_display_name,
20
+ :translations_list, :upc_code, :url_component, :use_marginal_rates, :vsoe_deferral, :vsoe_delivered,
21
+ :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units
22
+
23
+ record_refs :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_amount,
24
+ :issue_product, :item_options_list, :location, :parent, :pricing_group, :purchase_tax_code, :quantity_pricing_schedule,
25
+ :rev_rec_schedule, :sale_unit, :sales_tax_code, :ship_package, :store_display_image, :store_display_thumbnail,
26
+ :store_item_template, :subsidiary_list, :tax_schedule, :units_type
27
+
28
+ def initialize(attributes = {})
29
+ initialize_from_attributes_hash(attributes)
30
+ end
31
+
32
+ def self.get(id)
33
+ response = Actions::Get.call(id, self)
34
+ if response.success?
35
+ new(response.body)
36
+ else
37
+ raise RecordNotFound, "#{self} with ID=#{id} could not be found"
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
@@ -26,6 +26,14 @@ describe NetSuite::Records::Customer do
26
26
  end
27
27
  end
28
28
 
29
+ it 'has the right record_refs' do
30
+ [
31
+ :custom_form, :entity_status
32
+ ].each do |record_ref|
33
+ customer.should have_record_ref(record_ref)
34
+ end
35
+ end
36
+
29
37
  it 'has an addressbook_list field that builds a CustomerAddressbookList object' do
30
38
  customer.addressbook_list = {
31
39
  :addressbook => {
@@ -46,30 +54,6 @@ describe NetSuite::Records::Customer do
46
54
  customer.addressbook_list.should be_kind_of(NetSuite::Records::CustomerAddressbookList)
47
55
  end
48
56
 
49
- describe 'RecordRefs' do
50
- describe 'custom_form' do
51
- it 'builds a RecordRef for this field' do
52
- customer.custom_form = {
53
- :@internal_id => '3',
54
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
55
- :name => 'RP Customer Form'
56
- }
57
- customer.custom_form.should be_kind_of(NetSuite::Records::RecordRef)
58
- end
59
- end
60
-
61
- describe 'entity_status' do
62
- it 'builds a RecordRef for this field' do
63
- customer.entity_status = {
64
- :@internal_id => '13',
65
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
66
- :name => 'CUSTOMER-Closed Won'
67
- }
68
- customer.entity_status.should be_kind_of(NetSuite::Records::RecordRef)
69
- end
70
- end
71
- end
72
-
73
57
  describe '.get' do
74
58
  context 'when the response is successful' do
75
59
  let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
@@ -32,6 +32,14 @@ describe NetSuite::Records::Invoice do
32
32
  end
33
33
  end
34
34
 
35
+ it 'has the right record_refs' do
36
+ [
37
+ :account, :bill_address_list, :custom_form, :entity, :posting_period, :ship_address_list
38
+ ].each do |record_ref|
39
+ invoice.should have_record_ref(record_ref)
40
+ end
41
+ end
42
+
35
43
  it 'handles the "klass" field correctly'
36
44
  # This field maps to 'class' but cannot be set as such in Ruby as it will cause runtime errors.
37
45
 
@@ -76,74 +84,6 @@ describe NetSuite::Records::Invoice do
76
84
  pending
77
85
  end
78
86
 
79
- describe 'RecordRefs' do
80
- describe 'account' do
81
- it 'creates a RecordRef for this attribute' do
82
- invoice.account = {
83
- :@internal_id => '123',
84
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
85
- :name => '1100 Accounts Receivable'
86
- }
87
- invoice.account.should be_kind_of(NetSuite::Records::RecordRef)
88
- end
89
- end
90
-
91
- describe 'bill_address_list' do
92
- it 'creates a RecordRef for this attribute' do
93
- invoice.bill_address_list = {
94
- :@internal_id => '567',
95
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
96
- :name => '123 Happy Lane'
97
- }
98
- invoice.bill_address_list.should be_kind_of(NetSuite::Records::RecordRef)
99
- end
100
- end
101
-
102
- describe 'custom_form' do
103
- it 'creates a RecordRef for this attribute' do
104
- invoice.custom_form = {
105
- :@internal_id => '101',
106
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
107
- :name => 'RP Test Product Invoice'
108
- }
109
- invoice.custom_form.should be_kind_of(NetSuite::Records::RecordRef)
110
- end
111
- end
112
-
113
- describe 'entity' do
114
- it 'creates a RecordRef for this attribute' do
115
- invoice.entity = {
116
- :@internal_id => '988',
117
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
118
- :name => '100157 Shutter Fly'
119
- }
120
- invoice.entity.should be_kind_of(NetSuite::Records::RecordRef)
121
- end
122
- end
123
-
124
- describe 'posting_period' do
125
- it 'creates a RecordRef for this attribute' do
126
- invoice.posting_period = {
127
- :@internal_id => '20',
128
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
129
- :name => 'Jan 2012'
130
- }
131
- invoice.posting_period.should be_kind_of(NetSuite::Records::RecordRef)
132
- end
133
- end
134
-
135
- describe 'ship_address_list' do
136
- it 'creates a RecordRef for this attribute' do
137
- invoice.ship_address_list = {
138
- :@internal_id => '567',
139
- :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
140
- :name => '123 Happy Lane'
141
- }
142
- invoice.ship_address_list.should be_kind_of(NetSuite::Records::RecordRef)
143
- end
144
- end
145
- end
146
-
147
87
  it 'has a transaction_bill_address field that builds a BillAddress object' do
148
88
  invoice.transaction_bill_address = {
149
89
  :"@xmlns:platform_common" => 'urn:common_2011_2.platform.webservices.netsuite.com',
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::NonInventorySaleItem do
4
+ let(:item) { NetSuite::Records::NonInventorySaleItem.new }
5
+
6
+ it 'has the right fields' do
7
+ [
8
+ :available_to_partners, :cost_estimate, :cost_estimate_type, :cost_estimate_units, :country_of_manufacture, :created_date,
9
+ :custom_field_list, :display_name, :dont_show_price, :enforce_min_qty_internally, :exclude_from_sitemap,
10
+ :featured_description, :handling_cost, :handling_cost_units, :include_children, :is_donation_item, :is_fulfillable,
11
+ :is_gco_compliant, :is_inactive, :is_online, :is_taxable, :item_id, :last_modified_date, :manufacturer, :manufacturer_addr1,
12
+ :manufacturer_city, :manufacturer_state, :manufacturer_tariff, :manufacturer_tax_id, :manufacturer_zip, :matrix_option_list,
13
+ :matrix_type, :max_donation_amount, :meta_tag_html, :minimum_quantity, :minimum_quantity_units, :mpn,
14
+ :mult_manufacture_addr, :nex_tag_category, :no_price_message, :offer_support, :on_special, :out_of_stock_behavior,
15
+ :out_of_stock_message, :overall_quantity_pricing_type, :page_title, :preference_criterion, :presentation_item_list,
16
+ :prices_include_tax, :pricing_matrix, :producer, :product_feed_list, :rate, :related_items_description, :sales_description,
17
+ :schedule_b_code, :schedule_b_number, :schedule_b_quantity, :search_keywords, :ship_individually, :shipping_cost,
18
+ :shipping_cost_units, :shopping_dot_com_category, :shopzilla_category_id, :show_default_donation_amount,
19
+ :site_category_list, :sitemap_priority, :soft_descriptor, :specials_description, :stock_description, :store_description,
20
+ :store_detailed_description, :store_display_name, :translations_list, :upc_code, :url_component, :use_marginal_rates,
21
+ :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :weight, :weight_unit, :weight_units
22
+ ].each do |field|
23
+ item.should have_field(field)
24
+ end
25
+ end
26
+
27
+ it 'has the right record_refs' do
28
+ [
29
+ :billing_schedule, :cost_category, :custom_form, :deferred_revenue_account, :department, :income_amount, :issue_product,
30
+ :item_options_list, :location, :parent, :pricing_group, :purchase_tax_code, :quantity_pricing_schedule, :rev_rec_schedule,
31
+ :sale_unit, :sales_tax_code, :ship_package, :store_display_image, :store_display_thumbnail, :store_item_template,
32
+ :subsidiary_list, :tax_schedule, :units_type
33
+ ].each do |record_ref|
34
+ item.should have_record_ref(record_ref)
35
+ end
36
+ end
37
+
38
+ # :class RecordRef
39
+
40
+ describe '.get' do
41
+ context 'when the response is successful' do
42
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :manufacturer_zip => '90401' }) }
43
+
44
+ it 'returns a NonInventorySaleItem instance populated with the data from the response object' do
45
+ NetSuite::Actions::Get.should_receive(:call).with(20, NetSuite::Records::NonInventorySaleItem).and_return(response)
46
+ customer = NetSuite::Records::NonInventorySaleItem.get(20)
47
+ customer.should be_kind_of(NetSuite::Records::NonInventorySaleItem)
48
+ customer.manufacturer_zip.should eql('90401')
49
+ end
50
+ end
51
+
52
+ context 'when the response is unsuccessful' do
53
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
54
+
55
+ it 'raises a RecordNotFound exception' do
56
+ NetSuite::Actions::Get.should_receive(:call).with(20, NetSuite::Records::NonInventorySaleItem).and_return(response)
57
+ lambda {
58
+ NetSuite::Records::NonInventorySaleItem.get(20)
59
+ }.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Records::NonInventorySaleItem with ID=20 could not be found')
60
+ end
61
+ end
62
+ end
63
+
64
+ end
@@ -0,0 +1,25 @@
1
+ RSpec::Matchers.define :have_record_ref do |attribute|
2
+
3
+ match do |model|
4
+ record_ref_can_be_set_and_retrieved?(model, attribute) && record_ref_can_be_set_on_instantiation?(model, attribute)
5
+ end
6
+
7
+ def record_ref_can_be_set_and_retrieved?(model, attribute)
8
+ model.send("#{attribute}=".to_sym, attributes)
9
+ model.send(attribute).should be_kind_of(NetSuite::Records::RecordRef)
10
+ end
11
+
12
+ def record_ref_can_be_set_on_instantiation?(model, attribute)
13
+ new_model = model.class.new(attribute => attributes)
14
+ new_model.send(attribute).should be_kind_of(NetSuite::Records::RecordRef)
15
+ end
16
+
17
+ def attributes
18
+ {
19
+ :@internal_id => '125',
20
+ :"@xmlns:platform_core" => 'urn:core_2011_2.platform.webservices.netsuite.com',
21
+ :name => 'RP RecordRef'
22
+ }
23
+ end
24
+
25
+ end
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-07 00:00:00 Z
18
+ date: 2012-01-09 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon
@@ -113,6 +113,7 @@ files:
113
113
  - lib/netsuite/records/customer.rb
114
114
  - lib/netsuite/records/customer_addressbook_list.rb
115
115
  - lib/netsuite/records/invoice.rb
116
+ - lib/netsuite/records/non_inventory_sale_item.rb
116
117
  - lib/netsuite/records/record_ref.rb
117
118
  - lib/netsuite/records/ship_address.rb
118
119
  - lib/netsuite/response.rb
@@ -131,6 +132,7 @@ files:
131
132
  - spec/netsuite/records/customer_addressbook_list_spec.rb
132
133
  - spec/netsuite/records/customer_spec.rb
133
134
  - spec/netsuite/records/invoice_spec.rb
135
+ - spec/netsuite/records/non_inventory_sale_item_spec.rb
134
136
  - spec/netsuite/records/record_ref_spec.rb
135
137
  - spec/netsuite/records/ship_address_spec.rb
136
138
  - spec/netsuite/response_spec.rb
@@ -144,6 +146,7 @@ files:
144
146
  - spec/support/fixtures/get/get_customer.xml
145
147
  - spec/support/fixtures/get/get_invoice.xml
146
148
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml
149
+ - spec/support/record_ref_matcher.rb
147
150
  - spec/support/savon.rb
148
151
  - wsdl/2011_02.wsdl
149
152
  homepage: https://github.com/RevolutionPrep/netsuite
@@ -192,6 +195,7 @@ test_files:
192
195
  - spec/netsuite/records/customer_addressbook_list_spec.rb
193
196
  - spec/netsuite/records/customer_spec.rb
194
197
  - spec/netsuite/records/invoice_spec.rb
198
+ - spec/netsuite/records/non_inventory_sale_item_spec.rb
195
199
  - spec/netsuite/records/record_ref_spec.rb
196
200
  - spec/netsuite/records/ship_address_spec.rb
197
201
  - spec/netsuite/response_spec.rb
@@ -205,4 +209,5 @@ test_files:
205
209
  - spec/support/fixtures/get/get_customer.xml
206
210
  - spec/support/fixtures/get/get_invoice.xml
207
211
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml
212
+ - spec/support/record_ref_matcher.rb
208
213
  - spec/support/savon.rb