netsuite 0.0.33 → 0.0.34
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/netsuite/actions/add.rb +7 -0
- data/lib/netsuite/actions/delete.rb +11 -0
- data/lib/netsuite/actions/get.rb +11 -0
- data/lib/netsuite/actions/initialize.rb +11 -0
- data/lib/netsuite/actions/update.rb +9 -0
- data/lib/netsuite/records/customer_refund.rb +2 -2
- data/lib/netsuite/support/actions.rb +14 -79
- data/lib/netsuite/version.rb +1 -1
- data/spec/netsuite/records/customer_refund_spec.rb +4 -4
- metadata +3 -3
data/lib/netsuite/actions/add.rb
CHANGED
@@ -62,6 +62,17 @@ module NetSuite
|
|
62
62
|
@response_body ||= response_hash[:base_ref]
|
63
63
|
end
|
64
64
|
|
65
|
+
module Support
|
66
|
+
def delete(options = {})
|
67
|
+
response = if options.empty?
|
68
|
+
NetSuite::Actions::Delete.call(self)
|
69
|
+
else
|
70
|
+
NetSuite::Actions::Delete.call(self, options)
|
71
|
+
end
|
72
|
+
response.success?
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
65
76
|
end
|
66
77
|
end
|
67
78
|
end
|
data/lib/netsuite/actions/get.rb
CHANGED
@@ -58,6 +58,17 @@ module NetSuite
|
|
58
58
|
@response_hash = @response[:get_response][:read_response]
|
59
59
|
end
|
60
60
|
|
61
|
+
module Support
|
62
|
+
def get(options = {})
|
63
|
+
response = NetSuite::Actions::Get.call(self, options)
|
64
|
+
if response.success?
|
65
|
+
new(response.body)
|
66
|
+
else
|
67
|
+
raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
61
72
|
end
|
62
73
|
end
|
63
74
|
end
|
@@ -51,6 +51,17 @@ module NetSuite
|
|
51
51
|
@response_body ||= response_hash[:record]
|
52
52
|
end
|
53
53
|
|
54
|
+
module Support
|
55
|
+
def initialize(object)
|
56
|
+
response = NetSuite::Actions::Initialize.call(self, object)
|
57
|
+
if response.success?
|
58
|
+
new(response.body)
|
59
|
+
else
|
60
|
+
raise InitializationError, "#{self}.initialize with #{object} failed."
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
54
65
|
end
|
55
66
|
end
|
56
67
|
end
|
@@ -62,6 +62,15 @@ module NetSuite
|
|
62
62
|
@response_hash ||= @response.to_hash[:update_response][:write_response]
|
63
63
|
end
|
64
64
|
|
65
|
+
module Support
|
66
|
+
def update(options = {})
|
67
|
+
options.merge!(:internal_id => internal_id) if respond_to?(:internal_id) && internal_id
|
68
|
+
options.merge!(:external_id => external_id) if respond_to?(:external_id) && external_id
|
69
|
+
response = NetSuite::Actions::Update.call(self.class, options)
|
70
|
+
response.success?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
65
74
|
end
|
66
75
|
end
|
67
76
|
end
|
@@ -9,7 +9,7 @@ module NetSuite
|
|
9
9
|
|
10
10
|
actions :get, :initialize, :add, :delete
|
11
11
|
|
12
|
-
fields :address, :
|
12
|
+
fields :address, :cc_approved, :cc_expire_date, :cc_name, :cc_number, :cc_street, :cc_zip_code, :charge_it,
|
13
13
|
:created_date, :currency_name, :debit_card_issue_no, :exchange_rate, :last_modified_date, :memo, :pn_ref_num, :status,
|
14
14
|
:to_be_printed, :tran_date, :tran_id, :valid_from
|
15
15
|
|
@@ -17,7 +17,7 @@ module NetSuite
|
|
17
17
|
field :apply_list, CustomerRefundApplyList
|
18
18
|
field :deposit_list, CustomerRefundDepositList
|
19
19
|
|
20
|
-
read_only_fields :total
|
20
|
+
read_only_fields :balance, :total
|
21
21
|
|
22
22
|
record_refs :account, :ar_acct, :credit_card, :credit_card_processor, :custom_form, :customer, :department, :klass,
|
23
23
|
:location, :payment_method, :posting_period, :subsidiary, :void_journal
|
@@ -9,95 +9,30 @@ module NetSuite
|
|
9
9
|
module ClassMethods
|
10
10
|
|
11
11
|
def actions(*args)
|
12
|
-
instance_module = Module.new
|
13
|
-
class_module = Module.new
|
14
12
|
args.each do |action|
|
15
|
-
|
13
|
+
action(action)
|
16
14
|
end
|
17
|
-
self.send(:include, instance_module)
|
18
|
-
self.send(:extend, class_module)
|
19
15
|
end
|
20
16
|
|
21
|
-
def
|
22
|
-
case
|
17
|
+
def action(name)
|
18
|
+
case name
|
23
19
|
when :get
|
24
|
-
|
20
|
+
self.extend(NetSuite::Actions::Get::Support)
|
25
21
|
when :add
|
26
|
-
|
27
|
-
when :initialize
|
28
|
-
define_initialize(class_module)
|
22
|
+
self.send(:include, NetSuite::Actions::Add::Support)
|
29
23
|
when :delete
|
30
|
-
|
24
|
+
self.send(:include, NetSuite::Actions::Delete::Support)
|
31
25
|
when :update
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
def define_get(class_module)
|
39
|
-
class_module.module_eval do
|
40
|
-
define_method :get do |*args|
|
41
|
-
options, *ignored = *args
|
42
|
-
response = NetSuite::Actions::Get.call(self, options)
|
43
|
-
if response.success?
|
44
|
-
new(response.body)
|
45
|
-
else
|
46
|
-
raise RecordNotFound, "#{self} with OPTIONS=#{options.inspect} could not be found"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def define_add(instance_module)
|
53
|
-
instance_module.module_eval do
|
54
|
-
define_method :add do
|
55
|
-
response = NetSuite::Actions::Add.call(self)
|
56
|
-
response.success?
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def define_initialize(class_module)
|
62
|
-
(class << self; self; end).instance_eval do
|
63
|
-
define_method :initialize do |*args|
|
64
|
-
super(*args)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
class_module.module_eval do
|
69
|
-
define_method :initialize do |object|
|
70
|
-
response = NetSuite::Actions::Initialize.call(self, object)
|
71
|
-
if response.success?
|
72
|
-
new(response.body)
|
73
|
-
else
|
74
|
-
raise InitializationError, "#{self}.initialize with #{object} failed."
|
26
|
+
self.send(:include, NetSuite::Actions::Update::Support)
|
27
|
+
when :initialize
|
28
|
+
(class << self; self; end).instance_eval do # We have to do this because Class has a private
|
29
|
+
define_method :initialize do |*args| # #initialize method that this method will override.
|
30
|
+
super(*args)
|
75
31
|
end
|
76
32
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
def define_delete(instance_module)
|
81
|
-
instance_module.module_eval do
|
82
|
-
define_method :delete do |*options|
|
83
|
-
response = if options.empty?
|
84
|
-
NetSuite::Actions::Delete.call(self)
|
85
|
-
else
|
86
|
-
NetSuite::Actions::Delete.call(self, *options)
|
87
|
-
end
|
88
|
-
response.success?
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
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
|
33
|
+
self.extend(NetSuite::Actions::Initialize::Support)
|
34
|
+
else
|
35
|
+
raise "Unknown action: #{name.inspect}"
|
101
36
|
end
|
102
37
|
end
|
103
38
|
|
data/lib/netsuite/version.rb
CHANGED
@@ -177,13 +177,13 @@ describe NetSuite::Records::CustomerRefund do
|
|
177
177
|
|
178
178
|
describe '#to_record' do
|
179
179
|
before do
|
180
|
-
refund.memo
|
181
|
-
refund.
|
180
|
+
refund.memo = 'This is a memo'
|
181
|
+
refund.cc_zip_code = '10101'
|
182
182
|
end
|
183
183
|
it 'can represent itself as a SOAP record' do
|
184
184
|
record = {
|
185
|
-
'tranCust:memo'
|
186
|
-
'tranCust:
|
185
|
+
'tranCust:memo' => 'This is a memo',
|
186
|
+
'tranCust:ccZipCode' => '10101'
|
187
187
|
}
|
188
188
|
refund.to_record.should eql(record)
|
189
189
|
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: 91
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 34
|
10
|
+
version: 0.0.34
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ryan Moran
|