netsuite 0.0.50 → 0.1.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.
Files changed (38) hide show
  1. data/README.md +13 -0
  2. data/lib/netsuite.rb +5 -4
  3. data/lib/netsuite/actions/add.rb +19 -14
  4. data/lib/netsuite/actions/delete.rb +11 -6
  5. data/lib/netsuite/actions/get.rb +7 -7
  6. data/lib/netsuite/actions/initialize.rb +7 -7
  7. data/lib/netsuite/actions/search.rb +16 -17
  8. data/lib/netsuite/actions/update.rb +16 -13
  9. data/lib/netsuite/configuration.rb +10 -8
  10. data/lib/netsuite/records/custom_field.rb +0 -18
  11. data/lib/netsuite/records/custom_field_list.rb +11 -7
  12. data/lib/netsuite/records/custom_record.rb +2 -2
  13. data/lib/netsuite/records/customer.rb +3 -3
  14. data/lib/netsuite/records/customer_payment.rb +3 -2
  15. data/lib/netsuite/records/customer_payment_apply.rb +17 -0
  16. data/lib/netsuite/records/customer_payment_apply_list.rb +27 -0
  17. data/lib/netsuite/records/invoice.rb +4 -4
  18. data/lib/netsuite/records/item_fulfillment.rb +43 -0
  19. data/lib/netsuite/records/item_fulfillment_item.rb +45 -0
  20. data/lib/netsuite/records/item_fulfillment_item_list.rb +32 -0
  21. data/lib/netsuite/records/sales_order_item.rb +1 -1
  22. data/lib/netsuite/support/records.rb +4 -2
  23. data/lib/netsuite/support/requests.rb +0 -8
  24. data/lib/netsuite/version.rb +1 -1
  25. data/netsuite.gemspec +2 -5
  26. data/spec/netsuite/actions/add_spec.rb +6 -4
  27. data/spec/netsuite/actions/delete_spec.rb +4 -2
  28. data/spec/netsuite/actions/get_spec.rb +8 -4
  29. data/spec/netsuite/actions/initialize_spec.rb +5 -2
  30. data/spec/netsuite/actions/update_spec.rb +6 -4
  31. data/spec/netsuite/configuration_spec.rb +5 -0
  32. data/spec/netsuite/records/custom_field_list_spec.rb +9 -1
  33. data/spec/netsuite/records/customer_spec.rb +2 -2
  34. data/spec/netsuite/records/invoice_spec.rb +7 -6
  35. data/spec/spec_helper.rb +0 -2
  36. data/spec/support/savon.rb +4 -6
  37. metadata +9 -53
  38. data/lib/netsuite/xml_logger.rb +0 -31
data/README.md CHANGED
@@ -87,6 +87,19 @@ task.add
87
87
  `open https://system.sandbox.netsuite.com/app/crm/calendar/task.nl?id=#{invoice.internal_id}`
88
88
 
89
89
  task.update :message => 'New Message'
90
+
91
+ # basic search
92
+ search = NetSuite::Records::Customer.search({
93
+ basic: [
94
+ {
95
+ field: 'companyName',
96
+ operator: 'contains',
97
+ value: company_name
98
+ }
99
+ ]
100
+ })
101
+
102
+ `open https://system.netsuite.com/app/common/entity/custjob.nl?id=#{search.results.first.internal_id}`
90
103
  ```
91
104
 
92
105
 
@@ -3,7 +3,6 @@ require 'set'
3
3
  require 'savon'
4
4
  require 'netsuite/version'
5
5
  require 'netsuite/errors'
6
- require 'netsuite/xml_logger'
7
6
  require 'netsuite/core_ext/string/lower_camelcase'
8
7
 
9
8
  module NetSuite
@@ -63,6 +62,8 @@ module NetSuite
63
62
  autoload :CustomerAddressbook, 'netsuite/records/customer_addressbook'
64
63
  autoload :CustomerAddressbookList, 'netsuite/records/customer_addressbook_list'
65
64
  autoload :CustomerPayment, 'netsuite/records/customer_payment'
65
+ autoload :CustomerPaymentApply, 'netsuite/records/customer_payment_apply'
66
+ autoload :CustomerPaymentApplyList, 'netsuite/records/customer_payment_apply_list'
66
67
  autoload :CustomerRefund, 'netsuite/records/customer_refund'
67
68
  autoload :CustomerRefundApply, 'netsuite/records/customer_refund_apply'
68
69
  autoload :CustomerRefundApplyList, 'netsuite/records/customer_refund_apply_list'
@@ -76,6 +77,9 @@ module NetSuite
76
77
  autoload :Invoice, 'netsuite/records/invoice'
77
78
  autoload :InvoiceItem, 'netsuite/records/invoice_item'
78
79
  autoload :InvoiceItemList, 'netsuite/records/invoice_item_list'
80
+ autoload :ItemFulfillment, 'netsuite/records/item_fulfillment'
81
+ autoload :ItemFulfillmentItem, 'netsuite/records/item_fulfillment_item'
82
+ autoload :ItemFulfillmentItemList, 'netsuite/records/item_fulfillment_item_list'
79
83
  autoload :Job, 'netsuite/records/job'
80
84
  autoload :JournalEntry, 'netsuite/records/journal_entry'
81
85
  autoload :JournalEntryLine, 'netsuite/records/journal_entry_line'
@@ -98,9 +102,6 @@ module NetSuite
98
102
 
99
103
  def self.configure(&block)
100
104
  NetSuite::Configuration.instance_eval(&block)
101
- Savon.configure do |config|
102
- config.logger = NetSuite::Configuration.logger
103
- end
104
105
  end
105
106
 
106
107
  end
@@ -10,20 +10,20 @@ module NetSuite
10
10
  private
11
11
 
12
12
  def request
13
- connection.request :platformMsgs, :add do
14
- soap.namespaces['xmlns:platformMsgs'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
15
- soap.namespaces['xmlns:platformCore'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
16
- soap.namespaces['xmlns:listRel'] = "urn:relationships_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com"
17
- soap.namespaces['xmlns:tranSales'] = "urn:sales_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com"
18
- soap.namespaces['xmlns:platformCommon'] = "urn:common_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
19
- soap.namespaces['xmlns:listAcct'] = "urn:accounting_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com"
20
- soap.namespaces['xmlns:actSched'] = "urn:scheduling_#{NetSuite::Configuration.api_version}.activities.webservices.netsuite.com"
21
- soap.namespaces['xmlns:tranCust'] = "urn:customers_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com"
22
- soap.namespaces['xmlns:setupCustom'] = "urn:customization_#{NetSuite::Configuration.api_version}.setup.webservices.netsuite.com"
23
- soap.namespaces['xmlns:tranGeneral'] = "urn:general_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com"
24
- soap.header = auth_header
25
- soap.body = request_body
26
- end
13
+ NetSuite::Configuration.connection(
14
+ namespaces: {
15
+ 'xmlns:platformMsgs' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
16
+ 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
17
+ 'xmlns:listRel' => "urn:relationships_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com",
18
+ 'xmlns:tranSales' => "urn:sales_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com",
19
+ 'xmlns:platformCommon' => "urn:common_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
20
+ 'xmlns:listAcct' => "urn:accounting_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com",
21
+ 'xmlns:actSched' => "urn:scheduling_#{NetSuite::Configuration.api_version}.activities.webservices.netsuite.com",
22
+ 'xmlns:tranCust' => "urn:customers_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com",
23
+ 'xmlns:setupCustom' => "urn:customization_#{NetSuite::Configuration.api_version}.setup.webservices.netsuite.com",
24
+ 'xmlns:tranGeneral' => "urn:general_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com",
25
+ },
26
+ ).call :add, :message => request_body
27
27
  end
28
28
 
29
29
  # <soap:Body>
@@ -34,6 +34,7 @@ module NetSuite
34
34
  # </platformMsgs:record>
35
35
  # </platformMsgs:add>
36
36
  # </soap:Body>
37
+
37
38
  def request_body
38
39
  hash = {
39
40
  'platformMsgs:record' => @object.to_record,
@@ -43,12 +44,15 @@ module NetSuite
43
44
  }
44
45
  }
45
46
  }
47
+
46
48
  if @object.respond_to?(:internal_id) && @object.internal_id
47
49
  hash[:attributes!]['platformMsgs:record']['platformMsgs:internalId'] = @object.internal_id
48
50
  end
51
+
49
52
  if @object.respond_to?(:external_id) && @object.external_id
50
53
  hash[:attributes!]['platformMsgs:record']['platformMsgs:externalId'] = @object.external_id
51
54
  end
55
+
52
56
  hash
53
57
  end
54
58
 
@@ -67,6 +71,7 @@ module NetSuite
67
71
  module Support
68
72
  def add
69
73
  response = NetSuite::Actions::Add.call(self)
74
+
70
75
  if response.success?
71
76
  @internal_id = response.body[:@internal_id]
72
77
  true
@@ -11,12 +11,12 @@ module NetSuite
11
11
  private
12
12
 
13
13
  def request
14
- connection.request :platformMsgs, :delete do
15
- soap.namespaces['xmlns:platformMsgs'] = "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
16
- soap.namespaces['xmlns:platformCore'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
17
- soap.header = auth_header
18
- soap.body = request_body
19
- end
14
+ NetSuite::Configuration.connection(
15
+ namespaces: {
16
+ 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
17
+ 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
18
+ },
19
+ ).call :delete, :message => request_body
20
20
  end
21
21
 
22
22
  def soap_type
@@ -37,16 +37,21 @@ module NetSuite
37
37
  }
38
38
  }
39
39
  }
40
+
40
41
  if @object.respond_to?(:external_id) && @object.external_id
41
42
  body[:attributes!]['platformMsgs:baseRef']['externalId'] = @object.external_id
42
43
  end
44
+
43
45
  if @object.respond_to?(:internal_id) && @object.internal_id
44
46
  body[:attributes!]['platformMsgs:baseRef']['internalId'] = @object.internal_id
45
47
  end
48
+
46
49
  if @object.class.respond_to?(:type_id) && @object.class.type_id
47
50
  body[:attributes!]['platformMsgs:baseRef']['typeId'] = @object.class.type_id
48
51
  end
52
+
49
53
  body[:attributes!]['platformMsgs:baseRef']['type'] = soap_type unless @options[:custom]
54
+
50
55
  body
51
56
  end
52
57
 
@@ -11,12 +11,12 @@ module NetSuite
11
11
  private
12
12
 
13
13
  def request
14
- connection.request :platformMsgs, :get do
15
- soap.namespaces['xmlns:platformMsgs'] = "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
16
- soap.namespaces['xmlns:platformCore'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
17
- soap.header = auth_header
18
- soap.body = request_body
19
- end
14
+ NetSuite::Configuration.connection(
15
+ namespaces: {
16
+ 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
17
+ 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
18
+ },
19
+ ).call :get, message: request_body#, message_tag: :platformMsgs
20
20
  end
21
21
 
22
22
  def soap_type
@@ -55,7 +55,7 @@ module NetSuite
55
55
  end
56
56
 
57
57
  def response_hash
58
- @response_hash = @response[:get_response][:read_response]
58
+ @response_hash = @response.body[:get_response][:read_response]
59
59
  end
60
60
 
61
61
  module Support
@@ -9,13 +9,13 @@ module NetSuite
9
9
  end
10
10
 
11
11
  def request
12
- connection.request :platformMsgs, :initialize do
13
- soap.namespaces['xmlns:platformMsgs'] = "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
14
- soap.namespaces['xmlns:platformCore'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
15
- soap.namespaces['xmlns:platformCoreTyp'] = "urn:types.core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
16
- soap.header = auth_header
17
- soap.body = request_body
18
- end
12
+ NetSuite::Configuration.connection(
13
+ namespaces: {
14
+ 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
15
+ 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
16
+ 'xmlns:platformCoreTyp' => "urn:types.core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
17
+ },
18
+ ).call :initialize, :message => request_body
19
19
  end
20
20
 
21
21
  # <platformMsgs:initializeRecord>
@@ -12,24 +12,23 @@ module NetSuite
12
12
  private
13
13
 
14
14
  def request
15
- # need to do this outside the block below because of variable scoping
16
- preferences = (@options[:preferences] || {}).inject({}) do |h, (k, v)|
15
+ # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteFlex/WebServices/STP_SettingSearchPreferences.html#N2028598271-3
16
+ preferences = NetSuite::Configuration.auth_header
17
+ preferences = preferences.merge((@options[:preferences] || {}).inject({}) do |h, (k, v)|
17
18
  h[k.to_s.lower_camelcase] = v
18
19
  h
19
- end
20
-
21
- connection.request(:search) do
22
- soap.namespaces['xmlns:platformMsgs'] = "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
23
- soap.namespaces['xmlns:platformCore'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
24
- soap.namespaces['xmlns:platformCommon'] = "urn:common_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
25
- soap.namespaces['xmlns:listRel'] = "urn:relationships_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com"
26
- soap.namespaces['xmlns:tranSales'] = "urn:sales_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com"
27
-
28
- # https://system.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteFlex/WebServices/STP_SettingSearchPreferences.html#N2028598271-3
29
- soap.header = auth_header.merge(preferences.empty? ? {} : { 'platformMsgs:searchPreferences' => preferences })
30
-
31
- soap.body = request_body
32
- end
20
+ end)
21
+
22
+ NetSuite::Configuration.connection(
23
+ namespaces: {
24
+ 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
25
+ 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
26
+ 'xmlns:platformCommon' => "urn:common_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
27
+ 'xmlns:listRel' => "urn:relationships_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com",
28
+ 'xmlns:tranSales' => "urn:sales_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com",
29
+ },
30
+ soap_header: preferences
31
+ ).call :search, :message => request_body
33
32
  end
34
33
 
35
34
  # basic search XML
@@ -97,7 +96,7 @@ module NetSuite
97
96
  end
98
97
 
99
98
  def search_result
100
- @search_result = @response[:search_response][:search_result]
99
+ @search_result = @response.body[:search_response][:search_result]
101
100
  end
102
101
 
103
102
  def success?
@@ -9,19 +9,19 @@ module NetSuite
9
9
  end
10
10
 
11
11
  def request
12
- connection.request :platformMsgs, :update do
13
- soap.namespaces['xmlns:platformMsgs'] = "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
14
- soap.namespaces['xmlns:platformCore'] = "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
15
- soap.namespaces['xmlns:listRel'] = "urn:relationships_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com"
16
- soap.namespaces['xmlns:tranSales'] = "urn:sales_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com"
17
- soap.namespaces['xmlns:platformCommon'] = "urn:common_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com"
18
- soap.namespaces['xmlns:listAcct'] = "urn:accounting_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com"
19
- soap.namespaces['xmlns:actSched'] = "urn:scheduling_#{NetSuite::Configuration.api_version}.activities.webservices.netsuite.com"
20
- soap.namespaces['xmlns:tranCust'] = "urn:customers_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com"
21
- soap.namespaces['xmlns:setupCustom'] = "urn:customization_#{NetSuite::Configuration.api_version}.setup.webservices.netsuite.com"
22
- soap.header = auth_header
23
- soap.body = request_body
24
- end
12
+ NetSuite::Configuration.connection(
13
+ namespaces: {
14
+ 'xmlns:platformMsgs' => "urn:messages_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
15
+ 'xmlns:platformCore' => "urn:core_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
16
+ 'xmlns:listRel' => "urn:relationships_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com",
17
+ 'xmlns:tranSales' => "urn:sales_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com",
18
+ 'xmlns:platformCommon' => "urn:common_#{NetSuite::Configuration.api_version}.platform.webservices.netsuite.com",
19
+ 'xmlns:listAcct' => "urn:accounting_#{NetSuite::Configuration.api_version}.lists.webservices.netsuite.com",
20
+ 'xmlns:actSched' => "urn:scheduling_#{NetSuite::Configuration.api_version}.activities.webservices.netsuite.com",
21
+ 'xmlns:tranCust' => "urn:customers_#{NetSuite::Configuration.api_version}.transactions.webservices.netsuite.com",
22
+ 'xmlns:setupCustom' => "urn:customization_#{NetSuite::Configuration.api_version}.setup.webservices.netsuite.com",
23
+ },
24
+ ).call :update, :message => request_body
25
25
  end
26
26
 
27
27
  # <platformMsgs:update>
@@ -38,12 +38,15 @@ module NetSuite
38
38
  }
39
39
  }
40
40
  }
41
+
41
42
  if updated_record.respond_to?(:internal_id) && updated_record.internal_id
42
43
  hash[:attributes!]['platformMsgs:record']['platformMsgs:internalId'] = updated_record.internal_id
43
44
  end
45
+
44
46
  if updated_record.respond_to?(:external_id) && updated_record.external_id
45
47
  hash[:attributes!]['platformMsgs:record']['platformMsgs:externalId'] = updated_record.external_id
46
48
  end
49
+
47
50
  hash
48
51
  end
49
52
 
@@ -10,13 +10,15 @@ module NetSuite
10
10
  @attributes ||= {}
11
11
  end
12
12
 
13
- def connection
14
- unless attributes[:connection]
15
- attributes[:connection] = Savon::Client.new(self.wsdl)
16
- attributes[:connection].http.read_timeout = read_timeout
17
- end
18
-
19
- attributes[:connection]
13
+ def connection(params = {})
14
+ Savon.client({
15
+ wsdl: wsdl,
16
+ read_timeout: read_timeout,
17
+ soap_header: auth_header,
18
+ pretty_print_xml: true,
19
+ logger: logger
20
+ # open_timeout: ???
21
+ }.merge(params))
20
22
  end
21
23
 
22
24
  def api_version(version = nil)
@@ -152,7 +154,7 @@ module NetSuite
152
154
  end
153
155
 
154
156
  def logger
155
- attributes[:logger] ||= NetSuite::XmlLogger.new (log && !log.empty?) ? log : STDOUT
157
+ attributes[:logger] ||= ::Logger.new (log && !log.empty?) ? log : $stdout
156
158
  end
157
159
 
158
160
  end
@@ -16,24 +16,6 @@ module NetSuite
16
16
  attributes[:value]
17
17
  end
18
18
 
19
- def to_record
20
- hash_rec = attributes.inject({}) do |hash, (k,v)|
21
- kname = "#{record_namespace}:#{k.to_s.lower_camelcase}"
22
- to_attributes!(hash, kname, v)
23
- v = v.to_record if v.respond_to?(:to_record)
24
- hash[kname] = v
25
- hash
26
- end
27
- hash_rec
28
- end
29
-
30
- def attributes!
31
- attr_hash = {}
32
- attr_hash['internalId'] = internal_id if internal_id
33
- attr_hash['xsi:type'] = type if type
34
- attr_hash
35
- end
36
-
37
19
  end
38
20
  end
39
21
  end
@@ -30,14 +30,18 @@ module NetSuite
30
30
  end
31
31
 
32
32
  def to_record
33
- custom_fields.map { |custom_field|
34
- Gyoku.xml({
35
- "#{record_namespace}:customField" => custom_field.to_record,
36
- :attributes! => {
37
- "#{record_namespace}:customField" => custom_field.attributes!
33
+ # TODO this is the best way I could find to handle this, there *has* to be a better way
34
+ # http://stackoverflow.com/questions/7001957/savon-array-of-xml-tags
35
+
36
+ {
37
+ "#{record_namespace}:customField" => custom_fields.map(&:to_record),
38
+ :attributes! => {
39
+ "#{record_namespace}:customField" => {
40
+ 'internalId' => custom_fields.map(&:internal_id),
41
+ 'xsi:type' => custom_fields.map(&:type)
38
42
  }
39
- })
40
- }.join
43
+ }
44
+ }
41
45
  end
42
46
 
43
47
  private
@@ -41,9 +41,9 @@ module NetSuite
41
41
  def self.type_id(id = nil)
42
42
  if id
43
43
  @type_id = id
44
- else
45
- @type_id
46
44
  end
45
+
46
+ @type_id
47
47
  end
48
48
 
49
49
  def record_type
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListRel
9
9
 
10
- actions :get, :add, :delete, :search
10
+ actions :get, :add, :update, :delete, :search
11
11
 
12
12
  fields :access_role, :account_number, :aging, :alt_email, :alt_name, :alt_phone, :bill_pay,
13
13
  :buying_reason, :buying_time_frame, :campaign_category, :category, :click_stream, :comments, :company_name,
@@ -17,7 +17,7 @@ module NetSuite
17
17
  :estimated_budget, :fax, :fax_transactions, :first_name, :first_visit, :give_access, :global_subscription_status,
18
18
  :group_pricing_list, :home_phone, :image, :is_budget_approved, :is_inactive, :is_person, :item_pricing_list, :keywords,
19
19
  :language, :last_modified, :last_name, :last_page_visited, :last_visit, :lead_source, :middle_name, :mobile_phone,
20
- :opening_balance, :opening_balance_account, :opening_balance_date, :parent, :partner, :partners_list,
20
+ :opening_balance, :opening_balance_account, :opening_balance_date, :parent, :partners_list,
21
21
  :password, :password_2, :phone, :phonetic_name, :pref_cc_processor, :price_level, :print_on_check_as,
22
22
  :print_transactions, :referrer, :reminder_days, :representing_subsidiary, :require_pwd_change, :resale_number,
23
23
  :sales_group, :sales_readiness, :sales_rep, :sales_team_list, :salutation, :send_email, :ship_complete, :shipping_item,
@@ -31,7 +31,7 @@ module NetSuite
31
31
  read_only_fields :balance, :consol_balance, :deposit_balance, :consol_deposit_balance, :overdue_balance,
32
32
  :consol_overdue_balance, :unbilled_orders, :consol_unbilled_orders
33
33
 
34
- record_refs :custom_form, :entity_status
34
+ record_refs :custom_form, :entity_status, :partner
35
35
 
36
36
  attr_reader :internal_id
37
37
  attr_accessor :external_id
@@ -12,12 +12,13 @@ module NetSuite
12
12
  fields :auth_code, :auto_apply, :cc_approved, :cc_avs_street_match, :cc_avs_zip_match,
13
13
  :cc_expire_date, :cc_name, :cc_number, :cc_security_code, :cc_security_code_match, :cc_street, :cc_zip_code,
14
14
  :charge_it, :check_num, :created_date, :currency_name, :debit_card_issue_no, :exchange_rate, :ignore_avs,
15
- :last_modified_date, :memo, :payment, :pending, :pn_ref_num, :status, :three_d_status_code, :tran_date,
15
+ :last_modified_date, :memo, :payment, :pn_ref_num, :status, :three_d_status_code, :tran_date,
16
16
  :undep_funds, :valid_from
17
17
 
18
18
  field :custom_field_list, CustomFieldList
19
+ field :apply_list, CustomerPaymentApplyList
19
20
 
20
- read_only_fields :applied, :balance, :total, :unapplied
21
+ read_only_fields :applied, :balance, :pending, :total, :unapplied
21
22
 
22
23
  record_refs :account, :ar_acct, :credit_card, :credit_card_processor, :custom_form, :customer, :department, :klass,
23
24
  :location, :payment_method, :posting_period, :subsidiary
@@ -0,0 +1,17 @@
1
+ module NetSuite
2
+ module Records
3
+ class CustomerPaymentApply
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranCust
7
+
8
+ fields :amount, :apply, :apply_date, :currency, :disc, :disc_amt, :disc_date,
9
+ :doc, :due, :job, :line, :ref_num, :total, :type
10
+
11
+ def initialize(attributes = {})
12
+ initialize_from_attributes_hash(attributes)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ module NetSuite
2
+ module Records
3
+ class CustomerPaymentApplyList
4
+ include Namespaces::TranCust
5
+
6
+ def initialize(attributes = {})
7
+ case attributes[:apply]
8
+ when Hash
9
+ applies << CustomerPaymentApply.new(attributes[:apply])
10
+ when Array
11
+ attributes[:apply].each { |apply| applies << CustomerPaymentApply.new(apply) }
12
+ end
13
+ end
14
+
15
+ def applies
16
+ @applies ||= []
17
+ end
18
+
19
+ def to_record
20
+ applies.map do |apply|
21
+ { "#{record_namespace}:apply" => apply.to_record }
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -9,7 +9,7 @@ module NetSuite
9
9
 
10
10
  actions :get, :initialize, :add, :delete
11
11
 
12
- fields :alt_handling_cost, :balance, :bill_address,
12
+ fields :balance, :bill_address,
13
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,
@@ -20,7 +20,7 @@ module NetSuite
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
22
  :lead_source, :linked_tracking_numbers, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
23
- :other_ref_name, :partner, :partners_list, :promo_code, :rev_rec_end_date,
23
+ :other_ref_name, :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
25
  :sales_group, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
26
26
  :shipping_cost, :shipping_tax_1_rate, :shipping_tax_2_rate, :shipping_tax_code, :source, :start_date,
@@ -36,9 +36,9 @@ module NetSuite
36
36
  field :custom_field_list, CustomFieldList
37
37
 
38
38
  read_only_fields :sub_total, :discount_total, :total, :recognized_revenue, :amount_remaining, :amount_paid,
39
- :alt_shipping_cost, :gift_cert_applied, :tax_rate, :handling_cost
39
+ :alt_shipping_cost, :gift_cert_applied, :tax_rate, :handling_cost, :alt_handling_cost
40
40
 
41
- record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass,
41
+ record_refs :account, :bill_address_list, :custom_form, :department, :entity, :klass, :partner,
42
42
  :posting_period, :ship_address_list, :terms, :location, :sales_rep, :tax_item, :created_from,
43
43
  :ship_method
44
44
 
@@ -0,0 +1,43 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillment
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
11
+
12
+ fields :tran_date, :tran_id, :shipping_cost, :memo, :ship_company, :ship_attention, :ship_addr1,
13
+ :ship_addr2, :ship_city, :ship_state, :ship_zip, :ship_phone, :ship_is_residential
14
+
15
+ read_only_fields :handling_cost
16
+
17
+ record_refs :custom_form, :entity, :created_from, :ship_carrier, :ship_method,
18
+ :ship_address_list, :klass, :ship_country
19
+
20
+ field :transaction_ship_address, ShipAddress
21
+ field :item_list, ItemFulfillmentItemList
22
+ field :custom_field_list, CustomFieldList
23
+
24
+ attr_reader :internal_id
25
+ attr_accessor :external_id
26
+
27
+ def initialize(attributes = {})
28
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
29
+ @external_id = attributes.delete(:external_id) || attributes.delete(:@external_id)
30
+ initialize_from_attributes_hash(attributes)
31
+ end
32
+
33
+ def to_record
34
+ rec = super
35
+ if rec["#{record_namespace}:customFieldList"]
36
+ rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
37
+ end
38
+ rec
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,45 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentItem
4
+ include Support::Fields
5
+ include Support::RecordRefs
6
+ include Support::Records
7
+ include Namespaces::TranSales
8
+
9
+ fields :amount, :amount_ordered, :bin_numbers, :cost_estimate, :cost_estimate_type, :current_percent,
10
+ :defer_rev_rec, :description, :gift_cert_from, :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email,
11
+ :gift_cert_recipient_name, :gross_amt, :inventory_detail, :is_taxable, :item_is_fulfilled, :license_code, :line,
12
+ :klass, :options, :order_line, :percent_complete, :quantity, :quantity_available, :quantity_fulfilled,
13
+ :quantity_on_hand, :quantity_ordered, :rate, :rev_rec_end_date, :rev_rec_start_date,
14
+ :serial_numbers, :ship_group, :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral,
15
+ :vsoe_delivered, :vsoe_permit_discount, :vsoe_price, :item_receive
16
+
17
+ field :custom_field_list, CustomFieldList
18
+
19
+ read_only_fields :quantity_remaining
20
+
21
+ record_refs :department, :item, :job, :location, :price, :rev_rec_schedule, :ship_address, :ship_method, :tax_code, :units, :klass
22
+
23
+ def initialize(attributes_or_record = {})
24
+ case attributes_or_record
25
+ when Hash
26
+ initialize_from_attributes_hash(attributes_or_record)
27
+ when self.class
28
+ initialize_from_record(attributes_or_record)
29
+ end
30
+ end
31
+
32
+ def initialize_from_record(record)
33
+ self.attributes = record.send(:attributes)
34
+ end
35
+
36
+ def to_record
37
+ rec = super
38
+ if rec["#{record_namespace}:customFieldList"]
39
+ rec["#{record_namespace}:customFieldList!"] = rec.delete("#{record_namespace}:customFieldList")
40
+ end
41
+ rec
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentItemList
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 << ItemFulfillmentItem.new(items)
17
+ when Array
18
+ items.each { |item| self.items << ItemFulfillmentItem.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
@@ -9,7 +9,7 @@ module NetSuite
9
9
  fields :amount, :bin_numbers, :cost_estimate, :cost_estimate_type, :defer_rev_rec, :description, :gift_cert_from,
10
10
  :gift_cert_message, :gift_cert_number, :gift_cert_recipient_email, :gift_cert_recipient_name, :gross_amt, :is_taxable,
11
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,
12
+ :shipping_cost, :tax1_amt, :tax_rate1, :tax_rate2, :vsoe_allocation, :vsoe_amount, :vsoe_deferral, :vsoe_delivered,
13
13
  :vsoe_permit_discount, :vsoe_price
14
14
 
15
15
  field :custom_field_list, CustomFieldList
@@ -10,11 +10,13 @@ module NetSuite
10
10
  kname += k == :klass ? 'class' : k.to_s.lower_camelcase
11
11
 
12
12
  to_attributes!(hash, kname, v)
13
+
13
14
  if Array === v
14
15
  v = v.map { |i| i.respond_to?(:to_record) ? i.to_record : i }
15
- else
16
- v = v.to_record if v.respond_to?(:to_record)
16
+ elsif v.respond_to?(:to_record)
17
+ v = v.to_record
17
18
  end
19
+
18
20
  hash[kname] = v
19
21
  hash
20
22
  end
@@ -25,14 +25,6 @@ module NetSuite
25
25
  raise NotImplementedError, 'Please implement a #request method'
26
26
  end
27
27
 
28
- def connection
29
- Configuration.connection
30
- end
31
-
32
- def auth_header
33
- Configuration.auth_header
34
- end
35
-
36
28
  def build_response
37
29
  Response.new(:success => success?, header: response_header, :body => response_body)
38
30
  end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.50'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -15,10 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ['lib']
16
16
  gem.version = Netsuite::VERSION
17
17
 
18
- gem.add_dependency 'savon', '~> 1.2.0'
19
- gem.add_dependency 'nokogiri', '~> 1.5.0'
18
+ gem.add_dependency 'savon', '~> 2.2.0'
20
19
 
21
- gem.add_development_dependency 'rspec', '~> 2.10'
22
- gem.add_development_dependency 'savon_spec', '~> 1.3.0'
23
- gem.add_development_dependency 'autotest-standalone', '~> 4.5'
20
+ gem.add_development_dependency 'rspec', '~> 2.10'
24
21
  end
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Actions::Add do
4
+ before(:all) { savon.mock! }
5
+ after(:all) { savon.unmock! }
4
6
 
5
7
  context 'Customer' do
6
8
  let(:customer) do
@@ -8,7 +10,7 @@ describe NetSuite::Actions::Add do
8
10
  end
9
11
 
10
12
  before do
11
- savon.expects(:add).with({
13
+ savon.expects(:add).with(:message => {
12
14
  'platformMsgs:record' => {
13
15
  'listRel:entityId' => 'Shutter Fly',
14
16
  'listRel:companyName' => 'Shutter Fly, Inc.'
@@ -18,7 +20,7 @@ describe NetSuite::Actions::Add do
18
20
  'xsi:type' => 'listRel:Customer'
19
21
  }
20
22
  }
21
- }).returns(:add_customer)
23
+ }).returns(File.read('spec/support/fixtures/add/add_customer.xml'))
22
24
  end
23
25
 
24
26
  it 'makes a valid request to the NetSuite API' do
@@ -38,7 +40,7 @@ describe NetSuite::Actions::Add do
38
40
  end
39
41
 
40
42
  before do
41
- savon.expects(:add).with({
43
+ savon.expects(:add).with(:message => {
42
44
  'platformMsgs:record' => {
43
45
  'tranSales:source' => 'Google'
44
46
  },
@@ -47,7 +49,7 @@ describe NetSuite::Actions::Add do
47
49
  'xsi:type' => 'tranSales:Invoice'
48
50
  }
49
51
  }
50
- }).returns(:add_invoice)
52
+ }).returns(File.read('spec/support/fixtures/add/add_invoice.xml'))
51
53
  end
52
54
 
53
55
  it 'makes a valid request to the NetSuite API' do
@@ -1,6 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Actions::Delete do
4
+ before(:all) { savon.mock! }
5
+ after(:all) { savon.unmock! }
4
6
 
5
7
  context 'Customer' do
6
8
  let(:customer) do
@@ -8,7 +10,7 @@ describe NetSuite::Actions::Delete do
8
10
  end
9
11
 
10
12
  before do
11
- savon.expects(:delete).with({
13
+ savon.expects(:delete).with(:message => {
12
14
  'platformMsgs:baseRef' => {},
13
15
  :attributes! => {
14
16
  'platformMsgs:baseRef' => {
@@ -17,7 +19,7 @@ describe NetSuite::Actions::Delete do
17
19
  'xsi:type' => 'platformCore:RecordRef'
18
20
  }
19
21
  }
20
- }).returns(:delete_customer)
22
+ }).returns(File.read('spec/support/fixtures/delete/delete_customer.xml'))
21
23
  end
22
24
 
23
25
  it 'makes a valid request to the NetSuite API' do
@@ -1,10 +1,12 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Actions::Get do
4
+ before(:all) { savon.mock! }
5
+ after(:all) { savon.unmock! }
4
6
 
5
7
  describe 'Customer' do
6
8
  before do
7
- savon.expects(:get).with({
9
+ message = {
8
10
  'platformMsgs:baseRef' => {},
9
11
  :attributes! => {
10
12
  'platformMsgs:baseRef' => {
@@ -13,7 +15,9 @@ describe NetSuite::Actions::Get do
13
15
  'xsi:type' => 'platformCore:RecordRef'
14
16
  }
15
17
  }
16
- }).returns(:get_customer)
18
+ }
19
+
20
+ savon.expects(:get).with(:message => message).returns(File.read('spec/support/fixtures/get/get_customer.xml'))
17
21
  end
18
22
 
19
23
  it 'makes a valid request to the NetSuite API' do
@@ -28,7 +32,7 @@ describe NetSuite::Actions::Get do
28
32
 
29
33
  describe 'Invoice' do
30
34
  before do
31
- savon.expects(:get).with({
35
+ savon.expects(:get).with(:message => {
32
36
  'platformMsgs:baseRef' => {},
33
37
  :attributes! => {
34
38
  'platformMsgs:baseRef' => {
@@ -37,7 +41,7 @@ describe NetSuite::Actions::Get do
37
41
  'xsi:type' => 'platformCore:RecordRef'
38
42
  }
39
43
  }
40
- }).returns(:get_invoice)
44
+ }).returns(File.read('spec/support/fixtures/get/get_invoice.xml'))
41
45
  end
42
46
 
43
47
  it 'makes a valid request to the NetSuite API' do
@@ -1,10 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Actions::Initialize do
4
+ before(:all) { savon.mock! }
5
+ after(:all) { savon.unmock! }
6
+
4
7
  let(:customer) { NetSuite::Records::Customer.new(:internal_id => 1) }
5
8
 
6
9
  before do
7
- savon.expects(:initialize).with({
10
+ savon.expects(:initialize).with(:message => {
8
11
  'platformMsgs:initializeRecord' => {
9
12
  'platformCore:type' => 'customer',
10
13
  'platformCore:reference' => {},
@@ -15,7 +18,7 @@ describe NetSuite::Actions::Initialize do
15
18
  }
16
19
  }
17
20
  }
18
- }).returns(:initialize_invoice_from_customer)
21
+ }).returns(File.read('spec/support/fixtures/initialize/initialize_invoice_from_customer.xml'))
19
22
  end
20
23
 
21
24
  it 'makes a valid request to the NetSuite API' do
@@ -1,13 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Actions::Update do
4
+ before(:all) { savon.mock! }
5
+ after(:all) { savon.unmock! }
4
6
 
5
7
  context 'Customer' do
6
8
  let(:customer) { NetSuite::Records::Customer.new }
7
9
  let(:attributes) { { :entity_id => 'Shutter Fly', :company_name => 'Shutter Fly, Inc.' } }
8
10
 
9
11
  before do
10
- savon.expects(:update).with({
12
+ savon.expects(:update).with(:message => {
11
13
  'platformMsgs:record' => {
12
14
  'listRel:entityId' => 'Shutter Fly',
13
15
  'listRel:companyName' => 'Shutter Fly, Inc.'
@@ -17,7 +19,7 @@ describe NetSuite::Actions::Update do
17
19
  'xsi:type' => 'listRel:Customer'
18
20
  }
19
21
  }
20
- }).returns(:update_customer)
22
+ }).returns(File.read('spec/support/fixtures/update/update_customer.xml'))
21
23
  end
22
24
 
23
25
  it 'makes a valid request to the NetSuite API' do
@@ -36,7 +38,7 @@ describe NetSuite::Actions::Update do
36
38
  let(:attributes) { { :source => 'Google', :total => 100.0 } }
37
39
 
38
40
  before do
39
- savon.expects(:update).with({
41
+ savon.expects(:update).with(:message => {
40
42
  'platformMsgs:record' => {
41
43
  'tranSales:source' => 'Google',
42
44
  },
@@ -45,7 +47,7 @@ describe NetSuite::Actions::Update do
45
47
  'xsi:type' => 'tranSales:Invoice'
46
48
  }
47
49
  }
48
- }).returns(:update_invoice)
50
+ }).returns(File.read('spec/support/fixtures/update/update_invoice.xml'))
49
51
  end
50
52
 
51
53
  it 'makes a valid request to the NetSuite API' do
@@ -18,6 +18,11 @@ describe NetSuite::Configuration do
18
18
 
19
19
  describe '#connection' do
20
20
  it 'returns a Savon::Client object that allows requests to the service' do
21
+ # reset clears out the password info
22
+ config.email 'me@example.com'
23
+ config.password 'me@example.com'
24
+ config.account 1023
25
+
21
26
  config.connection.should be_kind_of(Savon::Client)
22
27
  end
23
28
  end
@@ -17,7 +17,15 @@ describe NetSuite::Records::CustomFieldList do
17
17
  end
18
18
 
19
19
  it 'can represent itself as a SOAP record' do
20
- record = "<platformCore:customField internalId=\"3\" xsi:type=\"BooleanCustomFieldRef\"><platformCore:value>false</platformCore:value></platformCore:customField>"
20
+ record = [
21
+ {
22
+ "platformCore:customField" => {"platformCore:value"=>false},
23
+ :attributes! => {
24
+ "platformCore:customField" => {"internalId"=>"3", "xsi:type"=>"BooleanCustomFieldRef"}
25
+ }
26
+ }
27
+ ]
28
+
21
29
  list.to_record.should eql(record)
22
30
  end
23
31
  end
@@ -14,7 +14,7 @@ describe NetSuite::Records::Customer do
14
14
  :estimated_budget, :fax, :fax_transactions, :first_name, :first_visit, :give_access, :global_subscription_status,
15
15
  :group_pricing_list, :home_phone, :image, :is_budget_approved, :is_inactive, :is_person, :item_pricing_list, :keywords,
16
16
  :language, :last_modified, :last_name, :last_page_visited, :last_visit, :lead_source, :middle_name, :mobile_phone,
17
- :opening_balance, :opening_balance_account, :opening_balance_date, :overdue_balance, :parent, :partner, :partners_list,
17
+ :opening_balance, :opening_balance_account, :opening_balance_date, :overdue_balance, :parent, :partners_list,
18
18
  :password, :password_2, :phone, :phonetic_name, :pref_cc_processor, :price_level, :print_on_check_as,
19
19
  :print_transactions, :referrer, :reminder_days, :representing_subsidiary, :require_pwd_change, :resale_number,
20
20
  :sales_group, :sales_readiness, :sales_rep, :sales_team_list, :salutation, :send_email, :ship_complete, :shipping_item,
@@ -28,7 +28,7 @@ describe NetSuite::Records::Customer do
28
28
 
29
29
  it 'has the right record_refs' do
30
30
  [
31
- :custom_form, :entity_status
31
+ :custom_form, :entity_status, :partner
32
32
  ].each do |record_ref|
33
33
  customer.should have_record_ref(record_ref)
34
34
  end
@@ -7,22 +7,22 @@ describe NetSuite::Records::Invoice do
7
7
 
8
8
  it 'has all the right fields' do
9
9
  [
10
- :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :balance, :bill_address,
10
+ :balance, :bill_address,
11
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,
15
15
  :exp_cost_disc_taxable, :exp_cost_discount, :exp_cost_list, :exp_cost_tax_code, :exp_cost_tax_rate_1,
16
- :exp_cost_tax_rate_2, :fax, :fob, :gift_cert_applied, :gift_cert_redemption_list, :handling_cost, :handling_tax_1_rate,
16
+ :exp_cost_tax_rate_2, :fax, :fob, :gift_cert_redemption_list, :handling_tax_1_rate,
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
20
  :lead_source, :linked_tracking_numbers, :memo, :message, :message_sel, :on_credit_hold, :opportunity,
21
- :other_ref_name, :partner, :partners_list, :promo_code, :recognized_revenue, :rev_rec_end_date,
21
+ :other_ref_name, :partners_list, :promo_code, :rev_rec_end_date,
22
22
  :rev_rec_on_rev_commitment, :rev_rec_schedule, :rev_rec_start_date, :revenue_status, :sales_effective_date,
23
23
  :sales_group, :sales_team_list, :ship_address, :ship_date, :ship_group_list,
24
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,
25
+ :status, :subsidiary, :sync_partner_teams, :sync_sales_teams, :tax_2_total,
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,
@@ -34,7 +34,8 @@ describe NetSuite::Records::Invoice do
34
34
 
35
35
  it 'has all the right read_only_fields' do
36
36
  [
37
- :sub_total, :discount_total, :total
37
+ :sub_total, :discount_total, :total, :alt_handling_cost, :alt_shipping_cost, :gift_cert_applied, :tax_rate,
38
+ :handling_cost, :recognized_revenue, :amount_remaining, :amount_paid
38
39
  ].each do |field|
39
40
  NetSuite::Records::Invoice.should have_read_only_field(field)
40
41
  end
@@ -43,7 +44,7 @@ describe NetSuite::Records::Invoice do
43
44
  it 'has the right record_refs' do
44
45
  [
45
46
  :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
47
+ :created_from, :location, :sales_rep, :ship_method, :tax_item, :partner
47
48
  ].each do |record_ref|
48
49
  invoice.should have_record_ref(record_ref)
49
50
  end
@@ -1,9 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..') ))
2
2
 
3
3
  require 'rspec'
4
- require 'rspec/autorun'
5
4
  require 'netsuite'
6
- require 'savon_spec'
7
5
 
8
6
  # Requires supporting ruby files with custom matchers and macros, etc,
9
7
  # in spec/support/ and its subdirectories.
@@ -1,7 +1,5 @@
1
+ require "savon/mock/spec_helper"
2
+
1
3
  RSpec.configure do |config|
2
- config.include Savon::Spec::Macros
3
- end
4
- Savon::Spec::Fixture.path = File.expand_path('../fixtures', __FILE__)
5
- Savon.configure do |config|
6
- config.log = false
7
- end
4
+ config.include Savon::SpecHelper
5
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.50
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Moran
@@ -10,14 +10,14 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-04-04 00:00:00.000000000 Z
13
+ date: 2013-04-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  version_requirements: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 1.2.0
20
+ version: 2.2.0
21
21
  none: false
22
22
  name: savon
23
23
  type: :runtime
@@ -26,23 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.2.0
30
- none: false
31
- - !ruby/object:Gem::Dependency
32
- version_requirements: !ruby/object:Gem::Requirement
33
- requirements:
34
- - - ~>
35
- - !ruby/object:Gem::Version
36
- version: 1.5.0
37
- none: false
38
- name: nokogiri
39
- type: :runtime
40
- prerelease: false
41
- requirement: !ruby/object:Gem::Requirement
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 1.5.0
29
+ version: 2.2.0
46
30
  none: false
47
31
  - !ruby/object:Gem::Dependency
48
32
  version_requirements: !ruby/object:Gem::Requirement
@@ -60,38 +44,6 @@ dependencies:
60
44
  - !ruby/object:Gem::Version
61
45
  version: '2.10'
62
46
  none: false
63
- - !ruby/object:Gem::Dependency
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: 1.3.0
69
- none: false
70
- name: savon_spec
71
- type: :development
72
- prerelease: false
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 1.3.0
78
- none: false
79
- - !ruby/object:Gem::Dependency
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - ~>
83
- - !ruby/object:Gem::Version
84
- version: '4.5'
85
- none: false
86
- name: autotest-standalone
87
- type: :development
88
- prerelease: false
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ~>
92
- - !ruby/object:Gem::Version
93
- version: '4.5'
94
- none: false
95
47
  description: NetSuite SuiteTalk API Wrapper
96
48
  email:
97
49
  - ryan.moran@gmail.com
@@ -149,6 +101,8 @@ files:
149
101
  - lib/netsuite/records/customer_addressbook.rb
150
102
  - lib/netsuite/records/customer_addressbook_list.rb
151
103
  - lib/netsuite/records/customer_payment.rb
104
+ - lib/netsuite/records/customer_payment_apply.rb
105
+ - lib/netsuite/records/customer_payment_apply_list.rb
152
106
  - lib/netsuite/records/customer_refund.rb
153
107
  - lib/netsuite/records/customer_refund_apply.rb
154
108
  - lib/netsuite/records/customer_refund_apply_list.rb
@@ -160,6 +114,9 @@ files:
160
114
  - lib/netsuite/records/invoice.rb
161
115
  - lib/netsuite/records/invoice_item.rb
162
116
  - lib/netsuite/records/invoice_item_list.rb
117
+ - lib/netsuite/records/item_fulfillment.rb
118
+ - lib/netsuite/records/item_fulfillment_item.rb
119
+ - lib/netsuite/records/item_fulfillment_item_list.rb
163
120
  - lib/netsuite/records/job.rb
164
121
  - lib/netsuite/records/journal_entry.rb
165
122
  - lib/netsuite/records/journal_entry_line.rb
@@ -187,7 +144,6 @@ files:
187
144
  - lib/netsuite/support/requests.rb
188
145
  - lib/netsuite/support/search_result.rb
189
146
  - lib/netsuite/version.rb
190
- - lib/netsuite/xml_logger.rb
191
147
  - netsuite.gemspec
192
148
  - spec/netsuite/actions/add_spec.rb
193
149
  - spec/netsuite/actions/delete_spec.rb
@@ -1,31 +0,0 @@
1
- require 'logger'
2
-
3
- module NetSuite
4
- class XmlLogger < ::Logger
5
-
6
- def format_message(severity, timestamp, progname, msg)
7
- if msg.match('<?xml') && !(msg.match('SOAPAction'))
8
- xp(msg)
9
- else
10
- "#{msg}\n"
11
- end
12
- end
13
-
14
- def xp(xml_text)
15
- xsl = <<-XSL
16
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
17
- <xsl:output method="xml" encoding="UTF-8" indent="yes"/>
18
- <xsl:strip-space elements="*"/>
19
- <xsl:template match="/">
20
- <xsl:copy-of select="."/>
21
- </xsl:template>
22
- </xsl:stylesheet>
23
- XSL
24
- doc = Nokogiri::XML(xml_text)
25
- xslt = Nokogiri::XSLT(xsl)
26
- out = xslt.transform(doc)
27
- out.to_xml
28
- end
29
-
30
- end
31
- end