vtiger 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/bin/add_contact.rb +45 -0
- data/bin/add_lead.rb +44 -0
- data/bin/add_trouble_ticket.rb +43 -0
- data/bin/describe_object.rb +48 -0
- data/bin/helloworld.rb +1 -0
- data/bin/list_types.rb +45 -0
- data/bin/query.rb +48 -0
- data/bin/update_stock_inventory.rb +48 -0
- data/bin/yahoo_csv.rb +81 -0
- data/lib/vtiger/base.rb +25 -15
- data/lib/vtiger/commands.rb +19 -1
- data/lib/vtiger/support.rb +2 -1
- data/test/test_helper.rb +1 -1
- data/test/test_vtiger.rb +13 -0
- metadata +22 -6
data/README.rdoc
CHANGED
data/bin/add_contact.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env jruby -S
|
2
|
+
# == Synopsis
|
3
|
+
# Add a contact to vtiger
|
4
|
+
# == Usage
|
5
|
+
# add_contact.rb -u vtiger_url -e Contacts -n username -k access_key -c contactName
|
6
|
+
# Note -a flag for response --- eg true or false
|
7
|
+
# == Useful commands
|
8
|
+
# jruby add_contact.rb -u democrm.estormtech.com -c test -n scott -k xxxxx
|
9
|
+
# == Author
|
10
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
11
|
+
# == Copyright
|
12
|
+
# Copyright (c) 2007 Ficonab Pte. Ltd.
|
13
|
+
# See license for license details
|
14
|
+
require 'yaml'
|
15
|
+
require 'rubygems'
|
16
|
+
gem 'vtiger'
|
17
|
+
require 'vtiger'
|
18
|
+
require 'optparse'
|
19
|
+
require 'rdoc/usage'
|
20
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
25
|
+
RDoc::usage if arg_hash[:help]==true
|
26
|
+
require 'pp'
|
27
|
+
options = arg_hash
|
28
|
+
# set up variables using hash
|
29
|
+
|
30
|
+
puts "vtiger add contact #{Time.now}"
|
31
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
32
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
33
|
+
cmd = Vtiger::Commands.new()
|
34
|
+
cmd.challenge(options)
|
35
|
+
cmd.login(options)
|
36
|
+
cmd.addobject(options)
|
37
|
+
# consumer_session.close
|
38
|
+
# puts "#{result}"
|
39
|
+
# sleep(1)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
puts '-------------finished processing!!!'
|
44
|
+
|
45
|
+
|
data/bin/add_lead.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# == Synopsis
|
3
|
+
# Add a contact to vtiger
|
4
|
+
# == Usage
|
5
|
+
# add_contact.rb -u vtiger_url -e Contacts -n username -k access_key -c contactName
|
6
|
+
# Note -a flag for response --- eg true or false
|
7
|
+
# == Useful commands
|
8
|
+
# add_lead.rb -u democrm.estormtech.com -c test -e Contacts -n scott -k xxxxx
|
9
|
+
# == Author
|
10
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
11
|
+
# == Copyright
|
12
|
+
# Copyright (c) 2007 Ficonab Pte. Ltd.
|
13
|
+
# See license for license details
|
14
|
+
require 'yaml'
|
15
|
+
require 'rubygems'
|
16
|
+
gem 'vtiger'
|
17
|
+
require 'vtiger'
|
18
|
+
require 'optparse'
|
19
|
+
require 'rdoc/usage'
|
20
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
21
|
+
|
22
|
+
#testing of chagnes
|
23
|
+
|
24
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
25
|
+
RDoc::usage if arg_hash[:help]==true
|
26
|
+
require 'pp'
|
27
|
+
options = arg_hash
|
28
|
+
# set up variables using hash
|
29
|
+
|
30
|
+
puts "vtiger add contact #{Time.now}"
|
31
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
32
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
33
|
+
cmd = Vtiger::Commands.new()
|
34
|
+
cmd.challenge(options)
|
35
|
+
cmd.login(options)
|
36
|
+
cmd.addlead(options)
|
37
|
+
# consumer_session.close
|
38
|
+
# puts "#{result}"
|
39
|
+
# sleep(1)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
puts '-------------finished processing!!!'
|
44
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# == Synopsis
|
3
|
+
# Add a contact to vtiger
|
4
|
+
# == Usage
|
5
|
+
# add_trouble_ticket.rb -u vtiger_url -e HelpDesk -n username -k access_key -c contactName
|
6
|
+
# Note -a flag for response --- eg true or false
|
7
|
+
# == Useful commands
|
8
|
+
# add_trouble_ticket.rb -u democrm.estormtech.com -t titletest -e HelpDesk -n scott -k xxxxx
|
9
|
+
# == Author
|
10
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
11
|
+
# == Copyright
|
12
|
+
# Copyright (c) 2007 Ficonab Pte. Ltd.
|
13
|
+
# See license for license details
|
14
|
+
require 'yaml'
|
15
|
+
require 'rubygems'
|
16
|
+
gem 'vtiger'
|
17
|
+
require 'vtiger'
|
18
|
+
require 'optparse'
|
19
|
+
require 'rdoc/usage'
|
20
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
21
|
+
|
22
|
+
#testing of chagnes
|
23
|
+
|
24
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
25
|
+
RDoc::usage if arg_hash[:help]==true
|
26
|
+
require 'pp'
|
27
|
+
options = arg_hash
|
28
|
+
# set up variables using hash
|
29
|
+
|
30
|
+
puts "vtiger add trouble ticket #{Time.now}"
|
31
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
32
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
33
|
+
cmd = Vtiger::Commands.new()
|
34
|
+
cmd.challenge(options)
|
35
|
+
cmd.login(options)
|
36
|
+
cmd.add_trouble_ticket(options,"Open",arg_hash[:title],{})
|
37
|
+
# consumer_session.close
|
38
|
+
# puts "#{result}"
|
39
|
+
# sleep(1)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
puts '-------------finished processing!!!'
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env jruby -S
|
2
|
+
# == Synopsis
|
3
|
+
# Describe objects on vtiger server. Use the list_types command to get access to all the types
|
4
|
+
# == Usage
|
5
|
+
# describe object.rb -u vtiger_url -e object -n username -k access_key
|
6
|
+
# Note -a flag for response --- eg true or false
|
7
|
+
#
|
8
|
+
# == Useful commands
|
9
|
+
# jruby -S describe_object.rb -e Contacts -u democrm.estormtech.com -n scott -k xxx
|
10
|
+
# (this is a long response, try grep -A 5 to look five lines after what you are interested)
|
11
|
+
|
12
|
+
# == Author
|
13
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
14
|
+
# == Copyright
|
15
|
+
# Copyright (c) 2007 Ficonab Pte. Ltd.
|
16
|
+
# See license for license details
|
17
|
+
require 'yaml'
|
18
|
+
require 'rubygems'
|
19
|
+
gem 'vtiger'
|
20
|
+
require 'vtiger'
|
21
|
+
require 'optparse'
|
22
|
+
require 'rdoc/usage'
|
23
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
28
|
+
RDoc::usage if arg_hash[:help]==true
|
29
|
+
require 'pp'
|
30
|
+
options = arg_hash
|
31
|
+
# set up variables using hash
|
32
|
+
|
33
|
+
puts "vtiger add contact #{Time.now}"
|
34
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
35
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
36
|
+
cmd = Vtiger::Commands.new()
|
37
|
+
cmd.challenge(options)
|
38
|
+
cmd.login(options)
|
39
|
+
cmd.describe_object(options)
|
40
|
+
# consumer_session.close
|
41
|
+
# puts "#{result}"
|
42
|
+
# sleep(1)
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
puts '-------------finished processing!!!'
|
47
|
+
|
48
|
+
|
data/bin/helloworld.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
puts "hello world"
|
data/bin/list_types.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env jruby -S
|
2
|
+
# == Synopsis
|
3
|
+
# List the types on the vtiger server
|
4
|
+
# == Usage
|
5
|
+
# jruby -S list_types.rb -u website -n username -k accesskey
|
6
|
+
#
|
7
|
+
# == Useful commands
|
8
|
+
# list_types.rb -u democrm.estormtech.com -n scott -k xxx
|
9
|
+
# == Author
|
10
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
11
|
+
# == Copyright
|
12
|
+
# Copyright (c) 2007 Ficonab Pte. Ltd.
|
13
|
+
# See license for license details
|
14
|
+
require 'yaml'
|
15
|
+
require 'rubygems'
|
16
|
+
gem 'vtiger'
|
17
|
+
require 'vtiger'
|
18
|
+
require 'optparse'
|
19
|
+
require 'rdoc/usage'
|
20
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
25
|
+
RDoc::usage if arg_hash[:help]==true
|
26
|
+
require 'pp'
|
27
|
+
options = arg_hash
|
28
|
+
# set up variables using hash
|
29
|
+
|
30
|
+
puts "vtiger add contact #{Time.now}"
|
31
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
32
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
33
|
+
cmd = Vtiger::Commands.new()
|
34
|
+
cmd.challenge(options)
|
35
|
+
cmd.login(options)
|
36
|
+
cmd.list_types(options)
|
37
|
+
# consumer_session.close
|
38
|
+
# puts "#{result}"
|
39
|
+
# sleep(1)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
puts '-------------finished processing!!!'
|
44
|
+
|
45
|
+
|
data/bin/query.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env jruby -S
|
2
|
+
# == Synopsis
|
3
|
+
# Query the vtiger server
|
4
|
+
# == Usage
|
5
|
+
# jruby -S query.rb -u website -n username -k accesskey -q sql_query string
|
6
|
+
#
|
7
|
+
# == Useful commands
|
8
|
+
# jruby -S query.rb -u democrm.estormtech.com -n scott -k xxxxx -q 'select * from Accounts;'
|
9
|
+
# == Author
|
10
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
11
|
+
# == Copyright
|
12
|
+
# Copyright (c) 2007 Ficonab Pte. Ltd.
|
13
|
+
# See license for license details
|
14
|
+
require 'yaml'
|
15
|
+
require 'rubygems'
|
16
|
+
gem 'vtiger'
|
17
|
+
require 'vtiger'
|
18
|
+
require 'optparse'
|
19
|
+
require 'rdoc/usage'
|
20
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
25
|
+
RDoc::usage if arg_hash[:help]==true
|
26
|
+
require 'pp'
|
27
|
+
options = arg_hash
|
28
|
+
# set up variables using hash
|
29
|
+
|
30
|
+
puts "vtiger add contact #{Time.now}"
|
31
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
32
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
33
|
+
cmd = Vtiger::Commands.new()
|
34
|
+
cmd.challenge(options)
|
35
|
+
cmd.login(options)
|
36
|
+
cmd.query(options)
|
37
|
+
# consumer_session.close
|
38
|
+
# puts "#{result}"
|
39
|
+
# sleep(1)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
puts '-------------finished processing!!!'
|
44
|
+
|
45
|
+
|
46
|
+
# Thread.exit
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env jruby -S
|
2
|
+
# == Synopsis
|
3
|
+
# Update stock for give product
|
4
|
+
# == Usage
|
5
|
+
# update_stock_inventory.rb -u vtiger_url -e Products -n username -k access_key -p productName -q -1
|
6
|
+
# == Useful commands
|
7
|
+
# note uppercase Q and lowercase -p for product.
|
8
|
+
# jruby update_stock_inventory.rb -u democrm.estormtech.com -c test -n scott -k xxxxx -p "test for rap" -Q -1
|
9
|
+
# == Author
|
10
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
11
|
+
# == Copyright
|
12
|
+
# Copyright (c) 2007 Ficonab Pte. Ltd.
|
13
|
+
# See license for license details
|
14
|
+
require 'yaml'
|
15
|
+
require 'rubygems'
|
16
|
+
gem 'vtiger'
|
17
|
+
require 'vtiger'
|
18
|
+
require 'optparse'
|
19
|
+
require 'rdoc/usage'
|
20
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
25
|
+
RDoc::usage if arg_hash[:help]==true
|
26
|
+
require 'pp'
|
27
|
+
options = arg_hash
|
28
|
+
# set up variables using hash
|
29
|
+
|
30
|
+
puts "vtiger add contact #{Time.now}"
|
31
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
32
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
33
|
+
cmd = Vtiger::Commands.new()
|
34
|
+
cmd.challenge(options)
|
35
|
+
cmd.login(options)
|
36
|
+
cmd.query_product_inventory(options)
|
37
|
+
# consumer_session.close
|
38
|
+
# puts "#{result}"
|
39
|
+
# sleep(1)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
puts '-------------finished processing!!!'
|
44
|
+
|
45
|
+
|
46
|
+
# Thread.exit
|
47
|
+
# exit!
|
48
|
+
|
data/bin/yahoo_csv.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env jruby -S
|
2
|
+
# == Synopsis
|
3
|
+
# Update accounts or accounts based on yahoo statistics
|
4
|
+
# == Usage
|
5
|
+
# yahoo_csv.rb -u vtiger_url -e Contacts -n username -k access_key -f csvfilename
|
6
|
+
# == Useful commands
|
7
|
+
# yahoo_csv.rb -u testsmartroam.estormtech.com -e Contacts -n admin -k xxx -f csvfilename
|
8
|
+
# == Author
|
9
|
+
# Scott Sproule --- Ficonab.com (scott.sproule@ficonab.com)
|
10
|
+
# == Copyright
|
11
|
+
# Copyright (c) 2009 Ficonab Pte. Ltd.
|
12
|
+
# See license for license details
|
13
|
+
require 'yaml'
|
14
|
+
require 'rubygems'
|
15
|
+
gem 'vtiger'
|
16
|
+
require 'vtiger'
|
17
|
+
require 'optparse'
|
18
|
+
require 'rdoc/usage'
|
19
|
+
require 'java' if RUBY_PLATFORM =~ /java/
|
20
|
+
arg_hash=Vtiger::Options.parse_options(ARGV)
|
21
|
+
RDoc::usage if arg_hash[:help]==true
|
22
|
+
require 'pp'
|
23
|
+
options = arg_hash
|
24
|
+
# set up variables using hash
|
25
|
+
fieldmapping={}
|
26
|
+
fieldmapping[:tsipid]='cf_579' #TSIPID cf_578 accounts
|
27
|
+
fieldmapping[:referring_domain]='cf_622' #referring domain
|
28
|
+
fieldmapping[:traffic_source]='cf_623' #traffic source
|
29
|
+
fieldmapping[:campaign]='cf_624' #campaign
|
30
|
+
fieldmapping[:revenue]='cf_627' #revenue
|
31
|
+
fieldmapping[:unique_actions]='cf_628' #campaign
|
32
|
+
fieldmapping[:search_phrase]='cf_629' #campaign
|
33
|
+
puts "vtiger update contact #{Time.now}"
|
34
|
+
puts "vtiger url: #{arg_hash[:url]} "
|
35
|
+
puts "vtiger contact: #{arg_hash[:contact]} "
|
36
|
+
cmd = Vtiger::Commands.new()
|
37
|
+
cmd.challenge(options)
|
38
|
+
cmd.login(options)
|
39
|
+
tsipid='77'
|
40
|
+
# account_id = cmd.query_tsipid(tsipid,fieldmapping,options)
|
41
|
+
# puts "updating account id: #{account_id} tsipid '77' "
|
42
|
+
# values=cmd.retrieve_object(account_id)
|
43
|
+
# puts values.length
|
44
|
+
|
45
|
+
success_summary=""
|
46
|
+
fail_summary=""
|
47
|
+
counter=0
|
48
|
+
total= 0
|
49
|
+
member_label="Member"
|
50
|
+
# cmd.update_yahoo(fieldmapping,values,"www.google.com","traffic_source", "campaign123")
|
51
|
+
traffic_rows=Vtiger::Misc.read_csv_file(options[:filename])
|
52
|
+
traffic_rows.collect { |row|
|
53
|
+
#puts row
|
54
|
+
break if row[member_label]=="Subtotal"
|
55
|
+
success,summary =cmd.process_row(row,fieldmapping,options)
|
56
|
+
total+=1
|
57
|
+
success_summary << "#{total} #{summary}" if success
|
58
|
+
counter+=1 if success
|
59
|
+
fail_summary << "#{total} #{summary}" if !success
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
puts "% complete success #{counter} of total #{total}"
|
64
|
+
puts "Success: #{success_summary}"
|
65
|
+
puts "Fail: #{fail_summary}"
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
# consumer_session.close
|
71
|
+
# puts "#{result}"
|
72
|
+
# sleep(1)
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
puts '-------------finished processing!!!'
|
77
|
+
|
78
|
+
|
79
|
+
# Thread.exit
|
80
|
+
# exit!
|
81
|
+
|
data/lib/vtiger/base.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'net/http'
|
2
|
-
require '
|
2
|
+
#require 'yajl'
|
3
|
+
require 'yajl'
|
3
4
|
require 'digest/md5'
|
4
5
|
require 'erb'
|
5
6
|
class Hash
|
@@ -49,11 +50,12 @@ module Vtiger
|
|
49
50
|
|
50
51
|
body_enc=body.url_encode
|
51
52
|
# puts "attemping post: #{self.endpoint_url}#{operation} body: #{body} body_enc= #{body_enc}"
|
52
|
-
|
53
|
+
resp=ht.post(self.endpoint_url+operation,body_enc,response_header)
|
53
54
|
|
54
55
|
# p response.body.to_s
|
55
|
-
|
56
|
-
|
56
|
+
self.json_parse resp.body
|
57
|
+
# r=JSON.parse response.body
|
58
|
+
# r
|
57
59
|
end
|
58
60
|
def http_ask_get(input_url)
|
59
61
|
# puts "about to HTTP.get on '#{input_url}'"
|
@@ -70,8 +72,8 @@ module Vtiger
|
|
70
72
|
|
71
73
|
|
72
74
|
# puts "resp: " + resp
|
73
|
-
|
74
|
-
|
75
|
+
self.json_parse resp.body
|
76
|
+
# r
|
75
77
|
end
|
76
78
|
|
77
79
|
def login(options)
|
@@ -109,13 +111,9 @@ def describe_object(options)
|
|
109
111
|
# scott not working -- JSON.generate(input_array,{'array_nl'=>'true'})
|
110
112
|
result = http_ask_get(self.endpoint_url+"operation=describe&sessionName=#{self.session_name}&elementType=#{options[:element_type]}")
|
111
113
|
# puts JSON.pretty_generate(result)
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
else
|
116
|
-
puts "rails env is not defined"
|
117
|
-
puts self.json_please(result) #scott tmp=JSON.generate(object_map)
|
118
|
-
end
|
114
|
+
|
115
|
+
puts "#{result.inspect}" #scott tmp=JSON.generate(object_map)
|
116
|
+
|
119
117
|
end
|
120
118
|
def addobject(options)
|
121
119
|
puts "in addobject"
|
@@ -129,15 +127,27 @@ def addobject(options)
|
|
129
127
|
# self.session_name=result["result"]["sessionName"]
|
130
128
|
# puts JSON.pretty_generate(result)
|
131
129
|
end
|
130
|
+
def json_parse(incoming)
|
131
|
+
json = StringIO.new(incoming)
|
132
|
+
parser = Yajl::Parser.new
|
133
|
+
hash = parser.parse(json)
|
134
|
+
end
|
132
135
|
def json_please(object_map)
|
133
136
|
if defined? RAILS_ENV
|
134
137
|
#puts "in JSON code rails env: #{RAILS_ENV}"
|
135
138
|
tmp=object_map.to_json
|
136
139
|
else
|
137
140
|
puts "rails env is not defined"
|
138
|
-
|
141
|
+
# json = StringIO.new()
|
142
|
+
str = Yajl::Encoder.encode(object_map)
|
143
|
+
|
144
|
+
# parser = Yajl::Parser.new
|
145
|
+
# tmp = parser.parse(object_map.to_s)
|
146
|
+
# object_map.to_json # can remove eventually this if statements
|
147
|
+
|
148
|
+
# tmp=YAJL.generate(object_map) #scott tmp=JSON.generate(object_map)
|
139
149
|
end
|
140
|
-
|
150
|
+
str
|
141
151
|
end
|
142
152
|
def updateobject(values)
|
143
153
|
#puts "in updateobject"
|
data/lib/vtiger/commands.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'net/http'
|
2
|
-
require '
|
2
|
+
#require 'yajl'
|
3
3
|
#require 'digest/md5'
|
4
4
|
require 'erb'
|
5
|
+
require 'rubygems'
|
5
6
|
gem 'activesupport'
|
6
7
|
require 'active_support/core_ext/class/attribute_accessors'
|
7
8
|
|
@@ -32,6 +33,23 @@ module Vtiger
|
|
32
33
|
# puts JSON.pretty_generate(result)
|
33
34
|
result["success"]
|
34
35
|
end
|
36
|
+
def add_trouble_ticket(options,status,title,hashv)
|
37
|
+
puts "in add trouble ticket"
|
38
|
+
object_map= { 'assigned_user_id'=>"#{self.userid}",'ticketstatus'=>"#{status}", 'ticket_title'=>"#{title}"}
|
39
|
+
object_map=object_map.merge hashv
|
40
|
+
# 'tsipid'=>"1234"
|
41
|
+
tmp=self.json_please(object_map)
|
42
|
+
input_array ={'operation'=>'create','elementType'=>"HelpDesk",'sessionName'=>"#{self.session_name}", 'element'=>tmp} # removed the true
|
43
|
+
puts "input array:" + input_array.to_s #&username=#{self.username}&accessKey=#{self.md5}
|
44
|
+
# scott not working -- JSON.generate(input_array,{'array_nl'=>'true'})
|
45
|
+
result = http_crm_post("operation=create",input_array)
|
46
|
+
puts "#{result.inspect}"
|
47
|
+
# self.session_name=result["result"]["sessionName"]
|
48
|
+
# puts JSON.pretty_generate(result)
|
49
|
+
ttnumber="invalid"
|
50
|
+
ttnumber =result["result"]["ticket_no"] if result["success"]
|
51
|
+
return result["success"],ttnumber
|
52
|
+
end
|
35
53
|
def action(options)
|
36
54
|
puts "in action"
|
37
55
|
end
|
data/lib/vtiger/support.rb
CHANGED
@@ -34,7 +34,8 @@ module Vtiger
|
|
34
34
|
}
|
35
35
|
opts.on("-D","--email VAL", String) {|val| temp_hash[:email ] = val
|
36
36
|
temp_hash[:destination]=val }
|
37
|
-
|
37
|
+
opts.on("-t","--title VAL", String) {|val| temp_hash[:title ] = val
|
38
|
+
}
|
38
39
|
|
39
40
|
opts.on("-c","--contact VAL", String) {|val| temp_hash[:contact ] = val
|
40
41
|
puts "contact #{val}" }
|
data/test/test_helper.rb
CHANGED
data/test/test_vtiger.rb
CHANGED
@@ -66,6 +66,19 @@ class TestVtiger < Test::Unit::TestCase
|
|
66
66
|
assert lead,"lead should succeed"
|
67
67
|
end
|
68
68
|
|
69
|
+
def test_add_trouble_ticket
|
70
|
+
cmd = Vtiger::Commands.new()
|
71
|
+
challenge=cmd.challenge(@options)
|
72
|
+
login=cmd.login(@options)
|
73
|
+
hv={}
|
74
|
+
# hv[:firstname]='test'
|
75
|
+
tt,ticketnum=cmd.add_trouble_ticket(@options,"Open","testing title",hv)
|
76
|
+
|
77
|
+
puts "trouble ticket is #{tt} ticket number is #{ticketnum}"
|
78
|
+
assert challenge,"challenge is false "
|
79
|
+
assert login,"login should succeed"
|
80
|
+
assert tt,"trouble ticket should succeed"
|
81
|
+
end
|
69
82
|
|
70
83
|
def test_describe_object
|
71
84
|
cmd = Vtiger::Commands.new()
|
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:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 6
|
10
|
+
version: 0.3.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Scott Sproule
|
@@ -15,14 +15,21 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-06-23 00:00:00 +08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
22
|
description: Use to access vtiger crm system from ruby.
|
23
23
|
email: scott.sproule@estormtech.com
|
24
|
-
executables:
|
25
|
-
|
24
|
+
executables:
|
25
|
+
- add_contact.rb
|
26
|
+
- add_lead.rb
|
27
|
+
- describe_object.rb
|
28
|
+
- list_types.rb
|
29
|
+
- query.rb
|
30
|
+
- yahoo_csv.rb
|
31
|
+
- add_trouble_ticket.rb
|
32
|
+
- update_stock_inventory.rb
|
26
33
|
extensions: []
|
27
34
|
|
28
35
|
extra_rdoc_files: []
|
@@ -34,6 +41,15 @@ files:
|
|
34
41
|
- lib/vtiger.rb
|
35
42
|
- test/test_helper.rb
|
36
43
|
- test/test_vtiger.rb
|
44
|
+
- bin/add_contact.rb
|
45
|
+
- bin/add_lead.rb
|
46
|
+
- bin/add_trouble_ticket.rb
|
47
|
+
- bin/describe_object.rb
|
48
|
+
- bin/helloworld.rb
|
49
|
+
- bin/list_types.rb
|
50
|
+
- bin/query.rb
|
51
|
+
- bin/update_stock_inventory.rb
|
52
|
+
- bin/yahoo_csv.rb
|
37
53
|
- History.txt
|
38
54
|
- Manifest.txt
|
39
55
|
- PostInstall.txt
|