netsuite 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ODNjODA3MjM1ZDkyNWJkYWZkZWQ3NWIxNTFiMDJjODYxNzY0MWJiYw==
5
- data.tar.gz: !binary |-
6
- ZmE3YTNhMjRhNTRiZmRiY2Q5MzJkMDJkYWNkNWI0MzY5MTcyY2QyZg==
2
+ SHA1:
3
+ metadata.gz: 06cedbc327be3be9dc71bbed933d03cf7351f7bc
4
+ data.tar.gz: 468fd51d45565c586380bea58c8013d0070c8050
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZjBlOGYzODFkNzg3NjQxZTdlYmExMmRmNmRkMzI5YzBkMDFiYjAzOWQ5ZWMw
10
- YTIyNWRkYWQ5Y2MxNjNmNGNkYmJkZDM5ZDllMjc1YWJkZTk4MjM2MzZhMjU4
11
- NmJhYjQyYmVmZmJjMjkzN2UwMzYwM2QzMTk1YjE1Nzk4NWNmODg=
12
- data.tar.gz: !binary |-
13
- YjZiZDAxYWY5ZWRkNjg4OTY0NWIxYzY1MjUxYzQwZjdjZDEzM2FmNjM3ZGYw
14
- NmMxNzQxYzQ5OTcxYmNhNzgwNjJiMjQwNzc0ZGVhOTE0MzA3ODJiOTMxMzcz
15
- ZTA4Mjk5MjU3MzdlMGViYjg4OTRiZWE5YWY4ZjY4YzJjOWZkMTU=
6
+ metadata.gz: ab0c469a17de1c1c98fb793f7f986c0cbb6c10848d065f63b2b7865e3af1a5d245a7c24d4871929eafc0aee92a003bc3a26eaf8e688db91f66d3ed7c5137ead2
7
+ data.tar.gz: 4ffdda3b662d8bd0937fb0b0a58072da952a61dcb162f2dac8a1d55c5b3a3e8481b0ede1c9417724646c708481b5f6477fe9e208bfa4cecdad8c590b67fe7a4c
data/README.md CHANGED
@@ -256,7 +256,13 @@ NetSuite::Configuration.connection.call :get_customization_id, message: {
256
256
 
257
257
  server_time_response = NetSuite::Configuration.connection.call :get_server_time
258
258
  server_time_response.body[:get_server_time_response][:get_server_time_result][:server_time]
259
- ```
260
-
261
-
262
259
 
260
+ # using get_select_value with a custom record
261
+ NetSuite::Records::BaseRefList.get_select_value(
262
+ field: 'custrecord_something',
263
+ customRecordType: {
264
+ '@internalId' => 10,
265
+ '@xsi:type' => 'customRecord'
266
+ }
267
+ )
268
+ ```
@@ -86,6 +86,8 @@ module NetSuite
86
86
  autoload :ItemFulfillment, 'netsuite/records/item_fulfillment'
87
87
  autoload :ItemFulfillmentItem, 'netsuite/records/item_fulfillment_item'
88
88
  autoload :ItemFulfillmentItemList, 'netsuite/records/item_fulfillment_item_list'
89
+ autoload :ItemFulfillmentPackage, 'netsuite/records/item_fulfillment_package'
90
+ autoload :ItemFulfillmentPackageList, 'netsuite/records/item_fulfillment_package_list'
89
91
  autoload :Job, 'netsuite/records/job'
90
92
  autoload :JournalEntry, 'netsuite/records/journal_entry'
91
93
  autoload :JournalEntryLine, 'netsuite/records/journal_entry_line'
@@ -93,6 +95,7 @@ module NetSuite
93
95
  autoload :KitItem, 'netsuite/records/kit_item'
94
96
  autoload :Location, 'netsuite/records/location'
95
97
  autoload :LocationsList, 'netsuite/records/locations_list'
98
+ autoload :MatrixOptionList, 'netsuite/records/matrix_option_list'
96
99
  autoload :NonInventorySaleItem, 'netsuite/records/non_inventory_sale_item'
97
100
  autoload :PaymentMethod, 'netsuite/records/payment_method'
98
101
  autoload :PhoneCall, 'netsuite/records/phone_call'
@@ -18,6 +18,14 @@ module NetSuite
18
18
  def custom_fields
19
19
  @custom_fields ||= []
20
20
  end
21
+
22
+ # In case you want to get only MultiSelectCustomFieldRef for example:
23
+ #
24
+ # list.custom_fields_by_type "MultiSelectCustomFieldRef"
25
+ #
26
+ def custom_fields_by_type(type)
27
+ custom_fields.select { |field| field.type == "platformCore:#{type}" }
28
+ end
21
29
 
22
30
  def method_missing(sym, *args, &block)
23
31
  # read custom field if already set
@@ -43,6 +51,8 @@ module NetSuite
43
51
  "#{record_namespace}:customField" => custom_fields.map do |custom_field|
44
52
  if custom_field.value.respond_to?(:to_record)
45
53
  custom_field_value = custom_field.value.to_record
54
+ elsif custom_field.value.is_a?(Array)
55
+ custom_field_value = custom_field.value.map(&:to_record)
46
56
  else
47
57
  custom_field_value = custom_field.value.to_s
48
58
  end
@@ -69,6 +79,8 @@ module NetSuite
69
79
  def create_custom_field(internal_id, field_value)
70
80
  # all custom fields need types; infer type based on class sniffing
71
81
  field_type = case
82
+ when field_value.is_a?(Array)
83
+ 'MultiSelectCustomFieldRef'
72
84
  when field_value.is_a?(Hash)
73
85
  'SelectCustomFieldRef'
74
86
  when field_value.is_a?(DateTime),
@@ -90,6 +102,17 @@ module NetSuite
90
102
  CustomRecordRef.new(field_value)
91
103
  when field_value.is_a?(Time)
92
104
  field_value.iso8601
105
+ when field_value.is_a?(Array)
106
+ # sniff the first element of the array; if an int or string then assume internalId
107
+ # and create record refs pointing to the given IDs
108
+
109
+ if !field_value.empty? && (field_value.first.is_a?(String) || field_value.first.kind_of?(Integer))
110
+ field_value.map do |v|
111
+ NetSuite::Records::CustomRecordRef.new(internal_id: v)
112
+ end
113
+ else
114
+ field_value
115
+ end
93
116
  else
94
117
  field_value
95
118
  end
@@ -57,6 +57,7 @@ module NetSuite
57
57
  field :custom_field_list, CustomFieldList
58
58
  field :bin_number_list, BinNumberList
59
59
  field :locations_list, LocationsList
60
+ field :matrix_option_list, MatrixOptionList
60
61
 
61
62
  attr_reader :internal_id
62
63
  attr_accessor :external_id
@@ -19,6 +19,7 @@ module NetSuite
19
19
 
20
20
  field :transaction_ship_address, ShipAddress
21
21
  field :item_list, ItemFulfillmentItemList
22
+ field :package_list, ItemFulfillmentPackageList
22
23
  field :custom_field_list, CustomFieldList
23
24
 
24
25
  attr_reader :internal_id
@@ -0,0 +1,24 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentPackage
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranSales
7
+
8
+ fields :package_weight, :package_descr, :package_tracking_number
9
+
10
+ def initialize(attributes_or_record = {})
11
+ case attributes_or_record
12
+ when Hash
13
+ initialize_from_attributes_hash(attributes_or_record)
14
+ when self.class
15
+ initialize_from_record(attributes_or_record)
16
+ end
17
+ end
18
+
19
+ def initialize_from_record(record)
20
+ self.attributes = record.send(:attributes)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ module NetSuite
2
+ module Records
3
+ class ItemFulfillmentPackageList
4
+ include Support::Fields
5
+ include Support::Records
6
+ include Namespaces::TranSales
7
+
8
+ fields :item
9
+
10
+ def initialize(attributes = {})
11
+ initialize_from_attributes_hash(attributes)
12
+ end
13
+
14
+ def item=(items)
15
+ case items
16
+ when Hash
17
+ self.items << ItemFulfillmentPackage.new(items)
18
+ when Array
19
+ items.each { |item| self.items << ItemFulfillmentPackage.new(item) }
20
+ end
21
+ end
22
+
23
+ def items
24
+ @items ||= []
25
+ end
26
+
27
+ def to_record
28
+ { "#{record_namespace}:package" => items.map(&:to_record) }
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,18 @@
1
+ module NetSuite
2
+ module Records
3
+ class MatrixOptionList
4
+ def initialize(attributes = {})
5
+ attributes[:matrix_option].each do |option|
6
+ options << OpenStruct.new(
7
+ type_id: option[:value][:'@type_id'],
8
+ value_id: option[:value][:'@internal_id']
9
+ )
10
+ end if attributes[:matrix_option]
11
+ end
12
+
13
+ def options
14
+ @options ||= []
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -7,6 +7,24 @@ describe NetSuite::Records::CustomFieldList do
7
7
  list.custom_fields.should be_kind_of(Array)
8
8
  end
9
9
 
10
+ context 'writing convience methods' do
11
+ it "should create a custom field entry when none exists" do
12
+ list.custrecord_somefield = 'a value'
13
+ list.custom_fields.size.should == 1
14
+ list.custom_fields.first.value.should == 'a value'
15
+ list.custom_fields.first.type.should == 'platformCore:StringCustomFieldRef'
16
+ end
17
+
18
+ it "should convert a list of numbers into a list of custom field refs" do
19
+ list.custrecord_somefield = [1,2]
20
+ list.custom_fields.first.type.should == 'platformCore:MultiSelectCustomFieldRef'
21
+ list.custom_fields.first.value.map(&:to_record).should eql([
22
+ NetSuite::Records::CustomRecordRef.new(:internal_id => 1),
23
+ NetSuite::Records::CustomRecordRef.new(:internal_id => 2)
24
+ ].map(&:to_record))
25
+ end
26
+ end
27
+
10
28
  describe '#to_record' do
11
29
  before do
12
30
  list.custom_fields << NetSuite::Records::CustomField.new(
@@ -22,25 +40,23 @@ describe NetSuite::Records::CustomFieldList do
22
40
  end
23
41
 
24
42
  it 'can represent itself as a SOAP record' do
25
- record = [
26
- {
27
- "platformCore:customField" => {
43
+ record = {
44
+ "platformCore:customField" => [
45
+ {
46
+ 'platformCore:value' => 'false',
28
47
  "@internalId" => "custentity_registeredonline",
29
48
  "@xsi:type" => "BooleanCustomFieldRef",
30
- :content! => { "platformCore:value" => false }
31
- }
32
- },
33
- {
34
- "platformCore:customField" => {
49
+ },
50
+ {
35
51
  '@internalId' => 'custbody_salesclassification',
36
- '@xsi:type' => 'BooleanCustomFieldRef',
37
- :content! => { "platformCore:value" => true }
52
+ '@xsi:type' => 'SelectCustomFieldRef',
53
+ "platformCore:value"=>{"platformCore:name"=>"The Name", :@internalId=>13}
38
54
  }
39
- }
40
- ]
55
+ ]
56
+ }
41
57
 
42
58
  list.to_record.should eql(record)
43
- list.to_record.length.should == 2
59
+ list.to_record.length.should == 1
44
60
  end
45
61
  end
46
62
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netsuite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moran
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-03 00:00:00.000000000 Z
12
+ date: 2014-02-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: 2.3.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 2.3.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rspec
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '2.10'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '2.10'
42
42
  description: NetSuite SuiteTalk API Wrapper
@@ -47,9 +47,8 @@ executables: []
47
47
  extensions: []
48
48
  extra_rdoc_files: []
49
49
  files:
50
- - .autotest
51
- - .gitignore
52
- - .rspec
50
+ - ".gitignore"
51
+ - ".rspec"
53
52
  - Gemfile
54
53
  - LICENSE
55
54
  - README.md
@@ -118,6 +117,8 @@ files:
118
117
  - lib/netsuite/records/item_fulfillment.rb
119
118
  - lib/netsuite/records/item_fulfillment_item.rb
120
119
  - lib/netsuite/records/item_fulfillment_item_list.rb
120
+ - lib/netsuite/records/item_fulfillment_package.rb
121
+ - lib/netsuite/records/item_fulfillment_package_list.rb
121
122
  - lib/netsuite/records/job.rb
122
123
  - lib/netsuite/records/journal_entry.rb
123
124
  - lib/netsuite/records/journal_entry_line.rb
@@ -125,6 +126,7 @@ files:
125
126
  - lib/netsuite/records/kit_item.rb
126
127
  - lib/netsuite/records/location.rb
127
128
  - lib/netsuite/records/locations_list.rb
129
+ - lib/netsuite/records/matrix_option_list.rb
128
130
  - lib/netsuite/records/non_inventory_sale_item.rb
129
131
  - lib/netsuite/records/payment_method.rb
130
132
  - lib/netsuite/records/phone_call.rb
@@ -238,17 +240,17 @@ require_paths:
238
240
  - lib
239
241
  required_ruby_version: !ruby/object:Gem::Requirement
240
242
  requirements:
241
- - - ! '>='
243
+ - - ">="
242
244
  - !ruby/object:Gem::Version
243
245
  version: '0'
244
246
  required_rubygems_version: !ruby/object:Gem::Requirement
245
247
  requirements:
246
- - - ! '>='
248
+ - - ">="
247
249
  - !ruby/object:Gem::Version
248
250
  version: '0'
249
251
  requirements: []
250
252
  rubyforge_project:
251
- rubygems_version: 2.1.11
253
+ rubygems_version: 2.2.0
252
254
  signing_key:
253
255
  specification_version: 4
254
256
  summary: NetSuite SuiteTalk API Wrapper
data/.autotest DELETED
@@ -1,9 +0,0 @@
1
- Autotest.add_hook :initialize do |at|
2
- at.clear_mappings
3
-
4
- at.add_mapping(%r%^lib/(.*)\.rb$%) do |_, m|
5
- at.files_matching %r%^spec/#{m[1]}_spec\.rb$%
6
- end
7
-
8
- at.add_mapping(%r%^spec/.*\_spec\.rb$%) { |filename, _| filename }
9
- end