vtiger 0.4.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -47,6 +47,9 @@ Now has find_by_email_id
47
47
  == REQUIREMENTS:
48
48
  now using yajl as replacement to json.gem
49
49
 
50
+ == DIRECT DB ACCESS
51
+ Can now directly access Vtiger DB to run some queries. See base.rb campaignlist etc.
52
+
50
53
 
51
54
  == INSTALL:
52
55
 
data/lib/vtiger/base.rb CHANGED
@@ -1,8 +1,12 @@
1
1
  require 'net/http'
2
2
  #require 'yajl'
3
+ require 'rubygems'
4
+ gem 'yajl-ruby'
3
5
  require 'yajl'
4
6
  require 'digest/md5'
5
7
  require 'erb'
8
+ #gem 'activerecord'
9
+ require 'active_record'
6
10
  class Hash
7
11
  def url_encode
8
12
  to_a.map do |name_value|
@@ -10,10 +14,32 @@ require 'erb'
10
14
  end.join '&'
11
15
  end
12
16
  end
13
-
17
+ class CampaignList #< ActiveRecord::Base
18
+
19
+ def scott_connect(dbhost, dbname, dbuser,dbpasswd)
20
+ #ActiveRecord::Base.set_table_name('vtiger_campaigncontrel')
21
+ @myconnection =ActiveRecord::Base.establish_connection(
22
+ :adapter => "mysql",
23
+ :host => dbhost,
24
+ :username => dbuser,
25
+ :password => dbpasswd,
26
+ :database => dbname
27
+ )
28
+ end
29
+ def convert(mysql_res)
30
+ rows=[]
31
+ mysql_res.each_hash { |h| rows << h
32
+ puts "h is #{h} #{h.inspect} #{h.class}"}
33
+ rows
34
+ end
35
+ def find_contacts_by_campaign(dbconn,id)
36
+ mysql_results=@myconnection.connection.execute("select vtiger_contactdetails.email, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_campaigncontrel.campaignid from vtiger_contactdetails left join vtiger_campaigncontrel on vtiger_contactdetails.contactid=vtiger_campaigncontrel.contactid where vtiger_campaigncontrel.campaignid=#{id} and emailoptout=0;")
37
+ self.convert(mysql_results)
38
+ end
39
+ end
14
40
  module Vtiger
15
41
  class Base
16
- attr_accessor :md5,:token, :endpoint_url, :access_key, :session_name, :url, :username, :userid
42
+ attr_accessor :md5,:token, :endpoint_url, :access_key, :session_name, :url, :username, :userid, :campaigndb
17
43
 
18
44
  def challenge(options)
19
45
 
@@ -176,6 +202,17 @@ def updateobject(values)
176
202
  result = http_crm_post("operation=update",input_array)
177
203
  # self.session_name=result["result"]["sessionName"]
178
204
  # puts JSON.pretty_generate(result)
205
+ end
206
+ def accessdatabase(dbhost, dbname, dbuser,dbpasswd)
207
+ #select vtiger_contactdetails.email, vtiger_contactdetails.firstname, vtiger_contactdetails.lastname, vtiger_campaigncontrel.campaignid from vtiger_contactdetails left join vtiger_campaigncontrel on vtiger_contactdetails.contactid=vtiger_campaigncontrel.contactid where vtiger_campaigncontrel.campaignid='14' and emailoptout=0;
208
+ self.campaigndb=CampaignList.new
209
+ self.campaigndb.scott_connect(dbhost, dbname, dbuser,dbpasswd)
210
+
211
+
212
+ end
213
+ def get_contacts_from_campaign(campaignid)
214
+ self.campaigndb.find_contacts_by_campaign(self.campaigndb,campaignid)
215
+
179
216
  end
180
217
  end #clase base
181
218
  end #moduble
@@ -0,0 +1,4 @@
1
+ VTIGERDB= 'collinbniesdb'
2
+ VTIGERDBHOST='myestormdb1.cz7ya2tbsgz7.us-east-1.rds.amazonaws.com'
3
+ VTIGERDBUSER='collinbnies'
4
+ VTIGERDBPASSWD='9collinbnies341'
data/test/test_vtiger.rb CHANGED
@@ -27,6 +27,15 @@ def test_get_campaigns
27
27
  assert login,"login should succeed"
28
28
  assert success,"find campaigns should success"
29
29
  puts "CAMPAIGNS #{values}"
30
+ end
31
+ def test_get_contacts_from_campaigns
32
+ cmd = Vtiger::Commands.new()
33
+ @options[:username]='admin'
34
+ challenge=cmd.challenge(@options)
35
+ login=cmd.login(@options)
36
+ success,values=cmd.get_campaigns()
37
+ require 'test_secret'
38
+ cmd.accessdatabase(VTIGERDBHOST, VTIGERDB, VTIGERDBUSER,VTIGERDBPASSWD)
30
39
  end
31
40
  def test_api_login
32
41
  Vtiger::Api.api_settings = {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vtiger
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 9
10
- version: 0.4.9
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Scott Sproule
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-22 00:00:00 +08:00
18
+ date: 2010-10-23 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -40,6 +40,7 @@ files:
40
40
  - lib/vtiger/support.rb
41
41
  - lib/vtiger.rb
42
42
  - test/test_helper.rb
43
+ - test/test_secret.rb
43
44
  - test/test_vtiger.rb
44
45
  - bin/add_contact.rb
45
46
  - bin/add_lead.rb