netsuite 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,6 +26,7 @@ require 'netsuite/actions/initialize'
26
26
 
27
27
  # RECORDS
28
28
  require 'netsuite/records/bill_address'
29
+ require 'netsuite/records/custom_field'
29
30
  require 'netsuite/records/custom_field_list'
30
31
  require 'netsuite/records/customer'
31
32
  require 'netsuite/records/customer_addressbook'
@@ -0,0 +1,30 @@
1
+ module NetSuite
2
+ module Records
3
+ class CustomField
4
+ include Support::Fields
5
+ include Support::Records
6
+
7
+ attr_reader :internal_id, :type
8
+
9
+ def initialize(attributes = {})
10
+ @internal_id = attributes.delete(:internal_id) || attributes.delete(:@internal_id)
11
+ @type = attributes.delete(:type) || attributes.delete(:"@xsi:type")
12
+ @type = @type.split(':').last if @type
13
+ self.attributes = attributes
14
+ end
15
+
16
+ def to_record
17
+ hash_rec = attributes.inject({}) do |hash, (k,v)|
18
+ kname = "#{record_namespace}:#{k.to_s.lower_camelcase}"
19
+ v = v.to_record if v.respond_to?(:to_record)
20
+ hash[kname] = v
21
+ hash
22
+ end
23
+ hash_rec["#{record_namespace}:internalId"] = internal_id if internal_id
24
+ hash_rec["#{record_namespace}:type"] = type if type
25
+ hash_rec
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -1,6 +1,24 @@
1
1
  module NetSuite
2
2
  module Records
3
3
  class CustomFieldList
4
+ include Namespaces::PlatformCore
5
+
6
+ def initialize(attributes = {})
7
+ case attributes[:custom_field]
8
+ when Hash
9
+ custom_fields << CustomField.new(attributes[:custom_field])
10
+ when Array
11
+ attributes[:custom_field].each { |custom_field| custom_fields << CustomField.new(addressbook) }
12
+ end
13
+ end
14
+
15
+ def custom_fields
16
+ @custom_fields ||= []
17
+ end
18
+
19
+ def to_record
20
+ { "#{record_namespace}:customField" => custom_fields.map(&:to_record) }
21
+ end
4
22
 
5
23
  end
6
24
  end
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Namespaces::TranSales
8
8
 
9
9
  fields :alt_handling_cost, :alt_shipping_cost, :amount_paid, :amount_remaining, :balance, :bill_address,
10
- :billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name,
10
+ :billing_schedule, :contrib_pct, :created_date, :created_from, :currency_name, :custom_field_list,
11
11
  :deferred_revenue, :department, :discount_amount, :discount_date, :discount_item, :discount_rate,
12
12
  :due_date, :email, :end_date, :est_gross_profit, :est_gross_profit_percent, :exchange_rate,
13
13
  :exclude_commission, :exp_cost_disc_amount, :exp_cost_disc_print, :exp_cost_disc_rate, :exp_cost_disc_tax_1_amt,
@@ -56,6 +56,10 @@ module NetSuite
56
56
  attributes[:custom_field_list] ||= CustomFieldList.new
57
57
  end
58
58
 
59
+ def custom_field_list=(attrs)
60
+ attributes[:custom_field_list] = CustomFieldList.new(attrs)
61
+ end
62
+
59
63
  def self.get(id)
60
64
  response = Actions::Get.call(id, self)
61
65
  if response.success?
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
@@ -1,5 +1,19 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe NetSuite::Records::CustomFieldList do
4
- pending
4
+ let(:list) { NetSuite::Records::CustomFieldList.new }
5
+
6
+ it 'has a custom_fields attribute' do
7
+ list.custom_fields.should be_kind_of(Array)
8
+ end
9
+
10
+ describe '#to_record' do
11
+ it 'can represent itself as a SOAP record' do
12
+ record = {
13
+ 'platformCore:customField' => []
14
+ }
15
+ list.to_record.should eql(record)
16
+ end
17
+ end
18
+
5
19
  end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Records::CustomField do
4
+ pending
5
+ 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: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 14
10
- version: 0.0.14
9
+ - 15
10
+ version: 0.0.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -112,6 +112,7 @@ files:
112
112
  - lib/netsuite/namespaces/tran_sales.rb
113
113
  - lib/netsuite/records/bill_address.rb
114
114
  - lib/netsuite/records/classification.rb
115
+ - lib/netsuite/records/custom_field.rb
115
116
  - lib/netsuite/records/custom_field_list.rb
116
117
  - lib/netsuite/records/customer.rb
117
118
  - lib/netsuite/records/customer_addressbook.rb
@@ -137,6 +138,7 @@ files:
137
138
  - spec/netsuite/records/bill_address_spec.rb
138
139
  - spec/netsuite/records/classification_spec.rb
139
140
  - spec/netsuite/records/custom_field_list_spec.rb
141
+ - spec/netsuite/records/custom_field_spec.rb
140
142
  - spec/netsuite/records/customer_addressbook_list_spec.rb
141
143
  - spec/netsuite/records/customer_addressbook_spec.rb
142
144
  - spec/netsuite/records/customer_spec.rb
@@ -206,6 +208,7 @@ test_files:
206
208
  - spec/netsuite/records/bill_address_spec.rb
207
209
  - spec/netsuite/records/classification_spec.rb
208
210
  - spec/netsuite/records/custom_field_list_spec.rb
211
+ - spec/netsuite/records/custom_field_spec.rb
209
212
  - spec/netsuite/records/customer_addressbook_list_spec.rb
210
213
  - spec/netsuite/records/customer_addressbook_spec.rb
211
214
  - spec/netsuite/records/customer_spec.rb