sugarcrm 0.8.0 → 0.8.1
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/VERSION +1 -1
- data/lib/sugarcrm/connection/api/get_report_entries.rb +3 -5
- data/lib/sugarcrm/connection/api/search_by_module.rb +1 -1
- data/lib/sugarcrm/connection/api/set_relationship.rb +10 -4
- data/lib/sugarcrm/connection/api/set_relationships.rb +1 -1
- data/lib/sugarcrm/connection.rb +2 -2
- data/test/connection/test_set_relationship.rb +27 -0
- metadata +6 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.8.
|
1
|
+
0.8.1
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module SugarCRM; class Connection
|
2
2
|
# Retrieves a list of report entries based on specified report IDs.
|
3
|
-
def get_report_entries(ids,
|
3
|
+
def get_report_entries(ids, opts={})
|
4
4
|
login! unless logged_in?
|
5
|
-
{
|
6
|
-
:select_fields => '',
|
7
|
-
}.merge! options
|
5
|
+
options = {:select_fields => ''}.merge! opts
|
8
6
|
|
9
7
|
json = <<-EOF
|
10
8
|
{
|
11
9
|
\"session\": \"#{@session}\"\,
|
12
10
|
\"ids\": #{ids.to_json}\,
|
13
|
-
\"select_fields\": \"#{select_fields}\"
|
11
|
+
\"select_fields\": \"#{options[:select_fields].to_json}\"
|
14
12
|
}
|
15
13
|
EOF
|
16
14
|
json.gsub!(/^\s{6}/,'')
|
@@ -2,7 +2,7 @@ module SugarCRM; class Connection
|
|
2
2
|
# Returns the ID, module name and fields for specified modules.
|
3
3
|
# Supported modules are Accounts, Bugs, Calls, Cases, Contacts,
|
4
4
|
# Leads, Opportunities, Projects, Project Tasks, and Quotes.
|
5
|
-
def search_by_module(search_string, modules,
|
5
|
+
def search_by_module(search_string, modules, opts={})
|
6
6
|
login! unless logged_in?
|
7
7
|
|
8
8
|
options = {
|
@@ -1,15 +1,21 @@
|
|
1
1
|
module SugarCRM; class Connection
|
2
2
|
# Sets a single relationship between two SugarBeans.
|
3
|
-
def set_relationship(module_name, module_id, link_field_name, related_ids)
|
3
|
+
def set_relationship(module_name, module_id, link_field_name, related_ids, opts={})
|
4
4
|
login! unless logged_in?
|
5
|
+
options = {
|
6
|
+
:name_value_list => [],
|
7
|
+
:delete => 0,
|
8
|
+
}.merge! opts
|
5
9
|
raise ArgumentError, "related_ids must be an Array" unless related_ids.class == Array
|
6
10
|
json = <<-EOF
|
7
11
|
{
|
8
12
|
\"session\": \"#{@session}\"\,
|
9
13
|
\"module_name\": \"#{module_name}\"\,
|
10
|
-
\"module_id\": #{module_id}\,
|
11
|
-
\"link_field_name\": #{link_field_name}\,
|
12
|
-
\"related_ids\": #{
|
14
|
+
\"module_id\": \"#{module_id}\"\,
|
15
|
+
\"link_field_name\": \"#{link_field_name}\"\,
|
16
|
+
\"related_ids\": #{related_ids.to_json}\,
|
17
|
+
\"name_value_list\": #{options[:name_value_list].to_json}\,
|
18
|
+
\"delete\": #{options[:delete]}
|
13
19
|
}
|
14
20
|
EOF
|
15
21
|
json.gsub!(/^\s{6}/,'')
|
@@ -13,7 +13,7 @@ module SugarCRM; class Connection
|
|
13
13
|
\"module_names\": \"#{module_names.to_json}\"\,
|
14
14
|
\"module_ids\": #{module_ids.to_json}\,
|
15
15
|
\"link_field_names\": #{link_field_names.to_json}\,
|
16
|
-
\"related_ids\": #{
|
16
|
+
\"related_ids\": #{related_ids.to_json}
|
17
17
|
}
|
18
18
|
EOF
|
19
19
|
json.gsub!(/^\s{6}/,'')
|
data/lib/sugarcrm/connection.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
1
|
require 'uri'
|
3
2
|
require 'net/https'
|
4
3
|
|
5
4
|
require 'rubygems'
|
5
|
+
# TODO: Remove this dependency - ActiveSupport should cover it.
|
6
6
|
require 'json'
|
7
7
|
|
8
8
|
require 'sugarcrm/connection/helper'
|
@@ -72,7 +72,7 @@ module SugarCRM; class Connection
|
|
72
72
|
@connection.start
|
73
73
|
end
|
74
74
|
|
75
|
-
# Send a
|
75
|
+
# Send a request to the Sugar Instance
|
76
76
|
def send!(method, json)
|
77
77
|
@request = SugarCRM::Request.new(@url, method, json, @options[:debug])
|
78
78
|
if @request.length > 3900
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestSetRelationships < Test::Unit::TestCase
|
4
|
+
context "A SugarCRM.connection" do
|
5
|
+
setup do
|
6
|
+
SugarCRM::Connection.new(URL, USER, PASS, {:register_modules => false, :debug => false})
|
7
|
+
|
8
|
+
#retrieve ID of ACLRole and append shove it into the @id array
|
9
|
+
@id = [SugarCRM::ACLRole.find_by_name("Marketing Administrator").id]
|
10
|
+
assert @id
|
11
|
+
end
|
12
|
+
|
13
|
+
should "add the role found above to the user who's id is below when sent #set_relationship" do
|
14
|
+
response = SugarCRM.connection.set_relationship(
|
15
|
+
"Users","seed_will_id","aclroles",@id
|
16
|
+
)
|
17
|
+
assert_equal("failed0deleted0created1", response.to_s)
|
18
|
+
end
|
19
|
+
|
20
|
+
should "remove the role that was previously added when sent #set_relationship and delete=1" do
|
21
|
+
response = SugarCRM.connection.set_relationship(
|
22
|
+
"Users","seed_will_id","aclroles",@id,opts={:delete => 1}
|
23
|
+
)
|
24
|
+
assert_equal("failed0deleted1created0", response.to_s)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcrm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 61
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 1
|
10
|
+
version: 0.8.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Carl Hicks
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-12-
|
18
|
+
date: 2010-12-08 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- test/connection/test_get_user_team_id.rb
|
127
127
|
- test/connection/test_login.rb
|
128
128
|
- test/connection/test_logout.rb
|
129
|
+
- test/connection/test_set_relationship.rb
|
129
130
|
- test/helper.rb
|
130
131
|
- test/test_connection.rb
|
131
132
|
- test/test_module.rb
|
@@ -177,6 +178,7 @@ test_files:
|
|
177
178
|
- test/connection/test_get_user_team_id.rb
|
178
179
|
- test/connection/test_login.rb
|
179
180
|
- test/connection/test_logout.rb
|
181
|
+
- test/connection/test_set_relationship.rb
|
180
182
|
- test/helper.rb
|
181
183
|
- test/test_connection.rb
|
182
184
|
- test/test_module.rb
|