rubyzoho 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +26 -6
- data/VERSION +1 -1
- data/lib/ruby_zoho.rb +94 -8
- data/lib/zoho_api.rb +57 -23
- data/rubyzoho-0.1.1.gem +0 -0
- data/rubyzoho.gemspec +3 -2
- data/spec/ruby_zoho_spec.rb +40 -17
- data/spec/zoho_api_spec.rb +41 -9
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
{<img src="https://travis-ci.org/amalc/rubyzoho.png?branch=master" alt="Build Status" />}[https://travis-ci.org/amalc/rubyzoho]
|
2
2
|
|
3
|
+
{<img src="https://gemnasium.com/amalc/rubyzoho.png" alt="Dependency Status" />}[https://gemnasium.com/amalc/rubyzoho]
|
4
|
+
|
3
5
|
= rubyzoho
|
4
6
|
|
5
7
|
Abstracting Zoho's API into a set of Ruby classes, with reflection of Zoho's fields using a more familiar
|
@@ -9,7 +11,21 @@ ActiveRecord lifecycle but without ActiveRecord.
|
|
9
11
|
gem install rubyzoho
|
10
12
|
|
11
13
|
== Configure
|
12
|
-
|
14
|
+
|
15
|
+
=== Rails
|
16
|
+
Put the following in an initializer (e.g. <tt><RAILS_ROOT>/config/initializers/zoho.rb</tt>):
|
17
|
+
|
18
|
+
require 'ruby_zoho'
|
19
|
+
|
20
|
+
RubyZoho.configure do |config|
|
21
|
+
config.api_key = '<< API Key from Zoho>>'
|
22
|
+
# config.crm_modules = ['Accounts', 'Contacts', 'Leads', 'Potentials'] # Defaults to free edition if not set
|
23
|
+
# config.crm_modules = ['Quotes', 'SalesOrders', 'Invoices'] # Depending on what kind of account you've got, adds to free edition modules
|
24
|
+
# Currently only Quotes are suported
|
25
|
+
end
|
26
|
+
|
27
|
+
=== Ruby
|
28
|
+
Make sure the following block is executed prior to making calls to the gem.
|
13
29
|
|
14
30
|
require 'ruby_zoho'
|
15
31
|
|
@@ -23,9 +39,10 @@ Please be aware that Zoho limits API calls. So running tests repeatedly will qui
|
|
23
39
|
your daily allowance.
|
24
40
|
|
25
41
|
|
42
|
+
|
26
43
|
== Use
|
27
|
-
RubyZoho attempts to follow the ActiveRecord lifecycle, i.e. new, save and delete
|
28
|
-
|
44
|
+
RubyZoho attempts to follow the ActiveRecord lifecycle, i.e. new, save, update and delete.
|
45
|
+
See examples below.
|
29
46
|
|
30
47
|
To get a list of supported attributes for a Zoho CRM contact:
|
31
48
|
|
@@ -52,8 +69,8 @@ To retrieve an existing record:
|
|
52
69
|
Returns one or more records matching the query. The find_by_<attribute> follows
|
53
70
|
ActiveRecord style reflections, so if the attribute is present in the API, it can
|
54
71
|
be queried. There is currently a single attribute limitation imposed by the Zoho
|
55
|
-
API. Note, what is returned is an Array class
|
56
|
-
|
72
|
+
API. Note, what is returned is an Array class which is also Enumerable. Use +.each+,
|
73
|
+
+.map+, +.first+, +.last+, etc to navigate through the result set.
|
57
74
|
|
58
75
|
Equality is the only match currently supported.
|
59
76
|
|
@@ -128,13 +145,16 @@ To update a record:
|
|
128
145
|
Objects currently supported are:
|
129
146
|
RubyZoho::Crm::Account
|
130
147
|
RubyZoho::Crm::Contact
|
148
|
+
RubyZoho::Crm::Event
|
131
149
|
RubyZoho::Crm::Lead
|
132
150
|
RubyZoho::Crm::Potential
|
151
|
+
RubyZoho::Crm::Task
|
133
152
|
RubyZoho::Crm::Quote
|
153
|
+
RubyZoho::Crm::User
|
134
154
|
|
135
155
|
|
136
156
|
==Bugs and Enhancments
|
137
|
-
Please open an issue on GitHub. Or better yet, send in a pull request
|
157
|
+
Please open an issue on GitHub. Or better yet, send in a pull request with the fix or enhancement!
|
138
158
|
|
139
159
|
---
|
140
160
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/ruby_zoho.rb
CHANGED
@@ -21,7 +21,7 @@ module RubyZoho
|
|
21
21
|
def self.configure
|
22
22
|
self.configuration ||= Configuration.new
|
23
23
|
yield(configuration) if block_given?
|
24
|
-
self.configuration.crm_modules ||= [
|
24
|
+
self.configuration.crm_modules ||= []
|
25
25
|
self.configuration.api = ZohoApi::Crm.new(self.configuration.api_key, self.configuration.crm_modules)
|
26
26
|
end
|
27
27
|
|
@@ -37,15 +37,17 @@ module RubyZoho
|
|
37
37
|
@fields = RubyZoho.configuration.api.module_fields[
|
38
38
|
ApiUtils.string_to_symbol(Crm.module_name)]
|
39
39
|
RubyZoho::Crm.create_accessor(self.class, @fields)
|
40
|
-
retry_counter =
|
40
|
+
retry_counter = object_attribute_hash.count
|
41
41
|
begin
|
42
42
|
object_attribute_hash.map { |(k, v)| public_send("#{k}=", v) }
|
43
43
|
rescue NoMethodError => e
|
44
|
-
m = e.message.slice(/`
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
m = e.message.slice(/`(.*?)=/)
|
45
|
+
unless m.nil?
|
46
|
+
m.gsub!('`', '')
|
47
|
+
RubyZoho::Crm.create_accessor(self.class, [m.chop])
|
48
|
+
end
|
49
|
+
retry_counter -= 1
|
50
|
+
retry if retry_counter > 0
|
49
51
|
end
|
50
52
|
self
|
51
53
|
end
|
@@ -67,7 +69,8 @@ module RubyZoho
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def self.method_name?(n)
|
70
|
-
|
72
|
+
name = n.class == String ? ApiUtils.string_to_symbol(n) : n
|
73
|
+
return /[@$"]/ !~ name.inspect
|
71
74
|
end
|
72
75
|
|
73
76
|
def self.create_getter(klass, *names)
|
@@ -189,6 +192,32 @@ module RubyZoho
|
|
189
192
|
end
|
190
193
|
|
191
194
|
|
195
|
+
class Event < RubyZoho::Crm
|
196
|
+
include RubyZoho
|
197
|
+
attr_reader :fields
|
198
|
+
Crm.module_name = 'Events'
|
199
|
+
|
200
|
+
def initialize(object_attribute_hash = {})
|
201
|
+
Crm.module_name = 'Events'
|
202
|
+
super
|
203
|
+
end
|
204
|
+
|
205
|
+
def self.all
|
206
|
+
Crm.module_name = 'Events'
|
207
|
+
super
|
208
|
+
end
|
209
|
+
|
210
|
+
def self.delete(id)
|
211
|
+
Crm.module_name = 'Events'
|
212
|
+
super
|
213
|
+
end
|
214
|
+
|
215
|
+
def self.method_missing(meth, *args, &block)
|
216
|
+
Crm.module_name = 'Events'
|
217
|
+
super
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
192
221
|
class Lead < RubyZoho::Crm
|
193
222
|
include RubyZoho
|
194
223
|
attr_reader :fields
|
@@ -241,6 +270,32 @@ module RubyZoho
|
|
241
270
|
end
|
242
271
|
end
|
243
272
|
|
273
|
+
class Task < RubyZoho::Crm
|
274
|
+
include RubyZoho
|
275
|
+
attr_reader :fields
|
276
|
+
Crm.module_name = 'Tasks'
|
277
|
+
|
278
|
+
def initialize(object_attribute_hash = {})
|
279
|
+
Crm.module_name = 'Tasks'
|
280
|
+
super
|
281
|
+
end
|
282
|
+
|
283
|
+
def self.all
|
284
|
+
Crm.module_name = 'Tasks'
|
285
|
+
super
|
286
|
+
end
|
287
|
+
|
288
|
+
def self.delete(id)
|
289
|
+
Crm.module_name = 'Tasks'
|
290
|
+
super
|
291
|
+
end
|
292
|
+
|
293
|
+
def self.method_missing(meth, *args, &block)
|
294
|
+
Crm.module_name = 'Tasks'
|
295
|
+
super
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
244
299
|
class Quote < RubyZoho::Crm
|
245
300
|
include RubyZoho
|
246
301
|
attr_reader :fields
|
@@ -267,6 +322,37 @@ module RubyZoho
|
|
267
322
|
end
|
268
323
|
end
|
269
324
|
|
325
|
+
class User < RubyZoho::Crm
|
326
|
+
def initialize(object_attribute_hash = {})
|
327
|
+
Crm.module_name = 'Users'
|
328
|
+
super
|
329
|
+
end
|
330
|
+
|
331
|
+
def self.delete(id)
|
332
|
+
raise 'Cannot delete users through API'
|
333
|
+
end
|
334
|
+
|
335
|
+
def save
|
336
|
+
raise 'Cannot delete users through API'
|
337
|
+
end
|
338
|
+
|
339
|
+
def self.all
|
340
|
+
result = RubyZoho.configuration.api.users('AllUsers')
|
341
|
+
result.collect { |r| new(r) }
|
342
|
+
end
|
343
|
+
|
344
|
+
def self.find_by_email(email)
|
345
|
+
r = []
|
346
|
+
self.all.index { |u| r << u if u.email == email }
|
347
|
+
r
|
348
|
+
end
|
349
|
+
|
350
|
+
def self.method_missing(meth, *args, &block)
|
351
|
+
Crm.module_name = 'Users'
|
352
|
+
super
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
270
356
|
end
|
271
357
|
|
272
358
|
end
|
data/lib/zoho_api.rb
CHANGED
@@ -18,6 +18,7 @@ module ZohoApi
|
|
18
18
|
include HTTMultiParty
|
19
19
|
|
20
20
|
@@module_fields = {}
|
21
|
+
@@users = []
|
21
22
|
|
22
23
|
#debug_output $stderr
|
23
24
|
|
@@ -25,7 +26,7 @@ module ZohoApi
|
|
25
26
|
|
26
27
|
def initialize(auth_token, modules)
|
27
28
|
@auth_token = auth_token
|
28
|
-
@modules = modules
|
29
|
+
@modules = %w(Accounts Contacts Events Leads Potentials Tasks Users).concat(modules).uniq
|
29
30
|
@module_fields = reflect_module_fields
|
30
31
|
end
|
31
32
|
|
@@ -38,8 +39,7 @@ module ZohoApi
|
|
38
39
|
:query => { :newFormat => 1, :authtoken => @auth_token,
|
39
40
|
:scope => 'crmapi', :xmlData => x },
|
40
41
|
:headers => { 'Content-length' => '0' })
|
41
|
-
|
42
|
-
r.response.code
|
42
|
+
check_for_errors(r)
|
43
43
|
end
|
44
44
|
|
45
45
|
def add_field(row, field, value)
|
@@ -90,9 +90,13 @@ module ZohoApi
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def check_for_errors(response)
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
raise(RuntimeError, "Web service call failed with #{response.code}") unless response.code == 200
|
94
|
+
x = REXML::Document.new(response.body)
|
95
|
+
code = REXML::XPath.first(x, '//code')
|
96
|
+
raise(RuntimeError, "Zoho Error Code #{code.text}: #{REXML::XPath.first(x, '//message').text}.") unless
|
97
|
+
code.nil? || ['4422', '5000'].index(code.text)
|
98
|
+
return code.text unless code.nil?
|
99
|
+
response.code
|
96
100
|
end
|
97
101
|
|
98
102
|
def create_url(module_name, api_call)
|
@@ -109,21 +113,14 @@ module ZohoApi
|
|
109
113
|
end
|
110
114
|
|
111
115
|
def fields(module_name)
|
116
|
+
return user_fields if module_name == 'Users'
|
112
117
|
mod_name = ApiUtils.string_to_symbol(module_name)
|
113
118
|
return @@module_fields[mod_name] unless @@module_fields[mod_name].nil?
|
114
119
|
r = self.class.post(create_url(module_name, 'getFields'),
|
115
120
|
:query => { :authtoken => @auth_token, :scope => 'crmapi' },
|
116
121
|
:headers => { 'Content-length' => '0' })
|
117
|
-
@@module_fields[mod_name] = []
|
118
|
-
x = REXML::Document.new(r.body)
|
119
|
-
REXML::XPath.each(x, "/#{module_name}/section/FL/@dv") do |f|
|
120
|
-
field = ApiUtils.string_to_symbol(f.to_s)
|
121
|
-
@@module_fields[mod_name] << field if method_name?(field)
|
122
|
-
end
|
123
|
-
raise('Getting fields failed', RuntimeError, module_name) unless r.response.code == '200'
|
124
122
|
check_for_errors(r)
|
125
|
-
|
126
|
-
@@module_fields
|
123
|
+
update_module_fields(mod_name, module_name, r)
|
127
124
|
end
|
128
125
|
|
129
126
|
def first(module_name)
|
@@ -142,7 +139,6 @@ module ZohoApi
|
|
142
139
|
:query => {:newFormat => 1, :authtoken => @auth_token, :scope => 'crmapi',
|
143
140
|
:selectColumns => 'All', :searchCondition => search_condition,
|
144
141
|
:fromIndex => 1, :toIndex => NUMBER_OF_RECORDS_TO_GET})
|
145
|
-
raise(RuntimeError, 'Bad query', "#{sc_field} #{condition} #{value}") unless r.body.index('<error>').nil?
|
146
142
|
check_for_errors(r)
|
147
143
|
x = REXML::Document.new(r.body).elements.to_a("/response/result/#{module_name}/row")
|
148
144
|
to_hash(x)
|
@@ -167,15 +163,16 @@ module ZohoApi
|
|
167
163
|
@@module_fields
|
168
164
|
end
|
169
165
|
|
170
|
-
def related_records(
|
171
|
-
r = self.class.get(create_url("#{
|
166
|
+
def related_records(parent_module, parent_record_id, related_module)
|
167
|
+
r = self.class.get(create_url("#{related_module}", 'getRelatedRecords'),
|
172
168
|
:query => { :newFormat => 1, :authtoken => @auth_token, :scope => 'crmapi',
|
173
|
-
:parentModule =>
|
174
|
-
|
175
|
-
|
176
|
-
x = REXML::Document.new(r.body).elements.to_a("/response/result/#{
|
169
|
+
:parentModule => parent_module, :id => parent_record_id})
|
170
|
+
|
171
|
+
pp r.body
|
172
|
+
x = REXML::Document.new(r.body).elements.to_a("/response/result/#{parent_module}/row")
|
177
173
|
puts "====="
|
178
|
-
pp
|
174
|
+
pp check_for_errors(r)
|
175
|
+
return nil unless check_for_errors(r).nil?
|
179
176
|
end
|
180
177
|
|
181
178
|
def some(module_name, index = 1, number_of_records = nil)
|
@@ -203,6 +200,18 @@ module ZohoApi
|
|
203
200
|
r
|
204
201
|
end
|
205
202
|
|
203
|
+
def update_module_fields(mod_name, module_name, r)
|
204
|
+
@@module_fields[mod_name] = []
|
205
|
+
x = REXML::Document.new(r.body)
|
206
|
+
REXML::XPath.each(x, "/#{module_name}/section/FL/@dv") do |f|
|
207
|
+
field = ApiUtils.string_to_symbol(f.to_s)
|
208
|
+
@@module_fields[mod_name] << field if method_name?(field)
|
209
|
+
end
|
210
|
+
@@module_fields[mod_name] << ApiUtils.string_to_symbol(module_name.chop + 'id')
|
211
|
+
return @@module_fields[mod_name] unless @@module_fields.nil?
|
212
|
+
nil
|
213
|
+
end
|
214
|
+
|
206
215
|
def update_record(module_name, id, fields_values_hash)
|
207
216
|
x = REXML::Document.new
|
208
217
|
contacts = x.add_element module_name
|
@@ -218,6 +227,31 @@ module ZohoApi
|
|
218
227
|
r.response.code
|
219
228
|
end
|
220
229
|
|
230
|
+
def user_fields
|
231
|
+
@@module_fields[:users] = users[0].keys
|
232
|
+
end
|
233
|
+
|
234
|
+
def users(user_type = 'AllUsers')
|
235
|
+
return @@users unless @@users == [] || user_type == 'Refresh'
|
236
|
+
r = self.class.get(create_url('Users', 'getUsers'),
|
237
|
+
:query => { :newFormat => 1, :authtoken => @auth_token, :scope => 'crmapi',
|
238
|
+
:type => 'AllUsers' })
|
239
|
+
check_for_errors(r)
|
240
|
+
x = REXML::Document.new(r.body).elements.to_a("/users")
|
241
|
+
result = []
|
242
|
+
x.each do |e|
|
243
|
+
e.elements.to_a.each do |n|
|
244
|
+
record = {}
|
245
|
+
record.merge!( { :user_name => n.text })
|
246
|
+
n.attributes.each_pair do |k, v|
|
247
|
+
record.merge!({ k.to_s.to_sym => v.to_string.match(/'(.*?)'/).to_s.gsub("'", '') })
|
248
|
+
end
|
249
|
+
result << record
|
250
|
+
end
|
251
|
+
end
|
252
|
+
@@users = result
|
253
|
+
end
|
254
|
+
|
221
255
|
end
|
222
256
|
|
223
257
|
end
|
data/rubyzoho-0.1.1.gem
ADDED
Binary file
|
data/rubyzoho.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rubyzoho"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["amalc"]
|
12
|
-
s.date = "2013-02-
|
12
|
+
s.date = "2013-02-18"
|
13
13
|
s.description = ""
|
14
14
|
s.email = ""
|
15
15
|
s.extra_rdoc_files = [
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"lib/api_utils.rb",
|
31
31
|
"lib/ruby_zoho.rb",
|
32
32
|
"lib/zoho_api.rb",
|
33
|
+
"rubyzoho-0.1.1.gem",
|
33
34
|
"rubyzoho.gemspec",
|
34
35
|
"spec/api_utils_spec.rb",
|
35
36
|
"spec/fixtures/sample.pdf",
|
data/spec/ruby_zoho_spec.rb
CHANGED
@@ -13,12 +13,12 @@ describe RubyZoho::Crm do
|
|
13
13
|
#config.api_key = params['auth_token']
|
14
14
|
#config.api_key = 'e194b2951fb238e26bc096de9d0cf5f8'
|
15
15
|
config.api_key = '62cedfe9427caef8afb9ea3b5bf68154'
|
16
|
-
config.crm_modules =
|
16
|
+
config.crm_modules = %w(Quotes)
|
17
17
|
end
|
18
|
-
r = RubyZoho::Crm::Contact.find_by_last_name('Smithereens')
|
19
|
-
r.each { |m| RubyZoho::Crm::Contact.delete(m.contactid) } unless r.nil?
|
20
|
-
r = RubyZoho::Crm::Contact.find_by_email('raj@portra.com')
|
21
|
-
r.each { |c| RubyZoho::Crm::Contact.delete(c.contactid) } unless r.nil?
|
18
|
+
#r = RubyZoho::Crm::Contact.find_by_last_name('Smithereens')
|
19
|
+
#r.each { |m| RubyZoho::Crm::Contact.delete(m.contactid) } unless r.nil?
|
20
|
+
#r = RubyZoho::Crm::Contact.find_by_email('raj@portra.com')
|
21
|
+
#r.each { |c| RubyZoho::Crm::Contact.delete(c.contactid) } unless r.nil?
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should add accessors using a list of names' do
|
@@ -50,6 +50,28 @@ describe RubyZoho::Crm do
|
|
50
50
|
r.each { |m| RubyZoho::Crm::Contact.delete(m.contactid) }
|
51
51
|
end
|
52
52
|
|
53
|
+
it 'should find a contact by ID' do
|
54
|
+
contacts = RubyZoho::Crm::Contact.all
|
55
|
+
contact_id = contacts.first.contactid
|
56
|
+
c = RubyZoho::Crm::Contact.find_by_contactid(contact_id)
|
57
|
+
c.first.contactid.should eq(contact_id)
|
58
|
+
c.first.last_name.should eq(contacts.first.last_name)
|
59
|
+
c.first.email.should eq(contacts.first.email)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should find a lead by ID' do
|
63
|
+
leads = RubyZoho::Crm::Lead.all
|
64
|
+
lead_id = leads.first.leadid
|
65
|
+
l = RubyZoho::Crm::Lead.find_by_leadid(lead_id)
|
66
|
+
l.first.leadid.should eq(lead_id)
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should find a user by email address' do
|
70
|
+
users = RubyZoho::Crm::User.all
|
71
|
+
r = RubyZoho::Crm::User.find_by_email(users.first.email)
|
72
|
+
r.first.email.should eq(users.first.email)
|
73
|
+
end
|
74
|
+
|
53
75
|
it 'should get a list of attr_writers for accounts' do
|
54
76
|
c = RubyZoho::Crm::Account.new
|
55
77
|
c.attr_writers.count.should be >= 18
|
@@ -87,6 +109,12 @@ describe RubyZoho::Crm do
|
|
87
109
|
r.map { |r| r.class.should eq(RubyZoho::Crm::Contact) }
|
88
110
|
end
|
89
111
|
|
112
|
+
it 'should get a list of events' do
|
113
|
+
r = RubyZoho::Crm::Event.all
|
114
|
+
r.count.should be > 1
|
115
|
+
r.map { |r| r.class.should eq(RubyZoho::Crm::Event) }
|
116
|
+
end
|
117
|
+
|
90
118
|
it 'should get a list of potentials' do
|
91
119
|
r = RubyZoho::Crm::Potential.all
|
92
120
|
r.count.should be > 1
|
@@ -99,20 +127,15 @@ describe RubyZoho::Crm do
|
|
99
127
|
r.map { |r| r.class.should eq(RubyZoho::Crm::Quote) }
|
100
128
|
end
|
101
129
|
|
102
|
-
it 'should
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
c.first.contactid.should eq(contact_id)
|
107
|
-
c.first.last_name.should eq(contacts.first.last_name)
|
108
|
-
c.first.email.should eq(contacts.first.email)
|
130
|
+
it 'should get a list of tasks' do
|
131
|
+
r = RubyZoho::Crm::Task.all
|
132
|
+
r.count.should be > 1
|
133
|
+
r.map { |r| r.class.should eq(RubyZoho::Crm::Task) }
|
109
134
|
end
|
110
135
|
|
111
|
-
it 'should
|
112
|
-
|
113
|
-
|
114
|
-
l = RubyZoho::Crm::Lead.find_by_leadid(lead_id)
|
115
|
-
l.first.leadid.should eq(lead_id)
|
136
|
+
it 'should get a list of users' do
|
137
|
+
r = RubyZoho::Crm::User.all
|
138
|
+
r.count.should be >= 1
|
116
139
|
end
|
117
140
|
|
118
141
|
it 'should save a contact record' do
|
data/spec/zoho_api_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe ZohoApi do
|
|
25
25
|
#params = YAML.load(File.open(config_file))
|
26
26
|
#@zoho = ZohoApi::Crm.new(params['auth_token'])
|
27
27
|
@sample_pdf = File.join(base_path, 'sample.pdf')
|
28
|
-
modules = ['Accounts', 'Contacts', 'Leads', 'Potentials']
|
28
|
+
modules = ['Accounts', 'Contacts', 'Events', 'Leads', 'Tasks', 'Potentials']
|
29
29
|
#api_key = '783539943dc16d7005b0f3b78367d5d2'
|
30
30
|
#api_key = 'e194b2951fb238e26bc096de9d0cf5f8'
|
31
31
|
api_key = '62cedfe9427caef8afb9ea3b5bf68154'
|
@@ -37,8 +37,8 @@ describe ZohoApi do
|
|
37
37
|
:phone => '13452129087',
|
38
38
|
:mobile => '12341238790'
|
39
39
|
}
|
40
|
-
contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
|
41
|
-
contacts.each { |c| @zoho.delete_record('Contacts', c[:contactid]) } unless contacts.nil?
|
40
|
+
#contacts = @zoho.find_records('Contacts', :email, '=', @h_smith[:email])
|
41
|
+
#contacts.each { |c| @zoho.delete_record('Contacts', c[:contactid]) } unless contacts.nil?
|
42
42
|
end
|
43
43
|
|
44
44
|
it 'should add a new contact' do
|
@@ -81,14 +81,25 @@ describe ZohoApi do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should get a list of fields for a module' do
|
84
|
+
r = @zoho.fields('Accounts')
|
85
|
+
r.count.should >= 30
|
84
86
|
r = @zoho.fields('Contacts')
|
85
87
|
r.count.should be >= 35
|
88
|
+
r = @zoho.fields('Events')
|
89
|
+
r.count.should >= 10
|
86
90
|
r = @zoho.fields('Leads')
|
87
91
|
r.count.should be >= 23
|
88
92
|
r = @zoho.fields('Potentials')
|
89
93
|
r.count.should be >= 15
|
90
|
-
r = @zoho.fields('
|
91
|
-
r.count.should >=
|
94
|
+
r = @zoho.fields('Tasks')
|
95
|
+
r.count.should >= 10
|
96
|
+
r = @zoho.fields('Users')
|
97
|
+
r.count.should >= 7
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'should get a list of user fields' do
|
101
|
+
r = @zoho.user_fields
|
102
|
+
r.count.should be >= 7
|
92
103
|
end
|
93
104
|
|
94
105
|
it 'should retrieve records by module name' do
|
@@ -100,10 +111,31 @@ describe ZohoApi do
|
|
100
111
|
|
101
112
|
it 'should return related records by module and id' do
|
102
113
|
pending
|
103
|
-
r = @zoho.some('
|
104
|
-
pp r
|
105
|
-
related = @zoho.related_records('
|
106
|
-
|
114
|
+
r = @zoho.some('Accounts').first
|
115
|
+
pp r
|
116
|
+
related = @zoho.related_records('Accounts', r[:accountid], 'Attachments')
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should return events' do
|
120
|
+
r = @zoho.some('Events').first
|
121
|
+
r.should_not eq(nil)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'should return users' do
|
125
|
+
r = @zoho.users
|
126
|
+
r.should_not eq(nil)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should do a full CRUD lifecycle on tasks' do
|
130
|
+
pending
|
131
|
+
mod_name = 'Tasks'
|
132
|
+
fields = @zoho.fields(mod_name)
|
133
|
+
fields.count >= 10
|
134
|
+
fields.index(:task_owner).should_not eq(nil)
|
135
|
+
@zoho.add_record(mod_name, {:task_owner => 'Task Owner', :subject => 'Test Task', :due_date => '1/1/2100'})
|
136
|
+
r = @zoho.some(mod_name).first
|
137
|
+
pp r
|
138
|
+
r.should_not eq(nil)
|
107
139
|
end
|
108
140
|
|
109
141
|
it 'should update a contact' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyzoho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httmultiparty
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/api_utils.rb
|
209
209
|
- lib/ruby_zoho.rb
|
210
210
|
- lib/zoho_api.rb
|
211
|
+
- rubyzoho-0.1.1.gem
|
211
212
|
- rubyzoho.gemspec
|
212
213
|
- spec/api_utils_spec.rb
|
213
214
|
- spec/fixtures/sample.pdf
|