rubyzoho 0.2.0 → 0.3.0
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.
- checksums.yaml +5 -13
- data/.travis.yml +1 -1
- data/Gemfile +2 -3
- data/README.rdoc +20 -15
- data/Rakefile +0 -15
- data/lib/crud_methods.rb +3 -7
- data/lib/zoho_api.rb +35 -34
- data/lib/zoho_api_finders.rb +1 -0
- data/rubyzoho.gemspec +34 -99
- data/spec/ruby_zoho_spec.rb +320 -219
- data/spec/spec_helper.rb +5 -8
- data/spec/zoho_api_spec.rb +231 -172
- metadata +41 -56
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
data/spec/ruby_zoho_spec.rb
CHANGED
@@ -2,344 +2,445 @@ $:.unshift File.join('..', File.dirname(__FILE__), 'lib')
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
require 'zoho_api'
|
5
|
+
require 'vcr'
|
6
|
+
|
7
|
+
VCR.configure do |c|
|
8
|
+
c.cassette_library_dir = 'spec/vcr'
|
9
|
+
c.hook_into :webmock
|
10
|
+
# c.default_cassette_options = {:record => :all}
|
11
|
+
# c.debug_logger = File.open('log/vcr_debug.log', 'w')
|
12
|
+
end
|
13
|
+
|
5
14
|
|
6
15
|
describe RubyZoho::Crm do
|
7
16
|
|
8
17
|
before(:all) do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
VCR.use_cassette 'zoho/initialization' do
|
19
|
+
base_path = File.join(File.dirname(__FILE__), 'fixtures')
|
20
|
+
@sample_pdf = File.join(base_path, 'sample.pdf')
|
21
|
+
RubyZoho.configure do |config|
|
22
|
+
config.api_key = ENV['ZOHO_API_KEY'].strip
|
23
|
+
config.crm_modules = %w(Quotes)
|
24
|
+
config.cache_fields = true
|
25
|
+
end
|
26
|
+
r = RubyZoho::Crm::Contact.find_by_last_name('Smithereens')
|
27
|
+
r.each { |m| RubyZoho::Crm::Contact.delete(m.contactid) } unless r.nil?
|
28
|
+
r = RubyZoho::Crm::Contact.find_by_email('raj@portra.com')
|
29
|
+
r.each { |contact| RubyZoho::Crm::Contact.delete(contact.contactid) } unless r.nil?
|
15
30
|
end
|
16
|
-
r = RubyZoho::Crm::Contact.find_by_last_name('Smithereens')
|
17
|
-
r.each { |m| RubyZoho::Crm::Contact.delete(m.contactid) } unless r.nil?
|
18
|
-
r = RubyZoho::Crm::Contact.find_by_email('raj@portra.com')
|
19
|
-
r.each { |c| RubyZoho::Crm::Contact.delete(c.contactid) } unless r.nil?
|
20
31
|
end
|
21
32
|
|
22
33
|
it 'should add accessors using a list of names' do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
34
|
+
VCR.use_cassette 'zoho/accessors_names' do
|
35
|
+
c = RubyZoho::Crm::Contact.new
|
36
|
+
c.first_name = 'Raj'
|
37
|
+
c.first_name.should eq('Raj')
|
38
|
+
c.email = 'raj@portra.com'
|
39
|
+
c.email.should eq('raj@portra.com')
|
40
|
+
c.module_name.should eq('Contacts')
|
41
|
+
end
|
29
42
|
end
|
30
43
|
|
31
44
|
it 'should attach a file to an account' do
|
32
|
-
|
33
|
-
|
45
|
+
VCR.use_cassette 'zoho/attach_file_to_account' do
|
46
|
+
r = RubyZoho::Crm::Account.all.first
|
47
|
+
r.attach_file(@sample_pdf, '1_' + File.basename(@sample_pdf)).should eq('200')
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
51
|
it 'should attach a file to a contact' do
|
37
|
-
|
38
|
-
|
52
|
+
VCR.use_cassette 'zoho/attach_file_to_contact' do
|
53
|
+
r = RubyZoho::Crm::Contact.all.first
|
54
|
+
r.attach_file(@sample_pdf, File.basename(@sample_pdf)).should eq('200')
|
55
|
+
end
|
39
56
|
end
|
40
57
|
|
41
58
|
it 'should attach a file to a lead' do
|
42
|
-
|
43
|
-
|
59
|
+
VCR.use_cassette 'zoho/attach_file_to_lead' do
|
60
|
+
r = RubyZoho::Crm::Lead.all.first
|
61
|
+
r.attach_file(@sample_pdf, File.basename(@sample_pdf)).should eq('200')
|
62
|
+
end
|
44
63
|
end
|
45
64
|
|
46
65
|
it 'should attach a file to a potential' do
|
47
|
-
|
48
|
-
|
66
|
+
VCR.use_cassette 'zoho/attach_file_to_potential' do
|
67
|
+
r = RubyZoho::Crm::Potential.all.first
|
68
|
+
r.attach_file(@sample_pdf, File.basename(@sample_pdf)).should eq('200')
|
69
|
+
end
|
49
70
|
end
|
50
71
|
|
51
72
|
it 'should attach a file to a task' do
|
52
|
-
|
53
|
-
|
73
|
+
VCR.use_cassette 'zoho/attach_file_to_task' do
|
74
|
+
r = RubyZoho::Crm::Task.all.first
|
75
|
+
r.attach_file(@sample_pdf, File.basename(@sample_pdf)).should eq('200')
|
76
|
+
end
|
54
77
|
end
|
55
78
|
|
56
79
|
it 'should concatenate a related object and save it' do
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
80
|
+
VCR.use_cassette 'zoho/concatenate_related_object' do
|
81
|
+
subject = '[DELETE THIS] New subject as of 112233'
|
82
|
+
a = RubyZoho::Crm::Account.all.last
|
83
|
+
#noinspection RubyArgCount
|
84
|
+
a << RubyZoho::Crm::Task.new(
|
85
|
+
:subject => subject,
|
86
|
+
:description => 'Nothing',
|
87
|
+
:status => 'Not Started',
|
88
|
+
:priority => 'High',
|
89
|
+
:send_notification_email => 'False',
|
90
|
+
:due_date => '2014-02-16 16:00:00',
|
91
|
+
:start_datetime => Time.now.to_s[1, 19],
|
92
|
+
:end_datetime => '2014-02-16 16:00:00'
|
93
|
+
)
|
94
|
+
r = RubyZoho::Crm::Task.find_by_subject(subject)
|
95
|
+
r.first.relatedtoid.should eq(a.accountid)
|
96
|
+
end
|
71
97
|
end
|
72
98
|
|
73
99
|
it 'should determine if a method is a module' do
|
74
|
-
|
75
|
-
|
100
|
+
VCR.use_cassette 'zoho/determine_module' do
|
101
|
+
good_methods = [:contact, :contacts, 'contacts', 'lead', 'leads', :potentials, :quotes]
|
102
|
+
good_methods.map { |m| RubyZoho::Crm.method_is_module?(m).should_not eq(nil) }
|
103
|
+
end
|
76
104
|
end
|
77
105
|
|
78
106
|
it 'should find a contact by email or last name' do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
107
|
+
VCR.use_cassette 'zoho/find_by_email_or_name' do
|
108
|
+
r = RubyZoho::Crm::Contact.find_by_email('bob@smith.com')
|
109
|
+
r.each { |m| RubyZoho::Crm::Contact.delete(m.id) } unless r.nil?
|
110
|
+
1.upto(3) do
|
111
|
+
c = RubyZoho::Crm::Contact.new(
|
112
|
+
:first_name => 'Bob',
|
113
|
+
:last_name => 'Smithereens',
|
114
|
+
:email => 'bob@smith.com')
|
115
|
+
c.save
|
116
|
+
end
|
117
|
+
r = RubyZoho::Crm::Contact.find_by_email('bob@smith.com')
|
118
|
+
r.should_not eq(nil)
|
119
|
+
r.count.should eq(3)
|
120
|
+
r.each { |m| m.email.should eq('bob@smith.com') }
|
121
|
+
r = RubyZoho::Crm::Contact.find_by_last_name('Smithereens')
|
122
|
+
r.should_not eq(nil)
|
123
|
+
r.map { |c| c.last_name }.count.should eq(3)
|
124
|
+
r.first.last_name.should eq('Smithereens')
|
125
|
+
r.each { |m| RubyZoho::Crm::Contact.delete(m.id) }
|
87
126
|
end
|
88
|
-
r = RubyZoho::Crm::Contact.find_by_email('bob@smith.com')
|
89
|
-
r.should_not eq(nil)
|
90
|
-
r.count.should eq(3)
|
91
|
-
r.each { |m| m.email.should eq('bob@smith.com') }
|
92
|
-
r = RubyZoho::Crm::Contact.find_by_last_name('Smithereens')
|
93
|
-
r.should_not eq(nil)
|
94
|
-
r.map { |c| c.last_name }.count.should eq(3)
|
95
|
-
r.first.last_name.should eq('Smithereens')
|
96
|
-
r.each { |m| RubyZoho::Crm::Contact.delete(m.id) }
|
97
127
|
end
|
98
128
|
|
99
129
|
it 'should find a contact by ID' do
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
130
|
+
VCR.use_cassette 'zoho/find_contact_by_id' do
|
131
|
+
contacts = RubyZoho::Crm::Contact.all
|
132
|
+
id = contacts.first.id
|
133
|
+
c = RubyZoho::Crm::Contact.find_by_contactid(id)
|
134
|
+
c.first.contactid.should eq(id)
|
135
|
+
c.first.last_name.should eq(contacts.first.last_name)
|
136
|
+
c.first.email.should eq(contacts.first.email)
|
137
|
+
end
|
106
138
|
end
|
107
139
|
|
108
140
|
it 'should find a lead by ID' do
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
141
|
+
VCR.use_cassette 'zoho/find_lead_by_id' do
|
142
|
+
leads = RubyZoho::Crm::Lead.all
|
143
|
+
lead_id = leads.first.id
|
144
|
+
l = RubyZoho::Crm::Lead.find_by_leadid(lead_id)
|
145
|
+
l.first.leadid.should eq(lead_id)
|
146
|
+
end
|
113
147
|
end
|
114
148
|
|
115
149
|
it 'should find a user by email address' do
|
116
|
-
|
117
|
-
|
118
|
-
|
150
|
+
VCR.use_cassette 'zoho/find_user_by_email' do
|
151
|
+
users = RubyZoho::Crm::CRMUser.all
|
152
|
+
r = RubyZoho::Crm::CRMUser.find_by_email(users.first.email)
|
153
|
+
r.first.email.should eq(users.first.email)
|
154
|
+
end
|
119
155
|
end
|
120
156
|
|
121
157
|
it 'should get a list of attr_writers for accounts' do
|
122
|
-
|
123
|
-
|
158
|
+
VCR.use_cassette 'zoho/list_attr_writers' do
|
159
|
+
c = RubyZoho::Crm::Account.new
|
160
|
+
c.attr_writers.count.should be >= 18
|
161
|
+
end
|
124
162
|
end
|
125
163
|
|
126
164
|
it 'should get a list of attr_writers for contacts' do
|
127
|
-
|
128
|
-
|
165
|
+
VCR.use_cassette 'zoho/list_attr_writers_for_contacts' do
|
166
|
+
c = RubyZoho::Crm::Contact.new
|
167
|
+
c.attr_writers.count.should be >= 10
|
168
|
+
end
|
129
169
|
end
|
130
170
|
|
131
171
|
it 'should get a list of attr_writers for leads' do
|
132
|
-
|
133
|
-
|
172
|
+
VCR.use_cassette 'zoho/list_attr_writers_for_leads' do
|
173
|
+
c = RubyZoho::Crm::Lead.new
|
174
|
+
c.attr_writers.count.should be >= 16
|
175
|
+
end
|
134
176
|
end
|
135
177
|
|
136
178
|
it 'should get a list of attr_writers for potentials' do
|
137
|
-
|
138
|
-
|
179
|
+
VCR.use_cassette 'zoho/list_attr_writers_for_potentials' do
|
180
|
+
c = RubyZoho::Crm::Potential.new
|
181
|
+
c.attr_writers.count.should be >= 14
|
182
|
+
end
|
139
183
|
end
|
140
184
|
|
141
185
|
it 'should get a list of attr_writers for tasks' do
|
142
|
-
|
143
|
-
|
186
|
+
VCR.use_cassette 'zoho/list_attr_writers_for_taskss' do
|
187
|
+
c = RubyZoho::Crm::Task.new
|
188
|
+
c.attr_writers.count.should be >= 14
|
189
|
+
end
|
144
190
|
end
|
145
191
|
|
146
192
|
it 'should get a list of attr_writers for quotes' do
|
147
|
-
|
148
|
-
|
193
|
+
VCR.use_cassette 'zoho/list_attr_writers_for_quotes' do
|
194
|
+
c = RubyZoho::Crm::Quote.new
|
195
|
+
c.attr_writers.count.should be >= 18 unless c.nil?
|
196
|
+
end
|
149
197
|
end
|
150
198
|
|
151
199
|
it 'should get a list of accounts' do
|
152
|
-
|
153
|
-
|
154
|
-
|
200
|
+
VCR.use_cassette 'zoho/list_of_accounts' do
|
201
|
+
r = RubyZoho::Crm::Account.all
|
202
|
+
r.count.should be > 1
|
203
|
+
r.map { |account| account.class.should eq(RubyZoho::Crm::Account) }
|
204
|
+
end
|
155
205
|
end
|
156
206
|
|
157
207
|
it 'should get a list of calls' do
|
158
|
-
|
159
|
-
|
160
|
-
r.
|
161
|
-
|
208
|
+
VCR.use_cassette 'zoho/list_of_calls' do
|
209
|
+
r = RubyZoho::Crm::Call.all
|
210
|
+
unless r.nil?
|
211
|
+
r.map { |e| e.class.should eq(RubyZoho::Crm::Call) }
|
212
|
+
r.map { |e| e.id.should eq(e.activityid) }
|
213
|
+
end
|
162
214
|
end
|
163
215
|
end
|
164
216
|
|
165
217
|
it 'should get a list of contacts' do
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
218
|
+
VCR.use_cassette 'zoho/list_of_contacts' do
|
219
|
+
r = RubyZoho::Crm::Contact.all
|
220
|
+
r.count.should be > 1
|
221
|
+
r.map { |e| e.class.should eq(RubyZoho::Crm::Contact) }
|
222
|
+
r.map { |e| e.id.should eq(e.contactid) }
|
223
|
+
end
|
170
224
|
end
|
171
225
|
|
172
226
|
it 'should get a list of events' do
|
173
227
|
pending
|
174
|
-
|
175
|
-
|
176
|
-
|
228
|
+
VCR.use_cassette 'zoho/list_of_events' do
|
229
|
+
r = RubyZoho::Crm::Event.all
|
230
|
+
r.map { |event| event.class.should eq(RubyZoho::Crm::Event) } unless r.nil?
|
231
|
+
r.map { |e| e.id.should eq(e.eventid) }
|
232
|
+
true.should eq(false)
|
233
|
+
end
|
177
234
|
end
|
178
235
|
|
179
236
|
it 'should get a list of potentials' do
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
237
|
+
VCR.use_cassette 'zoho/list_of_potentials' do
|
238
|
+
r = RubyZoho::Crm::Potential.all
|
239
|
+
r.count.should be > 1
|
240
|
+
r.map { |potential| potential.class.should eq(RubyZoho::Crm::Potential) }
|
241
|
+
r.map { |e| e.id.should eq(e.potentialid) }
|
242
|
+
end
|
184
243
|
end
|
185
244
|
|
186
245
|
it 'should get a list of quotes' do
|
187
246
|
pending
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
247
|
+
VCR.use_cassette 'zoho/list_of_quotes' do
|
248
|
+
r = RubyZoho::Crm::Quote.all
|
249
|
+
r.count.should be >= 1
|
250
|
+
r.map { |quote| quote.class.should eq(RubyZoho::Crm::Quote) }
|
251
|
+
r.map { |e| e.id.should eq(e.quoteid) }
|
252
|
+
end
|
192
253
|
end
|
193
254
|
|
194
255
|
it 'should get a list of tasks' do
|
195
|
-
|
196
|
-
|
197
|
-
|
256
|
+
VCR.use_cassette 'zoho/list_of_tasks' do
|
257
|
+
r = RubyZoho::Crm::Task.all
|
258
|
+
r.map { |task| task.class.should eq(RubyZoho::Crm::Task) } unless r.nil?
|
259
|
+
r.map { |e| e.id.should eq(e.activityid) }
|
260
|
+
end
|
198
261
|
end
|
199
262
|
|
200
263
|
it 'should get a list of users' do
|
201
|
-
|
202
|
-
|
264
|
+
VCR.use_cassette 'zoho/list_of_users' do
|
265
|
+
r = RubyZoho::Crm::CRMUser.all
|
266
|
+
r.count.should be >= 1
|
267
|
+
end
|
203
268
|
end
|
204
269
|
|
205
270
|
it 'should save a contact record' do
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
271
|
+
VCR.use_cassette 'zoho/save_contact' do
|
272
|
+
c = RubyZoho::Crm::Contact.new(
|
273
|
+
:first_name => 'Raj',
|
274
|
+
:last_name => 'Portra',
|
275
|
+
:email => 'raj@portra.com')
|
276
|
+
c.save
|
277
|
+
r = RubyZoho::Crm::Contact.find_by_email('raj@portra.com')
|
278
|
+
r.first.email.should eq('raj@portra.com')
|
279
|
+
r.each { |contact| RubyZoho::Crm::Contact.delete(contact.contactid) }
|
280
|
+
end
|
214
281
|
end
|
215
282
|
|
216
283
|
it 'should save a lead record' do
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
284
|
+
VCR.use_cassette 'zoho/save_lead' do
|
285
|
+
l = RubyZoho::Crm::Lead.new(
|
286
|
+
:first_name => 'Raj',
|
287
|
+
:last_name => 'Portra',
|
288
|
+
:email => 'raj@portra.com')
|
289
|
+
l.save
|
290
|
+
r = RubyZoho::Crm::Lead.find_by_email('raj@portra.com')
|
291
|
+
r.should_not eq(nil)
|
292
|
+
r.first.email.should eq(l.email)
|
293
|
+
r.each { |c| RubyZoho::Crm::Lead.delete(c.id) }
|
294
|
+
end
|
226
295
|
end
|
227
296
|
|
228
297
|
it 'should save and retrieve an account record with a custom field' do
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
298
|
+
VCR.use_cassette 'zoho/save_account_custom_field' do
|
299
|
+
accounts = RubyZoho::Crm::Account.all
|
300
|
+
a = accounts.first
|
301
|
+
if defined?(a.par_lifetime_to_dat)
|
302
|
+
RubyZoho::Crm::Account.update(
|
303
|
+
:id => a.id,
|
304
|
+
:par_lifetime_to_date => '$1000000'
|
305
|
+
)
|
306
|
+
a2 = RubyZoho::Crm::Account.find(a.accountid)
|
307
|
+
a2.first.test_custom.should eq('1000000')
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'should save and retrieve a lead record with a custom field' do
|
313
|
+
VCR.use_cassette 'zoho/save_lead_custom_field' do
|
314
|
+
l = RubyZoho::Crm::Lead.first
|
315
|
+
if defined?(l.test_label)
|
316
|
+
RubyZoho::Crm::Lead.update(
|
317
|
+
:id => l.id,
|
318
|
+
:test_label => '$1000000'
|
319
|
+
)
|
320
|
+
l2 = RubyZoho::Crm::Lead.find(l.id)
|
321
|
+
l2.first.test_label.should eq('$1000000')
|
322
|
+
end
|
238
323
|
end
|
239
324
|
end
|
240
325
|
|
241
326
|
it 'should save and retrieve a potential record' do
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
327
|
+
VCR.use_cassette 'zoho/potential_record' do
|
328
|
+
accounts = RubyZoho::Crm::Account.all
|
329
|
+
h = {
|
330
|
+
:potential_name => 'A very big potential INDEED!!!!!!!!!!!!!',
|
331
|
+
:accountid => accounts.first.accountid,
|
332
|
+
:account_name => accounts.first.account_name,
|
333
|
+
:closing_date => '1/1/2014',
|
334
|
+
:type => 'New Business',
|
335
|
+
:stage => 'Needs Analysis'}
|
336
|
+
r = RubyZoho::Crm::Potential.find_by_potential_name(h[:potential_name])
|
337
|
+
r.each { |c| RubyZoho::Crm::Potential.delete(c.potentialid) } unless r.nil?
|
338
|
+
p = RubyZoho::Crm::Potential.new(h)
|
339
|
+
p.save
|
340
|
+
r = RubyZoho::Crm::Potential.find_by_potential_name(p.potential_name)
|
341
|
+
r.first.potential_name.should eq(h[:potential_name])
|
342
|
+
potential = RubyZoho::Crm::Potential.find(r.first.potentialid)
|
343
|
+
potential.first.potentialid.should eq(r.first.potentialid)
|
344
|
+
p_by_account_id = RubyZoho::Crm::Potential.find_by_accountid(accounts.first.accountid)
|
345
|
+
p_found = p_by_account_id.map { |pn| pn if pn.potential_name == h[:potential_name] }.compact
|
346
|
+
p_found.first.potentialid.should eq(r.first.potentialid)
|
347
|
+
r.each { |c| RubyZoho::Crm::Potential.delete(c.potentialid) }
|
348
|
+
end
|
262
349
|
end
|
263
350
|
|
264
351
|
it 'should save and retrieve a task record' do
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
352
|
+
VCR.use_cassette 'zoho/task_record' do
|
353
|
+
accounts = RubyZoho::Crm::Account.all
|
354
|
+
h = {
|
355
|
+
:subject => 'Test Task',
|
356
|
+
:due_date => Date.today.to_s + '23:59',
|
357
|
+
:semodule => 'Accounts',
|
358
|
+
:relatedtoid => accounts.first.accountid,
|
359
|
+
:related_to => accounts.first.account_name,
|
360
|
+
:priority => 'Low'}
|
361
|
+
r = RubyZoho::Crm::Task.find_by_subject(h[:subject])
|
362
|
+
r.each { |t| RubyZoho::Crm::Task.delete(t.activityid) } unless r.nil?
|
363
|
+
t = RubyZoho::Crm::Task.new(h)
|
364
|
+
t.save
|
365
|
+
r = RubyZoho::Crm::Task.find_by_subject(h[:subject])
|
366
|
+
r.first.subject.should eq(h[:subject])
|
367
|
+
tasks = RubyZoho::Crm::Task.find_by_activityid(r.first.activityid)
|
368
|
+
tasks.first.activityid.should eq(r.first.activityid)
|
369
|
+
r.each { |c| RubyZoho::Crm::Task.delete(c.activityid) }
|
370
|
+
end
|
282
371
|
end
|
283
372
|
|
284
373
|
it 'should save an task record related to an account' do
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
374
|
+
VCR.use_cassette 'zoho/task_related_to_account' do
|
375
|
+
a = RubyZoho::Crm::Account.all.first
|
376
|
+
e = RubyZoho::Crm::Task.new(
|
377
|
+
:task_owner => a.account_owner,
|
378
|
+
:subject => "Task should be related to #{a.account_name} #{Time.now}",
|
379
|
+
:description => 'Nothing',
|
380
|
+
:smownerid => "#{a.smownerid}",
|
381
|
+
:status => 'Not Started',
|
382
|
+
:priority => 'High',
|
383
|
+
:send_notification_email => 'False',
|
384
|
+
:due_date => '2014-02-16 16:00:00',
|
385
|
+
:start_datetime => Time.now.to_s[1, 19],
|
386
|
+
:end_datetime => '2014-02-16 16:00:00',
|
387
|
+
:related_to => "#{a.account_name}",
|
388
|
+
:seid => "#{a.accountid}",
|
389
|
+
:semodule => 'Accounts'
|
390
|
+
)
|
391
|
+
r_expected = e.save
|
392
|
+
r = RubyZoho::Crm::Task.find_by_activityid(r_expected.id)
|
393
|
+
r.first.subject[0..20].should eq(r_expected.subject[0..20])
|
394
|
+
end
|
304
395
|
end
|
305
396
|
|
306
397
|
it 'should get tasks by user' do
|
307
398
|
pending
|
308
|
-
|
309
|
-
|
310
|
-
|
399
|
+
VCR.use_cassette 'zoho/tasks_by_owner' do
|
400
|
+
task_owner = RubyZoho::Crm::Task.first.task_owner
|
401
|
+
tasks = RubyZoho::Crm::Task.find_by_task_owner(task_owner)
|
402
|
+
tasks.should_not eq(nil)
|
403
|
+
tasks.map { |t| RubyZoho::Crm::Task.delete(t.activityid) } unless tasks.nil?
|
404
|
+
true.should eq(false)
|
405
|
+
end
|
311
406
|
end
|
312
407
|
|
313
408
|
it 'should sort contact records' do
|
314
|
-
|
315
|
-
|
316
|
-
|
409
|
+
VCR.use_cassette 'zoho/sort_contacts' do
|
410
|
+
r = RubyZoho::Crm::Contact.all
|
411
|
+
sorted = r.sort { |a, b| a.last_name <=> b.last_name }
|
412
|
+
sorted.collect { |c| c.last_name }.should_not eq(nil)
|
413
|
+
end
|
317
414
|
end
|
318
415
|
|
319
416
|
it 'should update a lead record' do
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
417
|
+
VCR.use_cassette 'zoho/update_lead' do
|
418
|
+
r_changed = RubyZoho::Crm::Lead.find_by_email('changed_raj@portra.com')
|
419
|
+
r_changed.each { |c| RubyZoho::Crm::Lead.delete(c.leadid) } unless r_changed.nil?
|
420
|
+
l = RubyZoho::Crm::Lead.new(
|
421
|
+
:first_name => 'Raj',
|
422
|
+
:last_name => 'Portra',
|
423
|
+
:email => 'raj@portra.com')
|
424
|
+
l.save
|
425
|
+
r = RubyZoho::Crm::Lead.find_by_email('raj@portra.com')
|
426
|
+
RubyZoho::Crm::Lead.update(
|
427
|
+
:id => r.first.leadid,
|
428
|
+
:email => 'changed_raj@portra.com'
|
429
|
+
)
|
430
|
+
r_changed = RubyZoho::Crm::Lead.find_by_email('changed_raj@portra.com')
|
431
|
+
r.first.leadid.should eq(r_changed.first.leadid)
|
432
|
+
r.each { |c| RubyZoho::Crm::Lead.delete(c.leadid) }
|
433
|
+
r_changed.each { |c| RubyZoho::Crm::Lead.delete(c.leadid) }
|
434
|
+
end
|
336
435
|
end
|
337
436
|
|
338
437
|
it 'should validate a field name' do
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
438
|
+
VCR.use_cassette 'zoho/validate_field' do
|
439
|
+
good_names = ['This is OK', 'OK_to_use', 'field()']
|
440
|
+
bad_names = ['This %#{@} is not']
|
441
|
+
good_names.map { |f| RubyZoho::Crm.method_name?(ApiUtils.string_to_symbol(f)).should_not eq(false) }
|
442
|
+
bad_names.map { |f| RubyZoho::Crm.method_name?(ApiUtils.string_to_symbol(f)).should eq(false) }
|
443
|
+
end
|
343
444
|
end
|
344
445
|
|
345
446
|
end
|