netsuite 0.0.48 → 0.0.49

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Netsuite
1
+ # NetSuite Ruby SuiteTalk Gem
2
2
 
3
3
  * This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API. Wow, that is a mouthful.
4
4
  * The gem does not cover the entire API, only the subset that we have found useful to cover so far.
5
- * [Extending the wrapper](#extending) is pretty simple. See below for an example.
5
+ * Extending the wrapper is pretty simple. See below for an example.
6
6
 
7
7
  ## Installation
8
8
 
@@ -19,6 +19,16 @@ Or install it yourself as:
19
19
  $ gem install netsuite
20
20
 
21
21
  This gem is built for ruby 1.9.x, checkout the [1-8-stable](https://github.com/RevolutionPrep/netsuite/tree/1-8-stable) branch for ruby 1.8.x support.
22
+
23
+ ## Testing
24
+ Before contributing a patch make sure all existing tests pass.
25
+
26
+ ```
27
+ git clone git://github.com/iloveitaly/netsuite.git
28
+ cd netsuite
29
+ bundle
30
+ bundle exec rspec
31
+ ```
22
32
  ## Usage
23
33
 
24
34
  ### Configuration
@@ -48,8 +58,13 @@ end
48
58
  * Retrieves the customer by internalId.
49
59
 
50
60
  ```Ruby
51
- customer = NetSuite::Records::Customer.get(:internal_id => 4) # => #<NetSuite::Records::Customer:0x1042f59b8>
52
- customer.is_person # => true
61
+ customer = NetSuite::Records::Customer.get(:internal_id => 4)
62
+ # => #<NetSuite::Records::Customer:0x1042f59b8>
63
+ customer.is_person
64
+ # => true
65
+
66
+ # or
67
+ NetSuite::Records::Customer.get(4).is_person
53
68
  ```
54
69
 
55
70
  ## Additions
@@ -79,6 +79,9 @@ module NetSuite
79
79
  autoload :PricingMatrix, 'netsuite/records/pricing_matrix'
80
80
  autoload :RecordRef, 'netsuite/records/record_ref'
81
81
  autoload :RevRecTemplate, 'netsuite/records/rev_rec_template'
82
+ autoload :SalesOrder, 'netsuite/records/sales_order'
83
+ autoload :SalesOrderItem, 'netsuite/records/sales_order_item'
84
+ autoload :SalesOrderItemList, 'netsuite/records/sales_order_item_list'
82
85
  autoload :ShipAddress, 'netsuite/records/ship_address'
83
86
  autoload :Term, 'netsuite/records/term'
84
87
  end
@@ -11,7 +11,7 @@ module NetSuite
11
11
 
12
12
  def request
13
13
  connection.request :platformMsgs, :add do
14
- soap.namespaces['xmlns:platformMsgs'] = "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
14
+ soap.namespaces['xmlns:platformMsgs'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
15
15
  soap.namespaces['xmlns:platformCore'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
16
16
  soap.namespaces['xmlns:listRel'] = "urn:relationships_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com"
17
17
  soap.namespaces['xmlns:tranSales'] = "urn:sales_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com"
@@ -66,7 +66,10 @@ module NetSuite
66
66
  module Support
67
67
  def add
68
68
  response = NetSuite::Actions::Add.call(self)
69
- response.success?
69
+ if response.success?
70
+ @internal_id = response.body[:@internal_id]
71
+ true
72
+ end
70
73
  end
71
74
  end
72
75
 
@@ -67,6 +67,8 @@ module NetSuite
67
67
  module ClassMethods
68
68
 
69
69
  def get(options = {})
70
+ options = { :internal_id => options } unless options.is_a?(Hash)
71
+
70
72
  response = NetSuite::Actions::Get.call(self, options)
71
73
  if response.success?
72
74
  new(response.body)
@@ -10,7 +10,7 @@ module NetSuite
10
10
  actions :get, :initialize, :add, :delete
11
11
 
12
12
  fields :alt_handling_cost, :alt_shipping_cost, :balance, :bill_address,
13
- :billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name, :custom_field_list,
13
+ :billing_schedule, :contrib_pct, :created_date, :currency_name, :custom_field_list,
14
14
  :deferred_revenue, :discount_amount, :discount_date, :discount_item, :discount_rate,
15
15
  :due_date, :email, :end_date, :est_gross_profit, :est_gross_profit_percent, :exchange_rate,
16
16
  :exclude_commission, :exp_cost_disc_amount, :exp_cost_disc_print, :exp_cost_disc_rate, :exp_cost_disc_tax_1_amt,
@@ -19,12 +19,12 @@ module NetSuite
19
19
  :handling_tax_2_rate, :handling_tax_code, :is_taxable, :item_cost_disc_amount, :item_cost_disc_print,
20
20
  :item_cost_disc_rate, :item_cost_disc_tax_1_amt, :item_cost_disc_taxable, :item_cost_discount, :item_cost_list,
21
21
  :item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :item_list, :job, :last_modified_date,
22
- :lead_source, :linked_tracking_numbers, :location, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
22
+ :lead_source, :linked_tracking_numbers, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
23
23
  :other_ref_name, :partner, :partners_list, :promo_code, :rev_rec_end_date,
24
24
  :rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date,
25
- :sales_group, :sales_rep, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
26
- :ship_method, :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date,
27
- :status, :subsidiary, :sync_partner_teams, :sync_sales_teams, :tax_2_total, :tax_item, :tax_rate,
25
+ :sales_group, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
26
+ :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date,
27
+ :status, :subsidiary, :sync_partner_teams, :sync_sales_teams, :tax_2_total, :tax_rate,
28
28
  :tax_total, :time_disc_amount, :time_disc_print, :time_disc_rate, :time_disc_tax_1_amt, :time_disc_taxable,
29
29
  :time_discount, :time_list, :time_tax_code, :time_tax_rate_1, :time_tax_rate_2, :to_be_emailed, :to_be_faxed,
30
30
  :to_be_printed, :total_cost_estimate, :tracking_numbers, :tran_date, :tran_id, :tran_is_vsoe_bundle,
@@ -37,7 +37,9 @@ module NetSuite
37
37
 
38
38
  read_only_fields :sub_total, :discount_total, :total, :recognized_revenue, :amount_remaining, :amount_paid
39
39
 
40
- record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass, :posting_period, :ship_address_list, :terms
40
+ record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass,
41
+ :posting_period, :ship_address_list, :terms, :location, :sales_rep, :tax_item, :created_from,
42
+ :ship_method
41
43
 
42
44
  attr_reader :internal_id
43
45
  attr_accessor :external_id
@@ -16,7 +16,7 @@ module NetSuite
16
16
 
17
17
  field :custom_field_list, CustomFieldList
18
18
 
19
- record_refs :department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units
19
+ record_refs :department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units, :klass
20
20
 
21
21
  def initialize(attributes_or_record = {})
22
22
  case attributes_or_record
@@ -0,0 +1,43 @@
1
+ module NetSuite
2
+ module Records
3
+ class SalesOrder
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Support::Actions
8
+ include Namespaces::TranSales
9
+
10
+ actions :get, :add, :initialize, :delete, :update
11
+
12
+ fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :auto_apply, :balance,
13
+ :bill_address, :contrib_pct, :created_date, :currency_name, :deferred_revenue, :discount_rate, :email, :end_date,
14
+ :est_gross_profit, :est_gross_profit_percent, :exchange_rate, :exclude_commission, :fax, :gift_cert_applied,
15
+ :gift_cert_available, :gift_cert_total, :handling_cost, :handling_tax1_rate, :handling_tax2_rate, :is_taxable,
16
+ :last_modified_date, :memo, :message, :on_credit_hold, :order_status, :other_ref_num, :recognized_revenue,
17
+ :rev_rec_on_rev_commitment, :sales_effective_date, :shipping_cost, :shipping_tax1_rate, :shipping_tax2_rate, :source,
18
+ :start_date, :status, :sync_partner_teams, :sync_sales_teams, :tax2_total, :tax_rate, :to_be_emailed, :to_be_faxed,
19
+ :to_be_printed, :total_cost_estimate, :tran_date, :tran_id, :tran_is_vsoe_bundle, :vat_reg_num,
20
+ :vsoe_auto_calc
21
+
22
+ field :transaction_bill_address, BillAddress
23
+ field :item_list, SalesOrderItemList
24
+ field :custom_field_list, CustomFieldList
25
+
26
+ read_only_fields :applied, :discount_total, :sub_total, :tax_total, :total, :unapplied
27
+
28
+ record_refs :account, :bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item, :entity, :gift_cert,
29
+ :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel, :opportunity, :partner, :posting_period, :promo_code,
30
+ :sales_group, :sales_rep, :ship_method, :shipping_tax_code, :subsidiary, :tax_item
31
+
32
+ attr_reader :internal_id
33
+ attr_accessor :external_id
34
+
35
+ def initialize(attributes = {})
36
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
37
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
38
+ initialize_from_attributes_hash(attributes)
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,42 @@
1
+ module NetSuite
2
+ module Records
3
+ class SalesOrderItem
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::TranSales
8
+
9
+ fields :amount, :bin_numbers, :cost_estimate, :cost_estimate_type, :defer_rev_rec, :description, :gift_cert_from,
10
+ :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email, :gift_cert_recipient_name, :gross_amt, :is_taxable,
11
+ :line, :order_line, :quantity, :rate, :rev_rec_end_date, :rev_rec_start_date, :rev_rec_term_in_months, :serial_numbers,
12
+ :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered,
13
+ :vsoe_permit_discount, :vsoe_price
14
+
15
+ field :custom_field_list, CustomFieldList
16
+
17
+ record_refs :department, :item, :job, :klass, :location, :price, :rev_rec_schedule, :tax_code, :units
18
+
19
+ def initialize(attributes_or_record = {})
20
+ case attributes_or_record
21
+ when Hash
22
+ initialize_from_attributes_hash(attributes_or_record)
23
+ when self.class
24
+ initialize_from_record(attributes_or_record)
25
+ end
26
+ end
27
+
28
+ def initialize_from_record(record)
29
+ self.attributes = record.send(:attributes)
30
+ end
31
+
32
+ def to_record
33
+ rec = super
34
+ if rec["#{record_namespace}:customFieldList"]
35
+ rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
36
+ end
37
+ rec
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class SalesOrderItemList
4
+ include Support::Fields
5
+ include Namespaces::TranSales
6
+
7
+ fields :item
8
+
9
+ def initialize(attributes = {})
10
+ initialize_from_attributes_hash(attributes)
11
+ end
12
+
13
+ def item=(items)
14
+ case items
15
+ when Hash
16
+ self.items << SalesOrderItem.new(items)
17
+ when Array
18
+ items.each { |item| self.items << SalesOrderItem.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
29
+
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.48'
2
+ VERSION = '0.0.49'
3
3
  end
@@ -7,7 +7,7 @@ describe NetSuite::Records::InvoiceItem do
7
7
  [
8
8
  :amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent, :defer_rev_rec,
9
9
  :description, :gift_cert_from, :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email,
10
- :gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line, :klass,
10
+ :gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line,
11
11
  :options, :order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled, :quantity_on_hand,
12
12
  :quantity_ordered, :quantity_remaining, :rate, :rev_rec_end_date, :rev_rec_start_date, :serial_numbers, :ship_group,
13
13
  :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount,
@@ -19,7 +19,8 @@ describe NetSuite::Records::InvoiceItem do
19
19
 
20
20
  it 'has the right record_refs' do
21
21
  [
22
- :department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units
22
+ :department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units,
23
+ :klass
23
24
  ].each do |record_ref|
24
25
  item.should have_record_ref(record_ref)
25
26
  end
@@ -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, :currency_name,
12
12
  :deferred_revenue, :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,
@@ -17,12 +17,12 @@ describe NetSuite::Records::Invoice do
17
17
  :handling_tax_2_rate, :handling_tax_code, :is_taxable, :item_cost_disc_amount, :item_cost_disc_print,
18
18
  :item_cost_disc_rate, :item_cost_disc_tax_1_amt, :item_cost_disc_taxable, :item_cost_discount, :item_cost_list,
19
19
  :item_cost_tax_code, :item_cost_tax_rate_1, :item_cost_tax_rate_2, :job, :last_modified_date,
20
- :lead_source, :linked_tracking_numbers, :location, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
20
+ :lead_source, :linked_tracking_numbers, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
21
21
  :other_ref_name, :partner, :partners_list, :promo_code, :recognized_revenue, :rev_rec_end_date,
22
22
  :rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date,
23
- :sales_group, :sales_rep, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
24
- :ship_method, :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date,
25
- :status, :subsidiary, :sync_partner_teams, :sync_sales_teams, :tax_2_total, :tax_item, :tax_rate,
23
+ :sales_group, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
24
+ :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date,
25
+ :status, :subsidiary, :sync_partner_teams, :sync_sales_teams, :tax_2_total, :tax_rate,
26
26
  :tax_total, :time_disc_amount, :time_disc_print, :time_disc_rate, :time_disc_tax_1_amt, :time_disc_taxable,
27
27
  :time_discount, :time_list, :time_tax_code, :time_tax_rate_1, :time_tax_rate_2, :to_be_emailed, :to_be_faxed,
28
28
  :to_be_printed, :total_cost_estimate, :tracking_numbers, :tran_date, :tran_id, :tran_is_vsoe_bundle,
@@ -42,7 +42,8 @@ describe NetSuite::Records::Invoice do
42
42
 
43
43
  it 'has the right record_refs' do
44
44
  [
45
- :account, :bill_address_list, :custom_form, :department, :entity, :klass, :posting_period, :ship_address_list, :terms
45
+ :account, :bill_address_list, :custom_form, :department, :entity, :klass, :posting_period, :ship_address_list, :terms,
46
+ :created_from, :location, :sales_rep, :ship_method, :tax_item
46
47
  ].each do |record_ref|
47
48
  invoice.should have_record_ref(record_ref)
48
49
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::SalesOrderItemList do
4
+ let(:list) { NetSuite::Records::SalesOrderItemList.new }
5
+
6
+ it 'has a items attribute' do
7
+ list.items.should be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ before do
12
+ list.items << NetSuite::Records::SalesOrderItem.new(
13
+ :rate => 10
14
+ )
15
+ end
16
+
17
+ it 'can represent itself as a SOAP record' do
18
+ record = {
19
+ 'tranSales:item' => [{
20
+ 'tranSales:rate' => 10
21
+ }]
22
+ }
23
+ list.to_record.should eql(record)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::SalesOrderItem do
4
+ let(:item) { NetSuite::Records::SalesOrderItem.new }
5
+
6
+ it 'has all the right fields' do
7
+ [
8
+ :amount, :bin_numbers, :cost_estimate, :cost_estimate_type, :defer_rev_rec, :description, :gift_cert_from,
9
+ :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email, :gift_cert_recipient_name, :gross_amt, :is_taxable,
10
+ :line, :order_line, :quantity, :rate, :rev_rec_end_date, :rev_rec_start_date, :rev_rec_term_in_months, :serial_numbers,
11
+ :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered, :vsoe_permit_discount,
12
+ :vsoe_price
13
+ ].each do |field|
14
+ item.should have_field(field)
15
+ end
16
+ end
17
+
18
+ it 'has all the right record refs' do
19
+ [
20
+ :department, :item, :job, :klass, :location, :price, :rev_rec_schedule, :tax_code, :units
21
+ ].each do |record_ref|
22
+ item.should have_record_ref(record_ref)
23
+ end
24
+ end
25
+
26
+ describe '#options' do
27
+ it 'can be set from attributes'
28
+ it 'can be set from a CustomFieldList object'
29
+ end
30
+
31
+ describe '#inventory_detail' do
32
+ it 'can be set from attributes'
33
+ it 'can be set from an InventoryDetail object'
34
+ end
35
+
36
+ describe '#custom_field_list' do
37
+ it 'can be set from attributes'
38
+ it 'can be set from a CustomFieldList object'
39
+ end
40
+
41
+ end
@@ -0,0 +1,201 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::SalesOrder do
4
+ let(:salesorder) { NetSuite::Records::SalesOrder.new }
5
+ let(:customer) { NetSuite::Records::Customer.new }
6
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
7
+
8
+ it 'has all the right fields' do
9
+ [
10
+ :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :applied, :auto_apply,
11
+ :balance, :bill_address, :contrib_pct, :created_date, :currency_name, :deferred_revenue,
12
+ :discount_rate, :discount_total, :email, :end_date, :est_gross_profit, :est_gross_profit_percent,
13
+ :exchange_rate, :exclude_commission, :fax, :gift_cert_applied, :gift_cert_available,
14
+ :gift_cert_total, :handling_cost, :handling_tax1_rate, :handling_tax2_rate, :is_taxable,
15
+ :last_modified_date, :memo, :message, :on_credit_hold, :other_ref_num, :recognized_revenue,
16
+ :rev_rec_on_rev_commitment, :sales_effective_date, :shipping_cost, :shipping_tax1_rate,
17
+ :shipping_tax2_rate, :source, :start_date, :status, :sub_total, :sync_partner_teams,
18
+ :sync_sales_teams, :tax2_total, :tax_rate, :tax_total, :to_be_emailed, :to_be_faxed, :to_be_printed,
19
+ :total, :total_cost_estimate, :tran_date, :tran_id, :tran_is_vsoe_bundle, :unapplied, :vat_reg_num,
20
+ :vsoe_auto_calc
21
+ ].each do |field|
22
+ salesorder.should have_field(field)
23
+ end
24
+ end
25
+
26
+ it 'has all the right record refs' do
27
+ [
28
+ :account, :bill_address_list, :created_from, :currency, :custom_form, :department, :discount_item,
29
+ :entity, :gift_cert, :handling_tax_code, :job, :klass, :lead_source, :location, :message_sel,
30
+ :opportunity, :partner, :posting_period, :promo_code, :sales_group, :sales_rep,
31
+ :ship_method, :shipping_tax_code, :subsidiary, :tax_item
32
+ ].each do |record_ref|
33
+ salesorder.should have_record_ref(record_ref)
34
+ end
35
+ end
36
+
37
+ describe '#order_status' do
38
+ it 'can be set from attributes'
39
+ it 'can be set from a SalesOrderOrderStatus object'
40
+ end
41
+
42
+ describe '#item_list' do
43
+ it 'can be set from attributes' do
44
+ attributes = {
45
+ :item => {
46
+ :amount => 10
47
+ }
48
+ }
49
+ salesorder.item_list = attributes
50
+ salesorder.item_list.should be_kind_of(NetSuite::Records::SalesOrderItemList)
51
+ salesorder.item_list.items.length.should eql(1)
52
+ end
53
+
54
+ it 'can be set from a SalesOrderItemList object' do
55
+ item_list = NetSuite::Records::SalesOrderItemList.new
56
+ salesorder.item_list = item_list
57
+ salesorder.item_list.should eql(item_list)
58
+ end
59
+ end
60
+
61
+ describe '#transaction_bill_address' do
62
+ it 'can be set from attributes'
63
+ it 'can be set from a BillAddress object'
64
+ end
65
+
66
+ describe '#revenue_status' do
67
+ it 'can be set from attributes'
68
+ it 'can be set from a RevenueStatus object'
69
+ end
70
+
71
+ describe '#sales_team_list' do
72
+ it 'can be set from attributes'
73
+ it 'can be set from a SalesOrderSalesTeamList object'
74
+ end
75
+
76
+ describe '#partners_list' do
77
+ it 'can be set from attributes'
78
+ it 'can be set from a SalesOrderPartnersList object'
79
+ end
80
+
81
+ describe '#custom_field_list' do
82
+ it 'can be set from attributes'
83
+ it 'can be set from a CustomFieldList object'
84
+ end
85
+
86
+ describe '.get' do
87
+ context 'when the response is successful' do
88
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :alt_shipping_cost => 100 }) }
89
+
90
+ it 'returns a SalesOrder instance populated with the data from the response object' do
91
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::SalesOrder, :external_id => 1).and_return(response)
92
+ salesorder = NetSuite::Records::SalesOrder.get(:external_id => 1)
93
+ salesorder.should be_kind_of(NetSuite::Records::SalesOrder)
94
+ salesorder.alt_shipping_cost.should eql(100)
95
+ end
96
+ end
97
+
98
+ context 'when the response is unsuccessful' do
99
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
100
+
101
+ it 'raises a RecordNotFound exception' do
102
+ NetSuite::Actions::Get.should_receive(:call).with(NetSuite::Records::SalesOrder, :external_id => 1).and_return(response)
103
+ lambda {
104
+ NetSuite::Records::SalesOrder.get(:external_id => 1)
105
+ }.should raise_error(NetSuite::RecordNotFound,
106
+ /NetSuite::Records::SalesOrder with OPTIONS=(.*) could not be found/)
107
+ end
108
+ end
109
+ end
110
+
111
+ describe '.initialize' do
112
+ context 'when the request is successful' do
113
+ it 'returns an initialized sales order from the customer entity' do
114
+ NetSuite::Actions::Initialize.should_receive(:call).with(NetSuite::Records::SalesOrder, customer).and_return(response)
115
+ salesorder = NetSuite::Records::SalesOrder.initialize(customer)
116
+ salesorder.should be_kind_of(NetSuite::Records::SalesOrder)
117
+ end
118
+ end
119
+
120
+ context 'when the response is unsuccessful' do
121
+ pending
122
+ end
123
+ end
124
+
125
+ describe '#add' do
126
+ let(:test_data) { { :email => 'test@example.com', :fax => '1234567890' } }
127
+
128
+ context 'when the response is successful' do
129
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
130
+
131
+ it 'returns true' do
132
+ salesorder = NetSuite::Records::SalesOrder.new(test_data)
133
+ NetSuite::Actions::Add.should_receive(:call).
134
+ with(salesorder).
135
+ and_return(response)
136
+ salesorder.add.should be_true
137
+ end
138
+ end
139
+
140
+ context 'when the response is unsuccessful' do
141
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
142
+
143
+ it 'returns false' do
144
+ salesorder = NetSuite::Records::SalesOrder.new(test_data)
145
+ NetSuite::Actions::Add.should_receive(:call).
146
+ with(salesorder).
147
+ and_return(response)
148
+ salesorder.add.should be_false
149
+ end
150
+ end
151
+ end
152
+
153
+ describe '#delete' do
154
+ let(:test_data) { { :internal_id => '1' } }
155
+
156
+ context 'when the response is successful' do
157
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
158
+
159
+ it 'returns true' do
160
+ salesorder = NetSuite::Records::SalesOrder.new(test_data)
161
+ NetSuite::Actions::Delete.should_receive(:call).
162
+ with(salesorder).
163
+ and_return(response)
164
+ salesorder.delete.should be_true
165
+ end
166
+ end
167
+
168
+ context 'when the response is unsuccessful' do
169
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
170
+
171
+ it 'returns false' do
172
+ salesorder = NetSuite::Records::SalesOrder.new(test_data)
173
+ NetSuite::Actions::Delete.should_receive(:call).
174
+ with(salesorder).
175
+ and_return(response)
176
+ salesorder.delete.should be_false
177
+ end
178
+ end
179
+ end
180
+
181
+ describe '#to_record' do
182
+ before do
183
+ salesorder.email = 'something@example.com'
184
+ salesorder.tran_id = '4'
185
+ end
186
+ it 'can represent itself as a SOAP record' do
187
+ record = {
188
+ 'tranSales:email' => 'something@example.com',
189
+ 'tranSales:tranId' => '4'
190
+ }
191
+ salesorder.to_record.should eql(record)
192
+ end
193
+ end
194
+
195
+ describe '#record_type' do
196
+ it 'returns a string representation of the SOAP type' do
197
+ salesorder.record_type.should eql('tranSales:SalesOrder')
198
+ end
199
+ end
200
+
201
+ end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.48
5
4
  prerelease:
5
+ version: 0.0.49
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Moran
@@ -10,88 +10,88 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-05 00:00:00.000000000 Z
13
+ date: 2013-02-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: savon
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
16
+ version_requirements: !ruby/object:Gem::Requirement
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
22
20
  version: 1.2.0
21
+ none: false
22
+ name: savon
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
25
+ requirement: !ruby/object:Gem::Requirement
27
26
  requirements:
28
27
  - - ~>
29
28
  - !ruby/object:Gem::Version
30
29
  version: 1.2.0
31
- - !ruby/object:Gem::Dependency
32
- name: nokogiri
33
- requirement: !ruby/object:Gem::Requirement
34
30
  none: false
31
+ - !ruby/object:Gem::Dependency
32
+ version_requirements: !ruby/object:Gem::Requirement
35
33
  requirements:
36
34
  - - ~>
37
35
  - !ruby/object:Gem::Version
38
36
  version: 1.5.0
37
+ none: false
38
+ name: nokogiri
39
39
  type: :runtime
40
40
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
41
+ requirement: !ruby/object:Gem::Requirement
43
42
  requirements:
44
43
  - - ~>
45
44
  - !ruby/object:Gem::Version
46
45
  version: 1.5.0
47
- - !ruby/object:Gem::Dependency
48
- name: rspec
49
- requirement: !ruby/object:Gem::Requirement
50
46
  none: false
47
+ - !ruby/object:Gem::Dependency
48
+ version_requirements: !ruby/object:Gem::Requirement
51
49
  requirements:
52
50
  - - ~>
53
51
  - !ruby/object:Gem::Version
54
52
  version: '2.10'
53
+ none: false
54
+ name: rspec
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
59
58
  requirements:
60
59
  - - ~>
61
60
  - !ruby/object:Gem::Version
62
61
  version: '2.10'
63
- - !ruby/object:Gem::Dependency
64
- name: savon_spec
65
- requirement: !ruby/object:Gem::Requirement
66
62
  none: false
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: !ruby/object:Gem::Requirement
67
65
  requirements:
68
66
  - - ~>
69
67
  - !ruby/object:Gem::Version
70
68
  version: 1.3.0
69
+ none: false
70
+ name: savon_spec
71
71
  type: :development
72
72
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
74
- none: false
73
+ requirement: !ruby/object:Gem::Requirement
75
74
  requirements:
76
75
  - - ~>
77
76
  - !ruby/object:Gem::Version
78
77
  version: 1.3.0
79
- - !ruby/object:Gem::Dependency
80
- name: autotest-standalone
81
- requirement: !ruby/object:Gem::Requirement
82
78
  none: false
79
+ - !ruby/object:Gem::Dependency
80
+ version_requirements: !ruby/object:Gem::Requirement
83
81
  requirements:
84
82
  - - ~>
85
83
  - !ruby/object:Gem::Version
86
84
  version: '4.5'
85
+ none: false
86
+ name: autotest-standalone
87
87
  type: :development
88
88
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
90
- none: false
89
+ requirement: !ruby/object:Gem::Requirement
91
90
  requirements:
92
91
  - - ~>
93
92
  - !ruby/object:Gem::Version
94
93
  version: '4.5'
94
+ none: false
95
95
  description: NetSuite SuiteTalk API Wrapper
96
96
  email:
97
97
  - ryan.moran@gmail.com
@@ -164,6 +164,9 @@ files:
164
164
  - lib/netsuite/records/pricing_matrix.rb
165
165
  - lib/netsuite/records/record_ref.rb
166
166
  - lib/netsuite/records/rev_rec_template.rb
167
+ - lib/netsuite/records/sales_order.rb
168
+ - lib/netsuite/records/sales_order_item.rb
169
+ - lib/netsuite/records/sales_order_item_list.rb
167
170
  - lib/netsuite/records/ship_address.rb
168
171
  - lib/netsuite/records/term.rb
169
172
  - lib/netsuite/response.rb
@@ -220,6 +223,9 @@ files:
220
223
  - spec/netsuite/records/payment_method_spec.rb
221
224
  - spec/netsuite/records/record_ref_spec.rb
222
225
  - spec/netsuite/records/rev_rec_template_spec.rb
226
+ - spec/netsuite/records/sales_order_item_list_spec.rb
227
+ - spec/netsuite/records/sales_order_item_spec.rb
228
+ - spec/netsuite/records/sales_order_spec.rb
223
229
  - spec/netsuite/records/ship_address_spec.rb
224
230
  - spec/netsuite/records/term_spec.rb
225
231
  - spec/netsuite/response_spec.rb
@@ -253,20 +259,20 @@ rdoc_options: []
253
259
  require_paths:
254
260
  - lib
255
261
  required_ruby_version: !ruby/object:Gem::Requirement
256
- none: false
257
262
  requirements:
258
263
  - - ! '>='
259
264
  - !ruby/object:Gem::Version
260
265
  version: '0'
261
- required_rubygems_version: !ruby/object:Gem::Requirement
262
266
  none: false
267
+ required_rubygems_version: !ruby/object:Gem::Requirement
263
268
  requirements:
264
269
  - - ! '>='
265
270
  - !ruby/object:Gem::Version
266
271
  version: '0'
272
+ none: false
267
273
  requirements: []
268
274
  rubyforge_project:
269
- rubygems_version: 1.8.24
275
+ rubygems_version: 1.8.23
270
276
  signing_key:
271
277
  specification_version: 3
272
278
  summary: NetSuite SuiteTalk API Wrapper
@@ -315,6 +321,9 @@ test_files:
315
321
  - spec/netsuite/records/payment_method_spec.rb
316
322
  - spec/netsuite/records/record_ref_spec.rb
317
323
  - spec/netsuite/records/rev_rec_template_spec.rb
324
+ - spec/netsuite/records/sales_order_item_list_spec.rb
325
+ - spec/netsuite/records/sales_order_item_spec.rb
326
+ - spec/netsuite/records/sales_order_spec.rb
318
327
  - spec/netsuite/records/ship_address_spec.rb
319
328
  - spec/netsuite/records/term_spec.rb
320
329
  - spec/netsuite/response_spec.rb