netsuite 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -25,7 +25,7 @@ module NetSuite
25
25
  def attributes!
26
26
  attr_hash = {}
27
27
  attr_hash['internalId'] = internal_id if internal_id
28
- attr_hash['xsi:type'] = type if type
28
+ attr_hash['xsi:type'] = type if type
29
29
  attr_hash
30
30
  end
31
31
 
@@ -7,7 +7,7 @@ module NetSuite
7
7
  include Support::Actions
8
8
  include Namespaces::ListRel
9
9
 
10
- actions :get, :add, :delete
10
+ actions :get, :add, :delete, :update
11
11
 
12
12
  fields :account_number, :allocate_payroll_expenses, :allow_all_resources_for_tasks, :allow_expenses, :allow_time,
13
13
  :alt_name, :alt_phone, :bill_pay, :calculated_end_date, :calculated_end_date_baseline, :comments, :company_name,
@@ -28,6 +28,8 @@ module NetSuite
28
28
  define_initialize(class_module)
29
29
  when :delete
30
30
  define_delete(instance_module)
31
+ when :update
32
+ define_update(instance_module)
31
33
  else
32
34
  raise "Unknown action: #{action.inspect}"
33
35
  end
@@ -88,6 +90,17 @@ module NetSuite
88
90
  end
89
91
  end
90
92
 
93
+ def define_update(instance_module)
94
+ instance_module.module_eval do
95
+ define_method :update do |options|
96
+ options.merge!(:internal_id => internal_id) if respond_to?(:internal_id) && internal_id
97
+ options.merge!(:external_id => external_id) if respond_to?(:external_id) && external_id
98
+ response = NetSuite::Actions::Update.call(self.class, options)
99
+ response.success?
100
+ end
101
+ end
102
+ end
103
+
91
104
  end
92
105
 
93
106
  end
@@ -1,3 +1,3 @@
1
1
  module Netsuite
2
- VERSION = '0.0.31'
2
+ VERSION = '0.0.32'
3
3
  end
@@ -159,6 +159,28 @@ describe NetSuite::Records::Job do
159
159
  end
160
160
  end
161
161
 
162
+ describe '.update' do
163
+ context 'when the response is successful' do
164
+ let(:response) { NetSuite::Response.new(:success => true, :body => { :account_number => 7 }) }
165
+
166
+ it 'returns true' do
167
+ NetSuite::Actions::Update.should_receive(:call).with(NetSuite::Records::Job, :external_id => 1, :account_number => 7).and_return(response)
168
+ job = NetSuite::Records::Job.new(:external_id => 1)
169
+ job.update(:account_number => 7).should be_true
170
+ end
171
+ end
172
+
173
+ context 'when the response is unsuccessful' do
174
+ let(:response) { NetSuite::Response.new(:success => false, :body => {}) }
175
+
176
+ it 'raises a RecordNotFound exception' do
177
+ NetSuite::Actions::Update.should_receive(:call).with(NetSuite::Records::Job, :internal_id => 1, :account_number => 7).and_return(response)
178
+ job = NetSuite::Records::Job.new(:internal_id => 1)
179
+ job.update(:account_number => 7).should be_false
180
+ end
181
+ end
182
+ end
183
+
162
184
  describe '#to_record' do
163
185
  let(:job) { NetSuite::Records::Job.new(:entity_id => 'TEST JOB', :account_number => 7) }
164
186
 
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: 33
4
+ hash: 95
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 31
10
- version: 0.0.31
9
+ - 32
10
+ version: 0.0.32
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-24 00:00:00 Z
18
+ date: 2012-01-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: savon