netsuite 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/netsuite/actions/add.rb +1 -0
- data/lib/netsuite/actions/delete.rb +20 -6
- data/lib/netsuite/actions/update.rb +2 -0
- data/lib/netsuite/records/custom_record.rb +5 -2
- data/lib/netsuite/support/actions.rb +6 -2
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/records/custom_record_spec.rb +2 -2
- metadata +4 -4
data/lib/netsuite/actions/add.rb
CHANGED
@@ -18,6 +18,7 @@ module NetSuite
|
|
18
18
|
soap.namespaces['xmlns:platformCommon'] = 'urn:common_2011_2.platform.webservices.netsuite.com'
|
19
19
|
soap.namespaces['xmlns:listAcct'] = 'urn:accounting_2011_2.lists.webservices.netsuite.com'
|
20
20
|
soap.namespaces['xmlns:tranCust'] = 'urn:customers_2011_2.transactions.webservices.netsuite.com'
|
21
|
+
soap.namespaces['xmlns:setupCustom'] = 'urn:customization_2011_2.setup.webservices.netsuite.com'
|
21
22
|
soap.header = auth_header
|
22
23
|
soap.body = request_body
|
23
24
|
end
|
@@ -3,8 +3,9 @@ module NetSuite
|
|
3
3
|
class Delete
|
4
4
|
include Support::Requests
|
5
5
|
|
6
|
-
def initialize(object = nil)
|
7
|
-
@object
|
6
|
+
def initialize(object = nil, options = {})
|
7
|
+
@object = object
|
8
|
+
@options = options
|
8
9
|
end
|
9
10
|
|
10
11
|
private
|
@@ -18,22 +19,35 @@ module NetSuite
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
22
|
+
def soap_type
|
23
|
+
@object.class.to_s.split('::').last.lower_camelcase
|
24
|
+
end
|
25
|
+
|
21
26
|
# <soap:Body>
|
22
27
|
# <platformMsgs:delete>
|
23
28
|
# <platformMsgs:baseRef internalId="980" type="customer" xsi:type="platformCore:RecordRef"/>
|
24
29
|
# </platformMsgs:delete>
|
25
30
|
# </soap:Body>
|
26
31
|
def request_body
|
27
|
-
{
|
32
|
+
body = {
|
28
33
|
'platformMsgs:baseRef' => {},
|
29
34
|
:attributes! => {
|
30
35
|
'platformMsgs:baseRef' => {
|
31
|
-
'
|
32
|
-
'type' => @object.class.to_s.split('::').last.lower_camelcase,
|
33
|
-
'xsi:type' => 'platformCore:RecordRef'
|
36
|
+
'xsi:type' => (@options[:custom] ? 'platformCore:CustomRecordRef' : 'platformCore:RecordRef')
|
34
37
|
}
|
35
38
|
}
|
36
39
|
}
|
40
|
+
if @object.respond_to?(:external_id) && @object.external_id
|
41
|
+
body[:attributes!]['platformMsgs:baseRef']['externalId'] = @object.external_id
|
42
|
+
end
|
43
|
+
if @object.respond_to?(:internal_id) && @object.internal_id
|
44
|
+
body[:attributes!]['platformMsgs:baseRef']['internalId'] = @object.internal_id
|
45
|
+
end
|
46
|
+
if @object.class.respond_to?(:type_id) && @object.class.type_id
|
47
|
+
body[:attributes!]['platformMsgs:baseRef']['typeId'] = @object.class.type_id
|
48
|
+
end
|
49
|
+
body[:attributes!]['platformMsgs:baseRef']['type'] = soap_type unless @options[:custom]
|
50
|
+
body
|
37
51
|
end
|
38
52
|
|
39
53
|
def response_hash
|
@@ -16,6 +16,8 @@ module NetSuite
|
|
16
16
|
soap.namespaces['xmlns:tranSales'] = 'urn:sales_2011_2.transactions.webservices.netsuite.com'
|
17
17
|
soap.namespaces['xmlns:platformCommon'] = 'urn:common_2011_2.platform.webservices.netsuite.com'
|
18
18
|
soap.namespaces['xmlns:listAcct'] = 'urn:accounting_2011_2.lists.webservices.netsuite.com'
|
19
|
+
soap.namespaces['xmlns:tranCust'] = 'urn:customers_2011_2.transactions.webservices.netsuite.com'
|
20
|
+
soap.namespaces['xmlns:setupCustom'] = 'urn:customization_2011_2.setup.webservices.netsuite.com'
|
19
21
|
soap.header = auth_header
|
20
22
|
soap.body = request_body
|
21
23
|
end
|
@@ -31,8 +31,11 @@ module NetSuite
|
|
31
31
|
|
32
32
|
def self.get(options = {})
|
33
33
|
options.merge!(:type_id => type_id) unless options[:type_id]
|
34
|
-
options.merge
|
35
|
-
|
34
|
+
super(options.merge(:custom => true))
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete
|
38
|
+
super(:custom => true)
|
36
39
|
end
|
37
40
|
|
38
41
|
def self.type_id(id = nil)
|
@@ -77,8 +77,12 @@ module NetSuite
|
|
77
77
|
|
78
78
|
def define_delete(instance_module)
|
79
79
|
instance_module.module_eval do
|
80
|
-
define_method :delete do
|
81
|
-
response =
|
80
|
+
define_method :delete do |*options|
|
81
|
+
response = if options.empty?
|
82
|
+
NetSuite::Actions::Delete.call(self)
|
83
|
+
else
|
84
|
+
NetSuite::Actions::Delete.call(self, *options)
|
85
|
+
end
|
82
86
|
response.success?
|
83
87
|
end
|
84
88
|
end
|
data/lib/netsuite/version.rb
CHANGED
@@ -102,7 +102,7 @@ describe NetSuite::Records::CustomRecord do
|
|
102
102
|
|
103
103
|
it 'returns true' do
|
104
104
|
NetSuite::Actions::Delete.should_receive(:call).
|
105
|
-
with(record).
|
105
|
+
with(record, { :custom => true }).
|
106
106
|
and_return(response)
|
107
107
|
record.delete.should be_true
|
108
108
|
end
|
@@ -113,7 +113,7 @@ describe NetSuite::Records::CustomRecord do
|
|
113
113
|
|
114
114
|
it 'returns false' do
|
115
115
|
NetSuite::Actions::Delete.should_receive(:call).
|
116
|
-
with(record).
|
116
|
+
with(record, { :custom => true }).
|
117
117
|
and_return(response)
|
118
118
|
record.delete.should be_false
|
119
119
|
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:
|
4
|
+
hash: 39
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 28
|
10
|
+
version: 0.0.28
|
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-
|
18
|
+
date: 2012-01-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: savon
|