netsuite 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest CHANGED
@@ -1,10 +1,9 @@
1
1
  Autotest.add_hook :initialize do |at|
2
2
  at.clear_mappings
3
3
 
4
- at.add_mapping %r%/^lib/(.*)\.rb$% do |_, m|
5
- possible = File.basename(m[1])
6
- files_matching %r%^spec/.*(#{possible}_spec)\.rb$%
4
+ at.add_mapping(%r%^lib/(.*)\.rb$%) do |_, m|
5
+ at.files_matching %r%^spec/#{m[1]}_spec\.rb$%
7
6
  end
8
7
 
9
- at.add_mapping(%r%^spec/.*\_spec.rb$%) {|filename, _| filename }
8
+ at.add_mapping(%r%^spec/.*\_spec\.rb$%) { |filename, _| filename }
10
9
  end
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ree-1.8.7-2010.02@netsuite
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Netsuite
2
2
 
3
- TODO: Write a gem description
3
+ * This gem will act as a wrapper around the NetSuite SuiteTalk WebServices API. Wow, that is a mouthful.
4
+ * The gem does not cover the entire API, only the subset that we have found useful to cover so far.
5
+ * [Extending the wrapper](#extending) is pretty simple. See below for an example.
4
6
 
5
7
  ## Installation
6
8
 
@@ -18,7 +20,70 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
21
- TODO: Write usage instructions here
23
+ ### Customer
24
+
25
+ * Initializing a customer can be done using a hash of attributes.
26
+
27
+ #### Get
28
+
29
+ * Retrieves the customer by internalId.
30
+
31
+ ```Ruby
32
+ customer = NetSuite::Customer.get(4) # => #<NetSuite::Customer:0x1042f59b8>
33
+ customer.is_person # => true
34
+ ```
35
+
36
+ <a name='extending'>
37
+ ## Additions
38
+
39
+ * Please submit a pull request for any models or actions that you would like to be included. The API is quite large and so we will necessarily not cover all of it.
40
+ * Models should go into the `lib/netsuite/models/` directory.
41
+ * Actions should be placed in their respective subdirectory under `lib/netsuite/actions`.
42
+ * Example:
43
+
44
+ ```Ruby
45
+ # lib/netsuite/actions/customer/add.rb
46
+
47
+ module NetSuite
48
+ module Actions
49
+ module Customer
50
+ class Add
51
+
52
+ def initialize(attributes = {})
53
+ @attributes = attributes
54
+ end
55
+
56
+ def self.call(attributes)
57
+ new(attributes).call
58
+ end
59
+
60
+ def call
61
+ response = NetSuite::Configuration.connection.request :add do
62
+ soap.header = NetSuite::Configuration.auth_header
63
+ soap.body = {
64
+ :entityId => @attributes[:entity_id],
65
+ :companyName => @attributes[:company_name],
66
+ :unsubscribe => @attributes[:unsubscribe]
67
+ }
68
+ end
69
+ success = response.to_hash[:add_response][:write_response][:status][:@is_success] == 'true'
70
+ body = response.to_hash[:add_response][:write_response][:base_ref]
71
+ NetSuite::Response.new(:success => success, :body => body)
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ response = NetSuite::Actions::Customer::Add.call(
80
+ :entity_id => 'Shutter Fly',
81
+ :company_name => 'Shutter Fly, Inc.',
82
+ :unsubscribe => false
83
+ ) # => #<NetSuite::Response:0x1041f64b5>
84
+ response.success? # => true
85
+ response.body # => { :internal_id => '979', :type => 'customer' }
86
+ ```
22
87
 
23
88
  ## Contributing
24
89
 
@@ -4,7 +4,9 @@ require 'netsuite/response'
4
4
  require 'netsuite/version'
5
5
 
6
6
  # ACTIONS
7
- require 'netsuite/actions/customer/get'
7
+ require 'netsuite/actions/support'
8
+ require 'netsuite/actions/add'
9
+ require 'netsuite/actions/get'
8
10
 
9
11
  # MODELS
10
12
  require 'netsuite/models/customer'
@@ -0,0 +1,58 @@
1
+ module NetSuite
2
+ module Actions
3
+ class Add
4
+ include Support
5
+
6
+ def initialize(attributes = {})
7
+ @attributes = attributes
8
+ end
9
+
10
+ private
11
+
12
+ def request
13
+ connection.request :platformMsgs, :add do
14
+ soap.namespaces['xmlns:platformMsgs'] = 'urn:messages_2011_2.platform.webservices.netsuite.com'
15
+ soap.namespaces['xmlns:platformCore'] = 'urn:core_2011_2.platform.webservices.netsuite.com'
16
+ soap.namespaces['xmlns:listRel'] = 'urn:relationships_2011_2.lists.webservices.netsuite.com'
17
+ soap.header = auth_header
18
+ soap.body = request_body
19
+ end
20
+ end
21
+
22
+ # <soap:Body>
23
+ # <platformMsgs:add>
24
+ # <platformMsgs:record xsi:type="listRel:Customer">
25
+ # <listRel:entityId>Shutter Fly</listRel:entityId>
26
+ # <listRel:companyName>Shutter Fly, Inc</listRel:companyName>
27
+ # </platformMsgs:record>
28
+ # </platformMsgs:add>
29
+ # </soap:Body>
30
+ def request_body
31
+ {
32
+ 'platformMsgs:record' => {
33
+ 'listRel:entityId' => @attributes[:entity_id],
34
+ 'listRel:companyName' => @attributes[:company_name]
35
+ },
36
+ :attributes! => {
37
+ 'platformMsgs:record' => {
38
+ 'xsi:type' => 'listRel:Customer'
39
+ }
40
+ }
41
+ }
42
+ end
43
+
44
+ def success?
45
+ @success ||= response_hash[:status][:@is_success] == 'true'
46
+ end
47
+
48
+ def response_body
49
+ @response_body ||= response_hash[:base_ref]
50
+ end
51
+
52
+ def response_hash
53
+ @response_hash ||= @response.to_hash[:add_response][:write_response]
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,55 @@
1
+ module NetSuite
2
+ module Actions
3
+ class Get
4
+ include Support
5
+
6
+ def initialize(id)
7
+ @id = id
8
+ end
9
+
10
+ private
11
+
12
+ def request
13
+ connection.request :platformMsgs, :get do
14
+ soap.namespaces['xmlns:platformMsgs'] = 'urn:messages_2011_2.platform.webservices.netsuite.com'
15
+ soap.namespaces['xmlns:platformCore'] = 'urn:core_2011_2.platform.webservices.netsuite.com'
16
+ soap.header = auth_header
17
+ soap.body = request_body
18
+ end
19
+ end
20
+
21
+ # <soap:Body>
22
+ # <platformMsgs:get>
23
+ # <platformMsgs:baseRef internalId="983" type="customer" xsi:type="platformCore:RecordRef">
24
+ # <platformCore:name/>
25
+ # </platformMsgs:baseRef>
26
+ # </platformMsgs:get>
27
+ # </soap:Body>
28
+ def request_body
29
+ {
30
+ 'platformMsgs:baseRef' => {},
31
+ :attributes! => {
32
+ 'platformMsgs:baseRef' => {
33
+ :internalId => @id,
34
+ :type => 'customer',
35
+ 'xsi:type' => 'platformCore:RecordRef'
36
+ }
37
+ }
38
+ }
39
+ end
40
+
41
+ def success?
42
+ @success ||= response_hash[:status][:@is_success] == 'true'
43
+ end
44
+
45
+ def response_body
46
+ @response_body ||= response_hash[:record]
47
+ end
48
+
49
+ def response_hash
50
+ @response_hash = @response[:get_response][:read_response]
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,50 @@
1
+ module NetSuite
2
+ module Actions
3
+ module Support
4
+
5
+ def self.included(base)
6
+ base.send(:extend, ClassMethods)
7
+ end
8
+
9
+ module ClassMethods
10
+
11
+ def call(*args)
12
+ new(*args).call
13
+ end
14
+
15
+ end
16
+
17
+ def call
18
+ @response = request
19
+ build_response
20
+ end
21
+
22
+ private
23
+
24
+ def request
25
+ raise NotImplementedError
26
+ end
27
+
28
+ def connection
29
+ NetSuite::Configuration.connection
30
+ end
31
+
32
+ def auth_header
33
+ NetSuite::Configuration.auth_header
34
+ end
35
+
36
+ def build_response
37
+ NetSuite::Response.new(:success => success?, :body => response_body)
38
+ end
39
+
40
+ def success?
41
+ raise NotImplementedError
42
+ end
43
+
44
+ def response_body
45
+ raise NotImplementedError
46
+ end
47
+
48
+ end
49
+ end
50
+ end
@@ -14,8 +14,16 @@ module NetSuite
14
14
  attributes[:connection] ||= Savon::Client.new(self.wsdl)
15
15
  end
16
16
 
17
- def wsdl
18
- attributes[:wsdl] ||= File.expand_path('../../../wsdl/2011_02.wsdl', __FILE__)
17
+ def wsdl=(wsdl)
18
+ attributes[:wsdl] = wsdl
19
+ end
20
+
21
+ def wsdl(wsdl = nil)
22
+ if wsdl
23
+ self.wsdl = wsdl
24
+ else
25
+ attributes[:wsdl] ||= File.expand_path('../../../wsdl/2011_02.wsdl', __FILE__)
26
+ end
19
27
  end
20
28
 
21
29
  def auth_header
@@ -6,7 +6,7 @@ module NetSuite
6
6
  end
7
7
 
8
8
  def self.get(id)
9
- response = NetSuite::Actions::Customer::Get.call(id)
9
+ response = NetSuite::Actions::Get.call(id)
10
10
  if response.success?
11
11
  new(response.body)
12
12
  else
@@ -14,8 +14,17 @@ module NetSuite
14
14
  end
15
15
  end
16
16
 
17
- def is_person
18
- @attributes[:is_person]
17
+ def add
18
+ response = NetSuite::Actions::Add.call(@attributes)
19
+ response.success?
20
+ end
21
+
22
+ def method_missing(m, *args, &block)
23
+ if @attributes.keys.include?(m.to_sym)
24
+ @attributes[m.to_sym]
25
+ else
26
+ super
27
+ end
19
28
  end
20
29
 
21
30
  end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Actions::Add do
4
+
5
+ context 'Customer' do
6
+ let(:attributes) do
7
+ {
8
+ :entity_id => 'Shutter Fly',
9
+ :company_name => 'Shutter Fly, Inc.'
10
+ }
11
+ end
12
+
13
+ before do
14
+ savon.expects(:add).with({
15
+ 'platformMsgs:record' => {
16
+ 'listRel:entityId' => 'Shutter Fly',
17
+ 'listRel:companyName' => 'Shutter Fly, Inc.'
18
+ },
19
+ :attributes! => {
20
+ 'platformMsgs:baseRef' => {
21
+ 'xsi:type' => 'listRel:Customer'
22
+ }
23
+ }
24
+ }).returns(:add_customer)
25
+ end
26
+
27
+ it 'makes a valid request to the NetSuite API' do
28
+ NetSuite::Actions::Add.call(attributes)
29
+ end
30
+
31
+ it 'returns a valid Response object' do
32
+ response = NetSuite::Actions::Add.call(attributes)
33
+ response.should be_kind_of(NetSuite::Response)
34
+ end
35
+ end
36
+
37
+ end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe NetSuite::Actions::Customer::Get do
3
+ describe NetSuite::Actions::Get do
4
4
 
5
5
  before do
6
6
  savon.expects(:get).with({
@@ -16,11 +16,11 @@ describe NetSuite::Actions::Customer::Get do
16
16
  end
17
17
 
18
18
  it 'makes a valid request to the NetSuite API' do
19
- NetSuite::Actions::Customer::Get.call(1)
19
+ NetSuite::Actions::Get.call(1)
20
20
  end
21
21
 
22
22
  it 'returns a valid Response object' do
23
- response = NetSuite::Actions::Customer::Get.call(1)
23
+ response = NetSuite::Actions::Get.call(1)
24
24
  response.should be_kind_of(NetSuite::Response)
25
25
  end
26
26
 
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe NetSuite::Actions::Support do
4
+ let(:instance) do
5
+ obj = Object.new
6
+ obj.extend(NetSuite::Actions::Support)
7
+ obj
8
+ end
9
+
10
+ describe '#call' do
11
+ before do
12
+ instance.stub(:request)
13
+ instance.stub(:success?)
14
+ instance.stub(:response_body)
15
+ end
16
+
17
+ it 'calls #request' do
18
+ instance.should_receive(:request)
19
+ instance.call
20
+ end
21
+
22
+ it 'calls #build_response' do
23
+ instance.should_receive(:build_response)
24
+ instance.call
25
+ end
26
+
27
+ it 'returns a NetSuite::Response object' do
28
+ response = instance.call
29
+ response.should be_kind_of(NetSuite::Response)
30
+ end
31
+ end
32
+
33
+ end
@@ -23,8 +23,20 @@ describe NetSuite::Configuration do
23
23
  end
24
24
 
25
25
  describe '#wsdl' do
26
- it 'returns a path to the WSDL to use for the API' do
27
- config.wsdl.should match(/.*\/netsuite\/wsdl\/2011_02\.wsdl/)
26
+ context 'when the wsdl has been set' do
27
+ before do
28
+ config.wsdl = 'https://system.sandbox.netsuite.com/wsdl/v2011_2_0/netsuite.wsdl'
29
+ end
30
+
31
+ it 'returns a path to the WSDL to use for the API' do
32
+ config.wsdl.should eql('https://system.sandbox.netsuite.com/wsdl/v2011_2_0/netsuite.wsdl')
33
+ end
34
+ end
35
+
36
+ context 'when the wsdl has not been set' do
37
+ it 'returns a path to the WSDL to use for the API' do
38
+ config.wsdl.should match(/.*\/netsuite\/wsdl\/2011_02\.wsdl/)
39
+ end
28
40
  end
29
41
  end
30
42
 
@@ -8,7 +8,7 @@ describe NetSuite::Customer do
8
8
  let(:response) { NetSuite::Response.new(:success => true, :body => { :is_person => true }) }
9
9
 
10
10
  it 'returns a Customer instance populated with the data from the response object' do
11
- NetSuite::Actions::Customer::Get.should_receive(:call).with(1).and_return(response)
11
+ NetSuite::Actions::Get.should_receive(:call).with(1).and_return(response)
12
12
  customer = NetSuite::Customer.get(1)
13
13
  customer.should be_kind_of(NetSuite::Customer)
14
14
  customer.is_person.should be_true
@@ -19,7 +19,7 @@ describe NetSuite::Customer do
19
19
  let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
20
20
 
21
21
  it 'returns a Customer instance populated with the data from the response object' do
22
- NetSuite::Actions::Customer::Get.should_receive(:call).with(1).and_return(response)
22
+ NetSuite::Actions::Get.should_receive(:call).with(1).and_return(response)
23
23
  lambda {
24
24
  NetSuite::Customer.get(1)
25
25
  }.should raise_error(NetSuite::RecordNotFound, 'NetSuite::Customer with ID=1 could not be found')
@@ -27,11 +27,46 @@ describe NetSuite::Customer do
27
27
  end
28
28
  end
29
29
 
30
- describe '#is_person' do
31
- context 'when the customer is a person' do
30
+ describe '#add' do
31
+ let(:test_data) { { :entity_name => 'TEST CUSTOMER', :is_person => true } }
32
+
33
+ context 'when the response is successful' do
34
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :internal_id => '1' }) }
35
+
32
36
  it 'returns true' do
33
- customer = NetSuite::Customer.new(:is_person => true)
34
- customer.is_person.should be_true
37
+ NetSuite::Actions::Add.should_receive(:call).
38
+ with(test_data).
39
+ and_return(response)
40
+ customer = NetSuite::Customer.new(test_data)
41
+ customer.add.should be_true
42
+ end
43
+ end
44
+
45
+ context 'when the response is unsuccessful' do
46
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
47
+ it 'returns false' do
48
+ NetSuite::Actions::Add.should_receive(:call).
49
+ with(test_data).
50
+ and_return(response)
51
+ customer = NetSuite::Customer.new(test_data)
52
+ customer.add.should be_false
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#method_missing' do
58
+ context 'when calling a method that exists as an attribute' do
59
+ it 'returns the right value from the attributes hash' do
60
+ customer = NetSuite::Customer.new(:name => 'Mr. Banana')
61
+ customer.name.should eql('Mr. Banana')
62
+ end
63
+ end
64
+
65
+ context 'when calling a method that does not exist in the attributes hash' do
66
+ it 'raises a NoMethodError' do
67
+ lambda {
68
+ customer.banana
69
+ }.should raise_error(NoMethodError)
35
70
  end
36
71
  end
37
72
  end
@@ -8,27 +8,34 @@ describe NetSuite do
8
8
  end
9
9
 
10
10
  describe '#configure' do
11
- it 'allows the Configuration #email= instance method to be called with instance eval' do
11
+ it 'allows the Configuration #email instance method to be called with instance eval' do
12
12
  NetSuite.configure do
13
13
  email 'me@example.com'
14
14
  end
15
15
  config.email.should eql('me@example.com')
16
16
  end
17
17
 
18
- it 'allows the Configuration #password= instance method to be called with instance eval' do
18
+ it 'allows the Configuration #password instance method to be called with instance eval' do
19
19
  NetSuite.configure do
20
20
  password 'myPassword'
21
21
  end
22
22
  config.password.should eql('myPassword')
23
23
  end
24
24
 
25
- it 'allows the Configuration #account= instance method to be called with instance eval' do
25
+ it 'allows the Configuration #account instance method to be called with instance eval' do
26
26
  NetSuite.configure do
27
27
  account 1234
28
28
  end
29
29
  config.account.should eql(1234)
30
30
  end
31
31
 
32
+ it 'allows the Configuration #wsdl instance method to be called with instance_eval' do
33
+ NetSuite.configure do
34
+ wsdl 'https://system.sandbox.netsuite.com/wsdl/v2011_2_0/netsuite.wsdl'
35
+ end
36
+ config.wsdl.should eql('https://system.sandbox.netsuite.com/wsdl/v2011_2_0/netsuite.wsdl')
37
+ end
38
+
32
39
  end
33
40
 
34
41
  end
@@ -1,6 +1,7 @@
1
1
  RSpec.configure do |config|
2
2
  config.before do
3
3
  NetSuite.configure do
4
+ reset!
4
5
  email 'me@example.com'
5
6
  password 'myPassword'
6
7
  account 1234
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
3
+ <soapenv:Header>
4
+ <platformMsgs:documentInfo xmlns:platformMsgs="urn:messages_2011_2.platform.webservices.netsuite.com">
5
+ <platformMsgs:nsId>WEBSERVICES_3392464_1220201115821392011296470399_67055c545d0</platformMsgs:nsId>
6
+ </platformMsgs:documentInfo>
7
+ </soapenv:Header>
8
+ <soapenv:Body>
9
+ <addResponse xmlns="urn:messages_2_5.platform.webservices.netsuite.com">
10
+ <writeResponse xmlns="urn:messages_2_5.platform.webservices.netsuite.com">
11
+ <ns1:status isSuccess="true" xmlns:ns1="urn:core_2_5.platform.webservices.netsuite.com"/>
12
+ <baseRef internalId="979" type="customer" xsi:type="ns2:RecordRef" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:core_2_5.platform.webservices.netsuite.com"/>
13
+ </writeResponse>
14
+ </addResponse>
15
+ </soapenv:Body>
16
+ </soapenv:Envelope>
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: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
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: 2011-12-21 00:00:00 -08:00
18
+ date: 2011-12-22 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -95,25 +95,31 @@ files:
95
95
  - .autotest
96
96
  - .gitignore
97
97
  - .rspec
98
+ - .rvmrc
98
99
  - Gemfile
99
100
  - LICENSE
100
101
  - README.md
101
102
  - Rakefile
102
103
  - lib/netsuite.rb
103
- - lib/netsuite/actions/customer/get.rb
104
+ - lib/netsuite/actions/add.rb
105
+ - lib/netsuite/actions/get.rb
106
+ - lib/netsuite/actions/support.rb
104
107
  - lib/netsuite/configuration.rb
105
108
  - lib/netsuite/errors.rb
106
109
  - lib/netsuite/models/customer.rb
107
110
  - lib/netsuite/response.rb
108
111
  - lib/netsuite/version.rb
109
112
  - netsuite.gemspec
110
- - spec/netsuite/actions/customer/get_spec.rb
113
+ - spec/netsuite/actions/add_spec.rb
114
+ - spec/netsuite/actions/get_spec.rb
115
+ - spec/netsuite/actions/support_spec.rb
111
116
  - spec/netsuite/configuration_spec.rb
112
117
  - spec/netsuite/models/customer_spec.rb
113
118
  - spec/netsuite/response_spec.rb
114
119
  - spec/netsuite_spec.rb
115
120
  - spec/spec_helper.rb
116
121
  - spec/support/configuration.rb
122
+ - spec/support/fixtures/add/add_customer.xml
117
123
  - spec/support/fixtures/get/get_customer.xml
118
124
  - spec/support/savon.rb
119
125
  - wsdl/2011_02.wsdl
@@ -152,12 +158,15 @@ signing_key:
152
158
  specification_version: 3
153
159
  summary: NetSuite SuiteTalk API Wrapper
154
160
  test_files:
155
- - spec/netsuite/actions/customer/get_spec.rb
161
+ - spec/netsuite/actions/add_spec.rb
162
+ - spec/netsuite/actions/get_spec.rb
163
+ - spec/netsuite/actions/support_spec.rb
156
164
  - spec/netsuite/configuration_spec.rb
157
165
  - spec/netsuite/models/customer_spec.rb
158
166
  - spec/netsuite/response_spec.rb
159
167
  - spec/netsuite_spec.rb
160
168
  - spec/spec_helper.rb
161
169
  - spec/support/configuration.rb
170
+ - spec/support/fixtures/add/add_customer.xml
162
171
  - spec/support/fixtures/get/get_customer.xml
163
172
  - spec/support/savon.rb
@@ -1,70 +0,0 @@
1
- module NetSuite
2
- module Actions
3
- module Customer
4
- class Get
5
-
6
- def initialize(id)
7
- @id = id
8
- end
9
-
10
- def self.call(id)
11
- new(id).call
12
- end
13
-
14
- def call
15
- @response = request
16
- build_response
17
- end
18
-
19
- private
20
-
21
- def request
22
- connection.request :platformMsgs, :get do
23
- soap.namespaces['xmlns:platformMsgs'] = 'urn:messages_2011_2.platform.webservices.netsuite.com'
24
- soap.namespaces['xmlns:platformCore'] = 'urn:core_2011_2.platform.webservices.netsuite.com'
25
- soap.header = auth_header
26
- soap.body = request_body
27
- end
28
- end
29
-
30
- def connection
31
- NetSuite::Configuration.connection
32
- end
33
-
34
- def auth_header
35
- NetSuite::Configuration.auth_header
36
- end
37
-
38
- def request_body
39
- {
40
- 'platformMsgs:baseRef' => {},
41
- :attributes! => {
42
- 'platformMsgs:baseRef' => {
43
- :internalId => @id,
44
- :type => 'customer',
45
- 'xsi:type' => 'platformCore:RecordRef'
46
- }
47
- }
48
- }
49
- end
50
-
51
- def build_response
52
- NetSuite::Response.new(:success => success?, :body => response_body)
53
- end
54
-
55
- def success?
56
- @success ||= response_hash[:status][:@is_success] == 'true'
57
- end
58
-
59
- def response_body
60
- @response_body ||= response_hash[:record]
61
- end
62
-
63
- def response_hash
64
- @response_hash = @response[:get_response][:read_response]
65
- end
66
-
67
- end
68
- end
69
- end
70
- end