sugarcrm 0.6.2 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +13 -8
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/sugarcrm.rb +7 -139
- data/lib/sugarcrm/association_methods.rb +45 -0
- data/lib/sugarcrm/attribute_methods.rb +65 -0
- data/lib/sugarcrm/base.rb +85 -0
- data/lib/sugarcrm/connection.rb +126 -103
- data/lib/sugarcrm/{api → connection/api}/get_available_modules.rb +6 -1
- data/lib/sugarcrm/{api → connection/api}/get_document_revision.rb +2 -1
- data/lib/sugarcrm/{api → connection/api}/get_entries.rb +5 -6
- data/lib/sugarcrm/{api → connection/api}/get_entries_count.rb +3 -5
- data/lib/sugarcrm/{api → connection/api}/get_entry.rb +6 -6
- data/lib/sugarcrm/{api → connection/api}/get_entry_list.rb +6 -6
- data/lib/sugarcrm/{api → connection/api}/get_module_fields.rb +2 -1
- data/lib/sugarcrm/{api → connection/api}/get_note_attachment.rb +1 -1
- data/lib/sugarcrm/connection/api/get_relationships.rb +34 -0
- data/lib/sugarcrm/{api → connection/api}/get_report_entries.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/get_server_info.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/get_user_id.rb +2 -2
- data/lib/sugarcrm/{api → connection/api}/get_user_team_id.rb +2 -2
- data/lib/sugarcrm/{api → connection/api}/login.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/logout.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/seamless_login.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/search_by_module.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/set_campaign_merge.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/set_document_revision.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/set_entries.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/set_entry.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/set_note_attachment.rb +0 -0
- data/lib/sugarcrm/{api → connection/api}/set_relationship.rb +1 -1
- data/lib/sugarcrm/{api → connection/api}/set_relationships.rb +1 -1
- data/lib/sugarcrm/connection/helper.rb +10 -0
- data/lib/sugarcrm/exceptions.rb +6 -0
- data/lib/sugarcrm/module.rb +105 -6
- data/lib/sugarcrm/module_methods.rb +18 -0
- data/lib/sugarcrm/request.rb +13 -3
- data/lib/sugarcrm/response.rb +75 -25
- data/test/connection/test_get_available_modules.rb +12 -0
- data/test/connection/test_get_entries.rb +21 -0
- data/test/connection/test_get_entry.rb +20 -0
- data/test/connection/test_get_entry_list.rb +28 -0
- data/test/connection/test_get_module_fields.rb +14 -0
- data/test/connection/test_get_relationships.rb +15 -0
- data/test/connection/test_get_server_info.rb +12 -0
- data/test/connection/test_get_user_id.rb +12 -0
- data/test/connection/test_get_user_team_id.rb +12 -0
- data/test/connection/test_login.rb +12 -0
- data/test/connection/test_logout.rb +12 -0
- data/test/helper.rb +4 -1
- data/test/test_connection.rb +12 -48
- data/test/test_module.rb +14 -0
- data/test/test_response.rb +5 -14
- data/test/test_sugarcrm.rb +16 -14
- metadata +60 -34
- data/lib/sugarcrm/api/get_relationship.rb +0 -25
- data/lib/sugarcrm/core_ext/attribute.rb +0 -67
- data/lib/sugarcrm/core_ext/remove_method.rb +0 -6
- data/lib/sugarcrm/core_ext/singleton_class.rb +0 -13
data/test/test_sugarcrm.rb
CHANGED
@@ -1,25 +1,17 @@
|
|
1
1
|
require 'helper'
|
2
|
-
require "test/unit"
|
3
|
-
require "pp"
|
4
2
|
|
5
|
-
class
|
6
|
-
context "A SugarCRM::
|
3
|
+
class TestSugarCRM < Test::Unit::TestCase
|
4
|
+
context "A SugarCRM::Base instance" do
|
7
5
|
|
8
6
|
should "return the module name" do
|
9
|
-
assert_equal "Users", SugarCRM::User.
|
7
|
+
assert_equal "Users", SugarCRM::User._module.name
|
10
8
|
end
|
11
9
|
|
12
10
|
should "respond to self.connection" do
|
13
11
|
assert_respond_to SugarCRM::User, :connection
|
14
12
|
assert_instance_of SugarCRM::Connection, SugarCRM::User.connection
|
15
13
|
end
|
16
|
-
|
17
|
-
should "respond to self.register_module_fields" do
|
18
|
-
assert_respond_to SugarCRM::User, :register_module_fields
|
19
|
-
SugarCRM::User.register_module_fields
|
20
|
-
assert SugarCRM::User.module_fields.length > 0
|
21
|
-
end
|
22
|
-
|
14
|
+
|
23
15
|
should "respond to self.connection.logged_in?" do
|
24
16
|
assert SugarCRM::User.connection.logged_in?
|
25
17
|
end
|
@@ -33,16 +25,26 @@ class TestSugarcrm < Test::Unit::TestCase
|
|
33
25
|
assert SugarCRM::User.attribute_methods_generated
|
34
26
|
end
|
35
27
|
|
36
|
-
should "respond to attributes derived from
|
28
|
+
should "respond to attributes derived from #_module.fields" do
|
37
29
|
u = SugarCRM::User.new
|
38
30
|
u.last_name = "Test"
|
39
31
|
assert_equal "Test", u.last_name
|
40
32
|
end
|
41
33
|
|
42
34
|
should "return an an instance of itself when sent #find(id)" do
|
35
|
+
assert_instance_of SugarCRM::User, SugarCRM::User.find(1)
|
36
|
+
end
|
37
|
+
|
38
|
+
should "receive a response containing all fields when sent #get_entry" do
|
43
39
|
u = SugarCRM::User.find(1)
|
44
|
-
|
40
|
+
assert_equal u.user_name, "admin"
|
41
|
+
end
|
42
|
+
|
43
|
+
should "return an email address when sent #email_addresses" do
|
44
|
+
u = SugarCRM::User.find("seed_sarah_id")
|
45
|
+
assert_equal "sarah@example.com", u.email_addresses.first.email_address
|
45
46
|
end
|
47
|
+
|
46
48
|
end
|
47
49
|
|
48
50
|
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: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 7
|
9
9
|
- 2
|
10
|
-
version: 0.
|
10
|
+
version: 0.7.2
|
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-
|
18
|
+
date: 2010-11-13 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -54,11 +54,11 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
hash:
|
57
|
+
hash: 7
|
58
58
|
segments:
|
59
|
-
- 2
|
60
59
|
- 3
|
61
|
-
|
60
|
+
- 0
|
61
|
+
version: "3.0"
|
62
62
|
type: :runtime
|
63
63
|
version_requirements: *id003
|
64
64
|
description: |-
|
@@ -81,40 +81,54 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- VERSION
|
83
83
|
- lib/sugarcrm.rb
|
84
|
-
- lib/sugarcrm/
|
85
|
-
- lib/sugarcrm/
|
86
|
-
- lib/sugarcrm/
|
87
|
-
- lib/sugarcrm/api/get_entries_count.rb
|
88
|
-
- lib/sugarcrm/api/get_entry.rb
|
89
|
-
- lib/sugarcrm/api/get_entry_list.rb
|
90
|
-
- lib/sugarcrm/api/get_module_fields.rb
|
91
|
-
- lib/sugarcrm/api/get_note_attachment.rb
|
92
|
-
- lib/sugarcrm/api/get_relationship.rb
|
93
|
-
- lib/sugarcrm/api/get_report_entries.rb
|
94
|
-
- lib/sugarcrm/api/get_server_info.rb
|
95
|
-
- lib/sugarcrm/api/get_user_id.rb
|
96
|
-
- lib/sugarcrm/api/get_user_team_id.rb
|
97
|
-
- lib/sugarcrm/api/login.rb
|
98
|
-
- lib/sugarcrm/api/logout.rb
|
99
|
-
- lib/sugarcrm/api/seamless_login.rb
|
100
|
-
- lib/sugarcrm/api/search_by_module.rb
|
101
|
-
- lib/sugarcrm/api/set_campaign_merge.rb
|
102
|
-
- lib/sugarcrm/api/set_document_revision.rb
|
103
|
-
- lib/sugarcrm/api/set_entries.rb
|
104
|
-
- lib/sugarcrm/api/set_entry.rb
|
105
|
-
- lib/sugarcrm/api/set_note_attachment.rb
|
106
|
-
- lib/sugarcrm/api/set_relationship.rb
|
107
|
-
- lib/sugarcrm/api/set_relationships.rb
|
84
|
+
- lib/sugarcrm/association_methods.rb
|
85
|
+
- lib/sugarcrm/attribute_methods.rb
|
86
|
+
- lib/sugarcrm/base.rb
|
108
87
|
- lib/sugarcrm/connection.rb
|
109
|
-
- lib/sugarcrm/
|
110
|
-
- lib/sugarcrm/
|
111
|
-
- lib/sugarcrm/
|
88
|
+
- lib/sugarcrm/connection/api/get_available_modules.rb
|
89
|
+
- lib/sugarcrm/connection/api/get_document_revision.rb
|
90
|
+
- lib/sugarcrm/connection/api/get_entries.rb
|
91
|
+
- lib/sugarcrm/connection/api/get_entries_count.rb
|
92
|
+
- lib/sugarcrm/connection/api/get_entry.rb
|
93
|
+
- lib/sugarcrm/connection/api/get_entry_list.rb
|
94
|
+
- lib/sugarcrm/connection/api/get_module_fields.rb
|
95
|
+
- lib/sugarcrm/connection/api/get_note_attachment.rb
|
96
|
+
- lib/sugarcrm/connection/api/get_relationships.rb
|
97
|
+
- lib/sugarcrm/connection/api/get_report_entries.rb
|
98
|
+
- lib/sugarcrm/connection/api/get_server_info.rb
|
99
|
+
- lib/sugarcrm/connection/api/get_user_id.rb
|
100
|
+
- lib/sugarcrm/connection/api/get_user_team_id.rb
|
101
|
+
- lib/sugarcrm/connection/api/login.rb
|
102
|
+
- lib/sugarcrm/connection/api/logout.rb
|
103
|
+
- lib/sugarcrm/connection/api/seamless_login.rb
|
104
|
+
- lib/sugarcrm/connection/api/search_by_module.rb
|
105
|
+
- lib/sugarcrm/connection/api/set_campaign_merge.rb
|
106
|
+
- lib/sugarcrm/connection/api/set_document_revision.rb
|
107
|
+
- lib/sugarcrm/connection/api/set_entries.rb
|
108
|
+
- lib/sugarcrm/connection/api/set_entry.rb
|
109
|
+
- lib/sugarcrm/connection/api/set_note_attachment.rb
|
110
|
+
- lib/sugarcrm/connection/api/set_relationship.rb
|
111
|
+
- lib/sugarcrm/connection/api/set_relationships.rb
|
112
|
+
- lib/sugarcrm/connection/helper.rb
|
112
113
|
- lib/sugarcrm/exceptions.rb
|
113
114
|
- lib/sugarcrm/module.rb
|
115
|
+
- lib/sugarcrm/module_methods.rb
|
114
116
|
- lib/sugarcrm/request.rb
|
115
117
|
- lib/sugarcrm/response.rb
|
118
|
+
- test/connection/test_get_available_modules.rb
|
119
|
+
- test/connection/test_get_entries.rb
|
120
|
+
- test/connection/test_get_entry.rb
|
121
|
+
- test/connection/test_get_entry_list.rb
|
122
|
+
- test/connection/test_get_module_fields.rb
|
123
|
+
- test/connection/test_get_relationships.rb
|
124
|
+
- test/connection/test_get_server_info.rb
|
125
|
+
- test/connection/test_get_user_id.rb
|
126
|
+
- test/connection/test_get_user_team_id.rb
|
127
|
+
- test/connection/test_login.rb
|
128
|
+
- test/connection/test_logout.rb
|
116
129
|
- test/helper.rb
|
117
130
|
- test/test_connection.rb
|
131
|
+
- test/test_module.rb
|
118
132
|
- test/test_response.rb
|
119
133
|
- test/test_sugarcrm.rb
|
120
134
|
has_rdoc: true
|
@@ -152,7 +166,19 @@ signing_key:
|
|
152
166
|
specification_version: 3
|
153
167
|
summary: Ruby based REST client for SugarCRM
|
154
168
|
test_files:
|
169
|
+
- test/connection/test_get_available_modules.rb
|
170
|
+
- test/connection/test_get_entries.rb
|
171
|
+
- test/connection/test_get_entry.rb
|
172
|
+
- test/connection/test_get_entry_list.rb
|
173
|
+
- test/connection/test_get_module_fields.rb
|
174
|
+
- test/connection/test_get_relationships.rb
|
175
|
+
- test/connection/test_get_server_info.rb
|
176
|
+
- test/connection/test_get_user_id.rb
|
177
|
+
- test/connection/test_get_user_team_id.rb
|
178
|
+
- test/connection/test_login.rb
|
179
|
+
- test/connection/test_logout.rb
|
155
180
|
- test/helper.rb
|
156
181
|
- test/test_connection.rb
|
182
|
+
- test/test_module.rb
|
157
183
|
- test/test_response.rb
|
158
184
|
- test/test_sugarcrm.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module SugarCRM; class Connection
|
2
|
-
# Retrieves a collection of beans that are related
|
3
|
-
# to the specified bean and, optionally, returns
|
4
|
-
# relationship data
|
5
|
-
def get_relationship(module_name, id, related_to, options={})
|
6
|
-
login! unless logged_in?
|
7
|
-
json = <<-EOF
|
8
|
-
{
|
9
|
-
\"session\": \"#{@session}\"\,
|
10
|
-
\"module_name\": \"#{module_name}\"\,
|
11
|
-
\"module_ids\": \"#{id}\"\,
|
12
|
-
\"link_field_name\": \"#{related_to.downcase}\"\,
|
13
|
-
\"related_module_query\": \"#{options[:related_module_query]}\"\,
|
14
|
-
\"related_fields\": #{options[:related_fields].to_json}\,
|
15
|
-
\"related_module_link_name_to_fields_array\": #{options[:related_link_fields].to_json}\,
|
16
|
-
\"deleted\": #{options[:deleted]}
|
17
|
-
}
|
18
|
-
EOF
|
19
|
-
json.gsub!(/^\s{6}/,'')
|
20
|
-
get(:get_relationship, json)
|
21
|
-
end
|
22
|
-
|
23
|
-
alias :get_relationships :get_relationship
|
24
|
-
|
25
|
-
end; end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
#require 'singleton_class'
|
2
|
-
#require 'remove_method'
|
3
|
-
|
4
|
-
class Class
|
5
|
-
# Declare a class-level attribute whose value is inheritable and
|
6
|
-
# overwritable by subclasses:
|
7
|
-
#
|
8
|
-
# class Base
|
9
|
-
# class_attribute :setting
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# class Subclass < Base
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# Base.setting = true
|
16
|
-
# Subclass.setting # => true
|
17
|
-
# Subclass.setting = false
|
18
|
-
# Subclass.setting # => false
|
19
|
-
# Base.setting # => true
|
20
|
-
#
|
21
|
-
# This matches normal Ruby method inheritance: think of writing an attribute
|
22
|
-
# on a subclass as overriding the reader method.
|
23
|
-
#
|
24
|
-
# For convenience, a query method is defined as well:
|
25
|
-
#
|
26
|
-
# Subclass.setting? # => false
|
27
|
-
#
|
28
|
-
# Instances may overwrite the class value in the same way:
|
29
|
-
#
|
30
|
-
# Base.setting = true
|
31
|
-
# object = Base.new
|
32
|
-
# object.setting # => true
|
33
|
-
# object.setting = false
|
34
|
-
# object.setting # => false
|
35
|
-
# Base.setting # => true
|
36
|
-
#
|
37
|
-
# To opt out of the instance writer method, pass :instance_writer => false.
|
38
|
-
#
|
39
|
-
# object.setting = false # => NoMethodError
|
40
|
-
def class_attribute(*attrs)
|
41
|
-
instance_writer = !attrs.last.is_a?(Hash) || attrs.pop[:instance_writer]
|
42
|
-
|
43
|
-
attrs.each do |name|
|
44
|
-
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
45
|
-
def self.#{name}() nil end
|
46
|
-
def self.#{name}?() !!#{name} end
|
47
|
-
|
48
|
-
def self.#{name}=(val)
|
49
|
-
singleton_class.class_eval do
|
50
|
-
remove_possible_method(:#{name})
|
51
|
-
define_method(:#{name}) { val }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def #{name}
|
56
|
-
defined?(@#{name}) ? @#{name} : singleton_class.#{name}
|
57
|
-
end
|
58
|
-
|
59
|
-
def #{name}?
|
60
|
-
!!#{name}
|
61
|
-
end
|
62
|
-
RUBY
|
63
|
-
|
64
|
-
attr_writer name if instance_writer
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Kernel
|
2
|
-
# Returns the object's singleton class.
|
3
|
-
def singleton_class
|
4
|
-
class << self
|
5
|
-
self
|
6
|
-
end
|
7
|
-
end unless respond_to?(:singleton_class) # exists in 1.9.2
|
8
|
-
|
9
|
-
# class_eval on an object acts like singleton_class.class_eval.
|
10
|
-
def class_eval(*args, &block)
|
11
|
-
singleton_class.class_eval(*args, &block)
|
12
|
-
end
|
13
|
-
end
|