rubyzoho 0.1.7 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.coverall.yml +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -5
- data/Gemfile +4 -2
- data/README.rdoc +24 -9
- data/VERSION +1 -1
- data/lib/api_utils.rb +1 -0
- data/lib/crm.rb +112 -0
- data/lib/crud_methods.rb +76 -0
- data/lib/ruby_zoho.rb +7 -225
- data/lib/zoho_api.rb +49 -161
- data/lib/zoho_api_field_utils.rb +126 -0
- data/lib/zoho_api_finders.rb +45 -0
- data/lib/zoho_crm_users.rb +32 -0
- data/lib/zoho_crm_utils.rb +81 -0
- data/rubyzoho-0.1.7.gem +0 -0
- data/rubyzoho.gemspec +24 -12
- data/spec/ruby_zoho_spec.rb +49 -50
- data/spec/spec_helper.rb +10 -0
- data/spec/zoho_api_spec.rb +25 -14
- metadata +33 -35
- data/.rvmrc +0 -1
- data/rubyzoho-0.1.6.gem +0 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
c = Class.new(RubyZoho::Crm) do
|
2
|
+
def initialize(object_attribute_hash = {})
|
3
|
+
Crm.module_name = 'Users'
|
4
|
+
super
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.delete(id)
|
8
|
+
raise 'Cannot delete users through API'
|
9
|
+
end
|
10
|
+
|
11
|
+
def save
|
12
|
+
raise 'Cannot delete users through API'
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.all
|
16
|
+
result = RubyZoho.configuration.api.users('AllUsers')
|
17
|
+
result.collect { |r| new(r) }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.find_by_email(email)
|
21
|
+
r = []
|
22
|
+
self.all.index { |u| r << u if u.email == email }
|
23
|
+
r
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.method_missing(meth, *args, &block)
|
27
|
+
Crm.module_name = 'Users'
|
28
|
+
super
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Kernel.const_set 'CRMUser', c
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module ZohoCrmUtils
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
def create_accessor(klass, names)
|
10
|
+
names.each do |name|
|
11
|
+
n = name.class == Symbol ? name.to_s : name
|
12
|
+
n.gsub!(/[()]*/, '')
|
13
|
+
raise(RuntimeError, "Bad field name: #{name}") unless method_name?(n)
|
14
|
+
create_getter(klass, n)
|
15
|
+
create_setter(klass, n)
|
16
|
+
end
|
17
|
+
names
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_getter(klass, *names)
|
21
|
+
names.each do |name|
|
22
|
+
klass.send(:define_method, "#{name}") { instance_variable_get("@#{name}") }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_setter(klass, *names)
|
27
|
+
names.each do |name|
|
28
|
+
klass.send(:define_method, "#{name}=") { |val| instance_variable_set("@#{name}", val) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def method_name?(n)
|
33
|
+
name = n.class == String ? ApiUtils.string_to_symbol(n) : n
|
34
|
+
return /[@$"]/ !~ name.inspect
|
35
|
+
end
|
36
|
+
|
37
|
+
def method_is_module?(str_or_sym)
|
38
|
+
return nil if str_or_sym.nil?
|
39
|
+
s = str_or_sym.class == String ? str_or_sym : ApiUtils.symbol_to_string(str_or_sym)
|
40
|
+
possible_module = s[s.length - 1].downcase == 's' ? s : s + 's'
|
41
|
+
i = RubyZoho.configuration.crm_modules.index(possible_module.capitalize)
|
42
|
+
return str_or_sym unless i.nil?
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def create_accessor(klass, names)
|
49
|
+
names.each do |name|
|
50
|
+
n = name.class == Symbol ? name.to_s : name
|
51
|
+
n.gsub!(/[()]*/, '')
|
52
|
+
raise(RuntimeError, "Bad field name: #{name}") unless self.class.method_name?(n)
|
53
|
+
self.class.create_getter(klass, n)
|
54
|
+
self.class.create_setter(klass, n)
|
55
|
+
end
|
56
|
+
names
|
57
|
+
end
|
58
|
+
|
59
|
+
def update_or_create_attrs(object_attribute_hash)
|
60
|
+
retry_counter = object_attribute_hash.count
|
61
|
+
begin
|
62
|
+
object_attribute_hash.map { |(k, v)| public_send("#{k}=", v) }
|
63
|
+
rescue NoMethodError => e
|
64
|
+
m = e.message.slice(/`(.*?)=/)
|
65
|
+
create_accessor(self.class, [m.gsub(/[`()]*/, '').chop]) unless m.nil?
|
66
|
+
retry_counter -= 1
|
67
|
+
retry if retry_counter > 0
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def attr_writers
|
72
|
+
self.methods.grep(/\w=$/)
|
73
|
+
end
|
74
|
+
|
75
|
+
def run_create_accessor(klass, meth)
|
76
|
+
method = meth.to_s.chop.to_sym
|
77
|
+
RubyZoho::Crm.create_accessor(klass, [method])
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/rubyzoho-0.1.7.gem
ADDED
Binary file
|
data/rubyzoho.gemspec
CHANGED
@@ -2,14 +2,15 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: rubyzoho 0.1.11 ruby lib
|
5
6
|
|
6
7
|
Gem::Specification.new do |s|
|
7
8
|
s.name = "rubyzoho"
|
8
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.11"
|
9
10
|
|
10
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
12
|
s.authors = ["amalc"]
|
12
|
-
s.date = "2013-
|
13
|
+
s.date = "2013-12-16"
|
13
14
|
s.description = ""
|
14
15
|
s.email = ""
|
15
16
|
s.extra_rdoc_files = [
|
@@ -17,9 +18,11 @@ Gem::Specification.new do |s|
|
|
17
18
|
"README.rdoc"
|
18
19
|
]
|
19
20
|
s.files = [
|
21
|
+
".coverall.yml",
|
20
22
|
".document",
|
21
23
|
".rspec",
|
22
|
-
".
|
24
|
+
".ruby-gemset",
|
25
|
+
".ruby-version",
|
23
26
|
".travis.yml",
|
24
27
|
"Gemfile",
|
25
28
|
"LICENSE.txt",
|
@@ -27,9 +30,15 @@ Gem::Specification.new do |s|
|
|
27
30
|
"Rakefile",
|
28
31
|
"VERSION",
|
29
32
|
"lib/api_utils.rb",
|
33
|
+
"lib/crm.rb",
|
34
|
+
"lib/crud_methods.rb",
|
30
35
|
"lib/ruby_zoho.rb",
|
31
36
|
"lib/zoho_api.rb",
|
32
|
-
"
|
37
|
+
"lib/zoho_api_field_utils.rb",
|
38
|
+
"lib/zoho_api_finders.rb",
|
39
|
+
"lib/zoho_crm_users.rb",
|
40
|
+
"lib/zoho_crm_utils.rb",
|
41
|
+
"rubyzoho-0.1.7.gem",
|
33
42
|
"rubyzoho.gemspec",
|
34
43
|
"spec/api_utils_spec.rb",
|
35
44
|
"spec/fixtures/sample.pdf",
|
@@ -45,15 +54,16 @@ Gem::Specification.new do |s|
|
|
45
54
|
s.homepage = "http://github.com/amalc/rubyzoho"
|
46
55
|
s.licenses = ["MIT"]
|
47
56
|
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = "1.
|
57
|
+
s.rubygems_version = "2.1.11"
|
49
58
|
s.summary = "A set of Ruby classes supporting the ActiveRecord lifecycle for the Zoho API."
|
50
59
|
|
51
60
|
if s.respond_to? :specification_version then
|
52
|
-
s.specification_version =
|
61
|
+
s.specification_version = 4
|
53
62
|
|
54
63
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
55
|
-
s.add_runtime_dependency(%q<
|
56
|
-
s.add_runtime_dependency(%q<
|
64
|
+
s.add_runtime_dependency(%q<activemodel>, [">= 0"])
|
65
|
+
s.add_runtime_dependency(%q<httmultiparty>, [">= 0"])
|
66
|
+
s.add_runtime_dependency(%q<roxml>, [">= 0"])
|
57
67
|
s.add_runtime_dependency(%q<multipart-post>, [">= 0"])
|
58
68
|
s.add_development_dependency(%q<bundler>, [">= 1.2"])
|
59
69
|
s.add_development_dependency(%q<cucumber>, [">= 1.2.1"])
|
@@ -64,8 +74,9 @@ Gem::Specification.new do |s|
|
|
64
74
|
s.add_development_dependency(%q<rspec>, [">= 2.12.0"])
|
65
75
|
s.add_development_dependency(%q<xml-simple>, [">= 1.1.2"])
|
66
76
|
else
|
67
|
-
s.add_dependency(%q<
|
68
|
-
s.add_dependency(%q<
|
77
|
+
s.add_dependency(%q<activemodel>, [">= 0"])
|
78
|
+
s.add_dependency(%q<httmultiparty>, [">= 0"])
|
79
|
+
s.add_dependency(%q<roxml>, [">= 0"])
|
69
80
|
s.add_dependency(%q<multipart-post>, [">= 0"])
|
70
81
|
s.add_dependency(%q<bundler>, [">= 1.2"])
|
71
82
|
s.add_dependency(%q<cucumber>, [">= 1.2.1"])
|
@@ -77,8 +88,9 @@ Gem::Specification.new do |s|
|
|
77
88
|
s.add_dependency(%q<xml-simple>, [">= 1.1.2"])
|
78
89
|
end
|
79
90
|
else
|
80
|
-
s.add_dependency(%q<
|
81
|
-
s.add_dependency(%q<
|
91
|
+
s.add_dependency(%q<activemodel>, [">= 0"])
|
92
|
+
s.add_dependency(%q<httmultiparty>, [">= 0"])
|
93
|
+
s.add_dependency(%q<roxml>, [">= 0"])
|
82
94
|
s.add_dependency(%q<multipart-post>, [">= 0"])
|
83
95
|
s.add_dependency(%q<bundler>, [">= 1.2"])
|
84
96
|
s.add_dependency(%q<cucumber>, [">= 1.2.1"])
|
data/spec/ruby_zoho_spec.rb
CHANGED
@@ -9,14 +9,14 @@ describe RubyZoho::Crm do
|
|
9
9
|
base_path = File.join(File.dirname(__FILE__), 'fixtures')
|
10
10
|
@sample_pdf = File.join(base_path, 'sample.pdf')
|
11
11
|
RubyZoho.configure do |config|
|
12
|
-
config.api_key =
|
12
|
+
config.api_key = ENV['ZOHO_API_KEY'].strip
|
13
13
|
config.crm_modules = %w(Quotes)
|
14
14
|
config.cache_fields = true
|
15
15
|
end
|
16
16
|
r = RubyZoho::Crm::Contact.find_by_last_name('Smithereens')
|
17
17
|
r.each { |m| RubyZoho::Crm::Contact.delete(m.contactid) } unless r.nil?
|
18
18
|
r = RubyZoho::Crm::Contact.find_by_email('raj@portra.com')
|
19
|
-
r.each { |c|
|
19
|
+
r.each { |c| RubyZoho::Crm::Contact.delete(c.contactid) } unless r.nil?
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should add accessors using a list of names' do
|
@@ -63,7 +63,7 @@ describe RubyZoho::Crm do
|
|
63
63
|
:priority => 'High',
|
64
64
|
:send_notification_email => 'False',
|
65
65
|
:due_date => '2014-02-16 16:00:00',
|
66
|
-
:start_datetime => Time.now.to_s[1,19],
|
66
|
+
:start_datetime => Time.now.to_s[1, 19],
|
67
67
|
:end_datetime => '2014-02-16 16:00:00'
|
68
68
|
)
|
69
69
|
r = RubyZoho::Crm::Task.find_by_subject(subject)
|
@@ -80,9 +80,9 @@ describe RubyZoho::Crm do
|
|
80
80
|
r.each { |m| RubyZoho::Crm::Contact.delete(m.id) } unless r.nil?
|
81
81
|
1.upto(3) do
|
82
82
|
c = RubyZoho::Crm::Contact.new(
|
83
|
-
|
84
|
-
|
85
|
-
|
83
|
+
:first_name => 'Bob',
|
84
|
+
:last_name => 'Smithereens',
|
85
|
+
:email => 'bob@smith.com')
|
86
86
|
c.save
|
87
87
|
end
|
88
88
|
r = RubyZoho::Crm::Contact.find_by_email('bob@smith.com')
|
@@ -113,8 +113,8 @@ describe RubyZoho::Crm do
|
|
113
113
|
end
|
114
114
|
|
115
115
|
it 'should find a user by email address' do
|
116
|
-
users = RubyZoho::Crm::
|
117
|
-
r = RubyZoho::Crm::
|
116
|
+
users = RubyZoho::Crm::CRMUser.all
|
117
|
+
r = RubyZoho::Crm::CRMUser.find_by_email(users.first.email)
|
118
118
|
r.first.email.should eq(users.first.email)
|
119
119
|
end
|
120
120
|
|
@@ -125,7 +125,7 @@ describe RubyZoho::Crm do
|
|
125
125
|
|
126
126
|
it 'should get a list of attr_writers for contacts' do
|
127
127
|
c = RubyZoho::Crm::Contact.new
|
128
|
-
c.attr_writers.count.should be >=
|
128
|
+
c.attr_writers.count.should be >= 10
|
129
129
|
end
|
130
130
|
|
131
131
|
it 'should get a list of attr_writers for leads' do
|
@@ -155,12 +155,10 @@ describe RubyZoho::Crm do
|
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'should get a list of calls' do
|
158
|
-
#pending
|
159
158
|
r = RubyZoho::Crm::Call.all
|
160
159
|
unless r.nil?
|
161
|
-
#r.count.should be > 1
|
162
160
|
r.map { |e| e.class.should eq(RubyZoho::Crm::Call) }
|
163
|
-
r.map { |e| e.id.should eq(e.activityid)}
|
161
|
+
r.map { |e| e.id.should eq(e.activityid) }
|
164
162
|
end
|
165
163
|
end
|
166
164
|
|
@@ -168,61 +166,63 @@ describe RubyZoho::Crm do
|
|
168
166
|
r = RubyZoho::Crm::Contact.all
|
169
167
|
r.count.should be > 1
|
170
168
|
r.map { |e| e.class.should eq(RubyZoho::Crm::Contact) }
|
171
|
-
r.map { |e| e.id.should eq(e.contactid)}
|
169
|
+
r.map { |e| e.id.should eq(e.contactid) }
|
172
170
|
end
|
173
171
|
|
174
172
|
it 'should get a list of events' do
|
173
|
+
pending
|
175
174
|
r = RubyZoho::Crm::Event.all
|
176
175
|
r.map { |r| r.class.should eq(RubyZoho::Crm::Event) } unless r.nil?
|
177
|
-
r.map { |e| e.id.should eq(e.eventid)}
|
176
|
+
r.map { |e| e.id.should eq(e.eventid) }
|
178
177
|
end
|
179
178
|
|
180
179
|
it 'should get a list of potentials' do
|
181
180
|
r = RubyZoho::Crm::Potential.all
|
182
181
|
r.count.should be > 1
|
183
182
|
r.map { |r| r.class.should eq(RubyZoho::Crm::Potential) }
|
184
|
-
r.map { |e| e.id.should eq(e.potentialid)}
|
183
|
+
r.map { |e| e.id.should eq(e.potentialid) }
|
185
184
|
end
|
186
185
|
|
187
186
|
it 'should get a list of quotes' do
|
187
|
+
pending
|
188
188
|
r = RubyZoho::Crm::Quote.all
|
189
189
|
r.count.should be >= 1
|
190
190
|
r.map { |r| r.class.should eq(RubyZoho::Crm::Quote) }
|
191
|
-
r.map { |e| e.id.should eq(e.quoteid)}
|
191
|
+
r.map { |e| e.id.should eq(e.quoteid) }
|
192
192
|
end
|
193
193
|
|
194
194
|
it 'should get a list of tasks' do
|
195
195
|
r = RubyZoho::Crm::Task.all
|
196
196
|
r.map { |r| r.class.should eq(RubyZoho::Crm::Task) } unless r.nil?
|
197
|
-
r.map { |e| e.id.should eq(e.activityid)}
|
197
|
+
r.map { |e| e.id.should eq(e.activityid) }
|
198
198
|
end
|
199
199
|
|
200
200
|
it 'should get a list of users' do
|
201
|
-
|
201
|
+
r = RubyZoho::Crm::CRMUser.all
|
202
202
|
r.count.should be >= 1
|
203
203
|
end
|
204
204
|
|
205
205
|
it 'should save a contact record' do
|
206
206
|
c = RubyZoho::Crm::Contact.new(
|
207
|
-
|
208
|
-
|
209
|
-
|
207
|
+
:first_name => 'Raj',
|
208
|
+
:last_name => 'Portra',
|
209
|
+
:email => 'raj@portra.com')
|
210
210
|
c.save
|
211
211
|
r = RubyZoho::Crm::Contact.find_by_email('raj@portra.com')
|
212
212
|
r.first.email.should eq('raj@portra.com')
|
213
|
-
r.each { |c|
|
213
|
+
r.each { |c| RubyZoho::Crm::Contact.delete(c.contactid) }
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'should save a lead record' do
|
217
217
|
l = RubyZoho::Crm::Lead.new(
|
218
|
-
|
219
|
-
|
220
|
-
|
218
|
+
:first_name => 'Raj',
|
219
|
+
:last_name => 'Portra',
|
220
|
+
:email => 'raj@portra.com')
|
221
221
|
l.save
|
222
222
|
r = RubyZoho::Crm::Lead.find_by_email('raj@portra.com')
|
223
223
|
r.should_not eq(nil)
|
224
224
|
r.first.email.should eq(l.email)
|
225
|
-
r.each { |c|
|
225
|
+
r.each { |c| RubyZoho::Crm::Lead.delete(c.id) }
|
226
226
|
end
|
227
227
|
|
228
228
|
it 'should save and retrieve an account record with a custom field' do
|
@@ -248,7 +248,7 @@ describe RubyZoho::Crm do
|
|
248
248
|
:type => 'New Business',
|
249
249
|
:stage => 'Needs Analysis'}
|
250
250
|
r = RubyZoho::Crm::Potential.find_by_potential_name(h[:potential_name])
|
251
|
-
r.each { |c|
|
251
|
+
r.each { |c| RubyZoho::Crm::Potential.delete(c.potentialid) } unless r.nil?
|
252
252
|
p = RubyZoho::Crm::Potential.new(h)
|
253
253
|
p.save
|
254
254
|
r = RubyZoho::Crm::Potential.find_by_potential_name(p.potential_name)
|
@@ -256,9 +256,9 @@ describe RubyZoho::Crm do
|
|
256
256
|
potential = RubyZoho::Crm::Potential.find(r.first.potentialid)
|
257
257
|
potential.first.potentialid.should eq(r.first.potentialid)
|
258
258
|
p_by_account_id = RubyZoho::Crm::Potential.find_by_accountid(accounts.first.accountid)
|
259
|
-
p_found = p_by_account_id.map { |pn| pn if pn.potential_name == h[:potential_name]}.compact
|
259
|
+
p_found = p_by_account_id.map { |pn| pn if pn.potential_name == h[:potential_name] }.compact
|
260
260
|
p_found.first.potentialid.should eq(r.first.potentialid)
|
261
|
-
r.each { |c|
|
261
|
+
r.each { |c| RubyZoho::Crm::Potential.delete(c.potentialid) }
|
262
262
|
end
|
263
263
|
|
264
264
|
it 'should save and retrieve a task record' do
|
@@ -269,22 +269,22 @@ describe RubyZoho::Crm do
|
|
269
269
|
:semodule => 'Accounts',
|
270
270
|
:relatedtoid => accounts.first.accountid,
|
271
271
|
:related_to => accounts.first.account_name,
|
272
|
-
:priority => 'Low'
|
272
|
+
:priority => 'Low'}
|
273
273
|
r = RubyZoho::Crm::Task.find_by_subject(h[:subject])
|
274
|
-
r.each { |t|
|
274
|
+
r.each { |t| RubyZoho::Crm::Task.delete(t.activityid) } unless r.nil?
|
275
275
|
t = RubyZoho::Crm::Task.new(h)
|
276
276
|
t.save
|
277
277
|
r = RubyZoho::Crm::Task.find_by_subject(h[:subject])
|
278
278
|
r.first.subject.should eq(h[:subject])
|
279
279
|
tasks = RubyZoho::Crm::Task.find_by_activityid(r.first.activityid)
|
280
280
|
tasks.first.activityid.should eq(r.first.activityid)
|
281
|
-
r.each { |c|
|
281
|
+
r.each { |c| RubyZoho::Crm::Task.delete(c.activityid) }
|
282
282
|
end
|
283
283
|
|
284
284
|
it 'should save an task record related to an account' do
|
285
285
|
a = RubyZoho::Crm::Account.all.first
|
286
286
|
e = RubyZoho::Crm::Task.new(
|
287
|
-
:task_owner =>
|
287
|
+
:task_owner => a.account_owner,
|
288
288
|
:subject => "Task should be related to #{a.account_name} #{Time.now}",
|
289
289
|
:description => 'Nothing',
|
290
290
|
:smownerid => "#{a.smownerid}",
|
@@ -292,38 +292,37 @@ describe RubyZoho::Crm do
|
|
292
292
|
:priority => 'High',
|
293
293
|
:send_notification_email => 'False',
|
294
294
|
:due_date => '2014-02-16 16:00:00',
|
295
|
-
:start_datetime => Time.now.to_s[1,19],
|
295
|
+
:start_datetime => Time.now.to_s[1, 19],
|
296
296
|
:end_datetime => '2014-02-16 16:00:00',
|
297
297
|
:related_to => "#{a.account_name}",
|
298
298
|
:seid => "#{a.accountid}",
|
299
299
|
:semodule => "Accounts"
|
300
300
|
)
|
301
|
-
r_expected
|
301
|
+
r_expected = e.save
|
302
302
|
r = RubyZoho::Crm::Task.find_by_activityid(r_expected.id)
|
303
303
|
r.first.subject.should eq(r_expected.subject)
|
304
304
|
end
|
305
305
|
|
306
306
|
it 'should get tasks by user' do
|
307
307
|
pending
|
308
|
-
pp
|
309
|
-
pp tasks = RubyZoho::Crm::Task.
|
310
|
-
|
311
|
-
tasks.map { |t| RubyZoho::Crm::Task.delete(t.activityid)} unless tasks.nil?
|
308
|
+
pp task_owner = RubyZoho::Crm::Task.first.task_owner
|
309
|
+
pp tasks = RubyZoho::Crm::Task.find_by_task_owner(task_owner)
|
310
|
+
#tasks.map { |t| RubyZoho::Crm::Task.delete(t.activityid)} unless tasks.nil?
|
312
311
|
end
|
313
312
|
|
314
313
|
it 'should sort contact records' do
|
315
314
|
r = RubyZoho::Crm::Contact.all
|
316
|
-
sorted =
|
315
|
+
sorted = r.sort { |a, b| a.last_name <=> b.last_name }
|
317
316
|
sorted.collect { |c| c.last_name }.should_not eq(nil)
|
318
317
|
end
|
319
318
|
|
320
319
|
it 'should update a lead record' do
|
321
320
|
r_changed = RubyZoho::Crm::Lead.find_by_email('changed_raj@portra.com')
|
322
|
-
r_changed.each { |c|
|
321
|
+
r_changed.each { |c| RubyZoho::Crm::Lead.delete(c.leadid) } unless r_changed.nil?
|
323
322
|
l = RubyZoho::Crm::Lead.new(
|
324
|
-
|
325
|
-
|
326
|
-
|
323
|
+
:first_name => 'Raj',
|
324
|
+
:last_name => 'Portra',
|
325
|
+
:email => 'raj@portra.com')
|
327
326
|
l.save
|
328
327
|
r = RubyZoho::Crm::Lead.find_by_email('raj@portra.com')
|
329
328
|
RubyZoho::Crm::Lead.update(
|
@@ -332,15 +331,15 @@ describe RubyZoho::Crm do
|
|
332
331
|
)
|
333
332
|
r_changed = RubyZoho::Crm::Lead.find_by_email('changed_raj@portra.com')
|
334
333
|
r.first.leadid.should eq(r_changed.first.leadid)
|
335
|
-
r.each { |c|
|
336
|
-
r_changed.each { |c|
|
334
|
+
r.each { |c| RubyZoho::Crm::Lead.delete(c.leadid) }
|
335
|
+
r_changed.each { |c| RubyZoho::Crm::Lead.delete(c.leadid) }
|
337
336
|
end
|
338
337
|
|
339
338
|
it 'should validate a field name' do
|
340
|
-
good_names = ['This is OK', 'OK_to_use']
|
341
|
-
bad_names = ['This
|
342
|
-
good_names.map { |f| RubyZoho::Crm.method_name?(ApiUtils.string_to_symbol(f)).should_not eq(false)}
|
343
|
-
bad_names.map { |f| RubyZoho::Crm.method_name?(ApiUtils.string_to_symbol(f)).should eq(false)}
|
339
|
+
good_names = ['This is OK', 'OK_to_use', 'field()']
|
340
|
+
bad_names = ['This %#{@} is not']
|
341
|
+
good_names.map { |f| RubyZoho::Crm.method_name?(ApiUtils.string_to_symbol(f)).should_not eq(false) }
|
342
|
+
bad_names.map { |f| RubyZoho::Crm.method_name?(ApiUtils.string_to_symbol(f)).should eq(false) }
|
344
343
|
end
|
345
344
|
|
346
345
|
end
|