netsuite 0.0.10 → 0.0.11

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 (48) hide show
  1. data/lib/netsuite.rb +17 -6
  2. data/lib/netsuite/actions/add.rb +7 -4
  3. data/lib/netsuite/actions/get.rb +1 -1
  4. data/lib/netsuite/actions/initialize.rb +1 -1
  5. data/lib/netsuite/namespaces/list_acct.rb +11 -0
  6. data/lib/netsuite/namespaces/list_rel.rb +11 -0
  7. data/lib/netsuite/namespaces/platform_common.rb +11 -0
  8. data/lib/netsuite/namespaces/platform_core.rb +11 -0
  9. data/lib/netsuite/namespaces/tran_sales.rb +11 -0
  10. data/lib/netsuite/records/bill_address.rb +3 -1
  11. data/lib/netsuite/records/classification.rb +27 -0
  12. data/lib/netsuite/records/customer.rb +4 -3
  13. data/lib/netsuite/records/customer_addressbook_list.rb +3 -2
  14. data/lib/netsuite/records/invoice.rb +18 -15
  15. data/lib/netsuite/records/invoice_item.rb +34 -0
  16. data/lib/netsuite/records/invoice_item_list.rb +11 -12
  17. data/lib/netsuite/records/non_inventory_sale_item.rb +4 -2
  18. data/lib/netsuite/records/record_ref.rb +8 -2
  19. data/lib/netsuite/records/ship_address.rb +3 -1
  20. data/lib/netsuite/support/attributes.rb +22 -0
  21. data/lib/netsuite/support/fields.rb +54 -0
  22. data/lib/netsuite/support/record_refs.rb +33 -0
  23. data/lib/netsuite/support/records.rb +40 -0
  24. data/lib/netsuite/{savon_support.rb → support/requests.rb} +2 -2
  25. data/lib/netsuite/version.rb +1 -1
  26. data/spec/netsuite/records/bill_address_spec.rb +37 -0
  27. data/spec/netsuite/records/classification_spec.rb +37 -0
  28. data/spec/netsuite/records/customer_addressbook_list_spec.rb +53 -28
  29. data/spec/netsuite/records/invoice_item_list_spec.rb +13 -13
  30. data/spec/netsuite/records/invoice_item_spec.rb +58 -0
  31. data/spec/netsuite/records/invoice_spec.rb +33 -83
  32. data/spec/netsuite/records/non_inventory_sale_item_spec.rb +21 -0
  33. data/spec/netsuite/records/record_ref_spec.rb +26 -0
  34. data/spec/netsuite/records/ship_address_spec.rb +21 -0
  35. data/spec/netsuite/support/attributes_spec.rb +5 -0
  36. data/spec/netsuite/support/fields_spec.rb +60 -0
  37. data/spec/netsuite/support/record_refs_spec.rb +5 -0
  38. data/spec/netsuite/{record_support_spec.rb → support/records_spec.rb} +6 -5
  39. data/spec/netsuite/{savon_support_spec.rb → support/requests_spec.rb} +2 -2
  40. data/spec/support/read_only_field_matcher.rb +7 -0
  41. metadata +32 -19
  42. data/lib/netsuite/attribute_support.rb +0 -16
  43. data/lib/netsuite/field_support.rb +0 -36
  44. data/lib/netsuite/record_ref_support.rb +0 -31
  45. data/lib/netsuite/record_support.rb +0 -17
  46. data/spec/netsuite/attribute_support_spec.rb +0 -5
  47. data/spec/netsuite/field_support_spec.rb +0 -34
  48. data/spec/netsuite/record_ref_support_spec.rb +0 -5
@@ -61,4 +61,25 @@ describe NetSuite::Records::NonInventorySaleItem do
61
61
  end
62
62
  end
63
63
 
64
+ describe '#to_record' do
65
+ before do
66
+ item.handling_cost = 100.0
67
+ item.is_online = true
68
+ end
69
+
70
+ it 'can represent itself as a SOAP record' do
71
+ record = {
72
+ 'listAcct:handlingCost' => 100.0,
73
+ 'listAcct:isOnline' => true
74
+ }
75
+ item.to_record.should eql(record)
76
+ end
77
+ end
78
+
79
+ describe '#record_type' do
80
+ it 'returns a string of the SOAP type' do
81
+ item.record_type.should eql('listAcct:NonInventorySaleItem')
82
+ end
83
+ end
84
+
64
85
  end
@@ -58,4 +58,30 @@ describe NetSuite::Records::RecordRef do
58
58
  end
59
59
  end
60
60
 
61
+ describe 'initialize from record' do
62
+ it 'initializes a new ref with the proper attributes from the record' do
63
+ record = NetSuite::Records::Classification.new(:is_inactive => false, :name => 'Retail', :internal_id => '9')
64
+ record_ref = NetSuite::Records::RecordRef.new(record)
65
+ record_ref.should be_kind_of(NetSuite::Records::RecordRef)
66
+ record_ref.internal_id.should eql('9')
67
+ record_ref.type.should eql('classification')
68
+ end
69
+ end
70
+
71
+ describe '#to_record' do
72
+ it 'can represent itself as a SOAP record' do
73
+ record_ref = NetSuite::Records::RecordRef.new(:something => 'blah')
74
+ record = {
75
+ 'platformCore:something' => 'blah'
76
+ }
77
+ record_ref.to_record.should eql(record)
78
+ end
79
+ end
80
+
81
+ describe '#record_type' do
82
+ it 'returns a string of the SOAP type' do
83
+ record_ref.record_type.should eql('platformCore:RecordRef')
84
+ end
85
+ end
86
+
61
87
  end
@@ -12,4 +12,25 @@ describe NetSuite::Records::ShipAddress do
12
12
  end
13
13
  end
14
14
 
15
+ describe '#to_record' do
16
+ before do
17
+ ship_address.ship_attention = 'Mr. Smith'
18
+ ship_address.ship_zip = '90007'
19
+ end
20
+
21
+ it 'can represent itself as a SOAP record' do
22
+ record = {
23
+ 'platformCommon:shipAttention' => 'Mr. Smith',
24
+ 'platformCommon:shipZip' => '90007'
25
+ }
26
+ ship_address.to_record.should eql(record)
27
+ end
28
+ end
29
+
30
+ describe '#record_type' do
31
+ it 'returns a string of the SOAP record type' do
32
+ ship_address.record_type.should eql('platformCommon:ShipAddress')
33
+ end
34
+ end
35
+
15
36
  end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Support::Attributes do
4
+ pending
5
+ end
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Support::Fields do
4
+ let(:klass) { Class.new.send(:include, NetSuite::Support::Fields) }
5
+ let(:instance) { klass.new }
6
+
7
+ describe '.fields' do
8
+ context 'with arguments' do
9
+ it 'calls .field with each argument passed to it' do
10
+ [:one, :two, :three].each do |field|
11
+ klass.should_receive(:field).with(field)
12
+ end
13
+ klass.fields(:one, :two, :three)
14
+ end
15
+ end
16
+
17
+ context 'without arguments' do
18
+ it 'returns a Set of the field arguments' do
19
+ arguments = [:one, :two, :three]
20
+ klass.fields(*arguments)
21
+ klass.fields.should eql(Set.new(arguments))
22
+ end
23
+ end
24
+ end
25
+
26
+ describe '.field' do
27
+ it 'defines instance accessor methods for the given field' do
28
+ klass.field(:one)
29
+ instance.one = 1
30
+ instance.one.should eql(1)
31
+ end
32
+ end
33
+
34
+ describe '.read_only_fields' do
35
+ context 'with arguments' do
36
+ it 'calls .read_only_field with each argument passed to it' do
37
+ [:one, :two, :three].each do |field|
38
+ klass.should_receive(:read_only_field).with(field)
39
+ end
40
+ klass.read_only_fields(:one, :two, :three)
41
+ end
42
+ end
43
+
44
+ context 'without arguments' do
45
+ it 'returns a Set of the read_only_field arguments' do
46
+ arguments = [:one, :two, :three]
47
+ klass.read_only_fields(*arguments)
48
+ klass.read_only_fields.should eql(Set.new(arguments))
49
+ end
50
+ end
51
+ end
52
+
53
+ describe '.read_only_field' do
54
+ it 'defines instance accessor methods for the given field' do
55
+ klass.should_receive(:field).with(:one)
56
+ klass.read_only_field(:one)
57
+ end
58
+ end
59
+
60
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Support::RecordRefs do
4
+ pending
5
+ end
@@ -3,7 +3,8 @@ require 'spec_helper'
3
3
  module Foo
4
4
  module Bar
5
5
  class Baz
6
- include NetSuite::RecordSupport
6
+ include NetSuite::Support::Fields
7
+ include NetSuite::Support::Records
7
8
 
8
9
  def attributes
9
10
  { :source => 'Google', :total => 100.0 }
@@ -12,21 +13,21 @@ module Foo
12
13
  end
13
14
  end
14
15
 
15
- describe NetSuite::RecordSupport do
16
+ describe NetSuite::Support::Records do
16
17
  let(:instance) { Foo::Bar::Baz.new }
17
18
 
18
19
  describe '#record_type' do
19
20
  it 'returns a hash of attributes to be used in a SOAP request' do
20
21
  instance.to_record.should eql({
21
- 'listRel:source' => 'Google',
22
- 'listRel:total' => 100.0
22
+ 'platformCore:source' => 'Google',
23
+ 'platformCore:total' => 100.0
23
24
  })
24
25
  end
25
26
  end
26
27
 
27
28
  describe '#record_type' do
28
29
  it 'returns a string of the record type to be used in a SOAP request' do
29
- instance.record_type.should eql('listRel:Baz')
30
+ instance.record_type.should eql('platformCore:Baz')
30
31
  end
31
32
  end
32
33
 
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe NetSuite::Actions::SavonSupport do
3
+ describe NetSuite::Support::Requests do
4
4
  let(:instance) do
5
5
  obj = Object.new
6
- obj.extend(NetSuite::Actions::SavonSupport)
6
+ obj.extend(NetSuite::Support::Requests)
7
7
  obj
8
8
  end
9
9
 
@@ -0,0 +1,7 @@
1
+ RSpec::Matchers.define :have_read_only_field do |attribute|
2
+
3
+ match do |model|
4
+ model.read_only_fields.include?(attribute).should be_true
5
+ end
6
+
7
+ 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: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 10
10
- version: 0.0.10
9
+ - 11
10
+ version: 0.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Moran
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-10 00:00:00 Z
18
+ date: 2012-01-11 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon
@@ -103,42 +103,51 @@ files:
103
103
  - lib/netsuite/actions/add.rb
104
104
  - lib/netsuite/actions/get.rb
105
105
  - lib/netsuite/actions/initialize.rb
106
- - lib/netsuite/attribute_support.rb
107
106
  - lib/netsuite/configuration.rb
108
107
  - lib/netsuite/errors.rb
109
- - lib/netsuite/field_support.rb
110
- - lib/netsuite/record_ref_support.rb
111
- - lib/netsuite/record_support.rb
108
+ - lib/netsuite/namespaces/list_acct.rb
109
+ - lib/netsuite/namespaces/list_rel.rb
110
+ - lib/netsuite/namespaces/platform_common.rb
111
+ - lib/netsuite/namespaces/platform_core.rb
112
+ - lib/netsuite/namespaces/tran_sales.rb
112
113
  - lib/netsuite/records/bill_address.rb
114
+ - lib/netsuite/records/classification.rb
113
115
  - lib/netsuite/records/customer.rb
114
116
  - lib/netsuite/records/customer_addressbook_list.rb
115
117
  - lib/netsuite/records/invoice.rb
118
+ - lib/netsuite/records/invoice_item.rb
116
119
  - lib/netsuite/records/invoice_item_list.rb
117
120
  - lib/netsuite/records/non_inventory_sale_item.rb
118
121
  - lib/netsuite/records/record_ref.rb
119
122
  - lib/netsuite/records/ship_address.rb
120
123
  - lib/netsuite/response.rb
121
- - lib/netsuite/savon_support.rb
124
+ - lib/netsuite/support/attributes.rb
125
+ - lib/netsuite/support/fields.rb
126
+ - lib/netsuite/support/record_refs.rb
127
+ - lib/netsuite/support/records.rb
128
+ - lib/netsuite/support/requests.rb
122
129
  - lib/netsuite/version.rb
123
130
  - netsuite.gemspec
124
131
  - spec/netsuite/actions/add_spec.rb
125
132
  - spec/netsuite/actions/get_spec.rb
126
133
  - spec/netsuite/actions/initialize_spec.rb
127
- - spec/netsuite/attribute_support_spec.rb
128
134
  - spec/netsuite/configuration_spec.rb
129
- - spec/netsuite/field_support_spec.rb
130
- - spec/netsuite/record_ref_support_spec.rb
131
- - spec/netsuite/record_support_spec.rb
132
135
  - spec/netsuite/records/bill_address_spec.rb
136
+ - spec/netsuite/records/classification_spec.rb
133
137
  - spec/netsuite/records/customer_addressbook_list_spec.rb
134
138
  - spec/netsuite/records/customer_spec.rb
135
139
  - spec/netsuite/records/invoice_item_list_spec.rb
140
+ - spec/netsuite/records/invoice_item_spec.rb
136
141
  - spec/netsuite/records/invoice_spec.rb
137
142
  - spec/netsuite/records/non_inventory_sale_item_spec.rb
138
143
  - spec/netsuite/records/record_ref_spec.rb
139
144
  - spec/netsuite/records/ship_address_spec.rb
140
145
  - spec/netsuite/response_spec.rb
141
- - spec/netsuite/savon_support_spec.rb
146
+ - spec/netsuite/support/attributes_spec.rb
147
+ - spec/netsuite/support/fields_spec.rb
148
+ - spec/netsuite/support/record_refs_spec.rb
149
+ - spec/netsuite/support/records_spec.rb
150
+ - spec/netsuite/support/requests_spec.rb
142
151
  - spec/netsuite_spec.rb
143
152
  - spec/spec_helper.rb
144
153
  - spec/support/configuration.rb
@@ -148,6 +157,7 @@ files:
148
157
  - spec/support/fixtures/get/get_customer.xml
149
158
  - spec/support/fixtures/get/get_invoice.xml
150
159
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml
160
+ - spec/support/read_only_field_matcher.rb
151
161
  - spec/support/record_ref_matcher.rb
152
162
  - spec/support/savon.rb
153
163
  - wsdl/2011_02.wsdl
@@ -188,21 +198,23 @@ test_files:
188
198
  - spec/netsuite/actions/add_spec.rb
189
199
  - spec/netsuite/actions/get_spec.rb
190
200
  - spec/netsuite/actions/initialize_spec.rb
191
- - spec/netsuite/attribute_support_spec.rb
192
201
  - spec/netsuite/configuration_spec.rb
193
- - spec/netsuite/field_support_spec.rb
194
- - spec/netsuite/record_ref_support_spec.rb
195
- - spec/netsuite/record_support_spec.rb
196
202
  - spec/netsuite/records/bill_address_spec.rb
203
+ - spec/netsuite/records/classification_spec.rb
197
204
  - spec/netsuite/records/customer_addressbook_list_spec.rb
198
205
  - spec/netsuite/records/customer_spec.rb
199
206
  - spec/netsuite/records/invoice_item_list_spec.rb
207
+ - spec/netsuite/records/invoice_item_spec.rb
200
208
  - spec/netsuite/records/invoice_spec.rb
201
209
  - spec/netsuite/records/non_inventory_sale_item_spec.rb
202
210
  - spec/netsuite/records/record_ref_spec.rb
203
211
  - spec/netsuite/records/ship_address_spec.rb
204
212
  - spec/netsuite/response_spec.rb
205
- - spec/netsuite/savon_support_spec.rb
213
+ - spec/netsuite/support/attributes_spec.rb
214
+ - spec/netsuite/support/fields_spec.rb
215
+ - spec/netsuite/support/record_refs_spec.rb
216
+ - spec/netsuite/support/records_spec.rb
217
+ - spec/netsuite/support/requests_spec.rb
206
218
  - spec/netsuite_spec.rb
207
219
  - spec/spec_helper.rb
208
220
  - spec/support/configuration.rb
@@ -212,5 +224,6 @@ test_files:
212
224
  - spec/support/fixtures/get/get_customer.xml
213
225
  - spec/support/fixtures/get/get_invoice.xml
214
226
  - spec/support/fixtures/initialize/initialize_invoice_from_customer.xml
227
+ - spec/support/read_only_field_matcher.rb
215
228
  - spec/support/record_ref_matcher.rb
216
229
  - spec/support/savon.rb
@@ -1,16 +0,0 @@
1
- module NetSuite
2
- module AttributeSupport
3
-
4
- def attributes
5
- @attributes ||= {}
6
- end
7
- private :attributes
8
-
9
- def initialize_from_attributes_hash(attributes = {})
10
- Hash[attributes.select { |k,v| self.class.fields.include?(k) }].each do |k,v|
11
- send("#{k}=", v)
12
- end
13
- end
14
-
15
- end
16
- end
@@ -1,36 +0,0 @@
1
- module NetSuite
2
- module FieldSupport
3
- include AttributeSupport
4
-
5
- def self.included(base)
6
- base.send(:extend, ClassMethods)
7
- end
8
-
9
- module ClassMethods
10
-
11
- def fields(*args)
12
- if args.empty?
13
- @fields ||= Set.new
14
- else
15
- args.each do |arg|
16
- field arg
17
- end
18
- end
19
- end
20
-
21
- def field(name)
22
- name_sym = name.to_sym
23
- fields << name_sym
24
- define_method(name_sym) do
25
- attributes[name_sym]
26
- end
27
-
28
- define_method("#{name_sym}=") do |value|
29
- attributes[name_sym] = value
30
- end
31
- end
32
-
33
- end
34
-
35
- end
36
- end
@@ -1,31 +0,0 @@
1
- module NetSuite
2
- module RecordRefSupport
3
-
4
- def self.included(base)
5
- base.extend(ClassMethods)
6
- end
7
-
8
- module ClassMethods
9
-
10
- def record_refs(*names)
11
- names.each do |name|
12
- record_ref name
13
- end
14
- end
15
-
16
- def record_ref(name)
17
- name_sym = name.to_sym
18
- fields << name_sym
19
- define_method "#{name}=" do |attrs|
20
- attributes[name_sym] = NetSuite::Records::RecordRef.new(attrs)
21
- end
22
-
23
- define_method name_sym do
24
- attributes[name_sym]
25
- end
26
- end
27
-
28
- end
29
-
30
- end
31
- end
@@ -1,17 +0,0 @@
1
- module NetSuite
2
- module RecordSupport
3
- include AttributeSupport
4
-
5
- def to_record
6
- attributes.inject({}) do |hash, (k,v)|
7
- hash.store("listRel:#{k.to_s.lower_camelcase}", v)
8
- hash
9
- end
10
- end
11
-
12
- def record_type
13
- "listRel:#{self.class.to_s.split('::').last}"
14
- end
15
-
16
- end
17
- end