google_apps_api 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/google_apps_api.gemspec +1 -1
- data/lib/google_apps_api/contacts.rb +10 -0
- data/test/google_apps_api_contacts_test.rb +12 -39
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/google_apps_api.gemspec
CHANGED
@@ -62,6 +62,16 @@ module GoogleAppsApi #:nodoc:
|
|
62
62
|
@id = xml.at_css("id").content.gsub(/^.+\/base\//,"")
|
63
63
|
@domain = xml.at_css("id").content.gsub(/^.+\/contacts\/([^\/]+)\/.+$/,"\\1")
|
64
64
|
@name = xml.at_css("title").content
|
65
|
+
|
66
|
+
xml.css("gd|email").each do |email_node|
|
67
|
+
loc = email_node.attribute("rel").content.gsub(/^.+\#/,"").to_sym
|
68
|
+
email = email_node.attribute("address").content
|
69
|
+
primary = email_node.attribute("primary") && email_node.attribute("primary").content == "true"
|
70
|
+
|
71
|
+
@primary_email = loc if primary
|
72
|
+
@emails[loc] = email
|
73
|
+
|
74
|
+
end
|
65
75
|
else
|
66
76
|
if args.first.kind_of?(String)
|
67
77
|
super(:contact => args.first)
|
@@ -5,56 +5,29 @@ class GoogleAppsApiContactsTest < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
context "given a connection to apps.cul" do
|
7
7
|
setup do
|
8
|
-
gapps_config =YAML::load_file("private/gapps-config.yml")["
|
8
|
+
gapps_config =YAML::load_file("private/gapps-config.yml")["apps_ocelot"].symbolize_keys!
|
9
9
|
@co_api = Contacts::Api.new(gapps_config)
|
10
10
|
end
|
11
11
|
|
12
12
|
should "have a token" do
|
13
13
|
assert @co_api.token
|
14
14
|
end
|
15
|
-
|
16
|
-
# should "be able to retrieve user" do
|
17
|
-
# resp = @api.retrieve_user("jws2135")
|
18
|
-
#
|
19
|
-
# assert_kind_of UserEntity, resp
|
20
|
-
#
|
21
|
-
# assert_equal resp.id, "jws2135"
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# should "throw an error if given an invalid user" do
|
25
|
-
# assert_raises GDataError do
|
26
|
-
# resp = @api.retrieve_user("xx_jws2135")
|
27
|
-
# end
|
28
|
-
# end
|
29
|
-
#
|
30
|
-
#
|
15
|
+
|
31
16
|
should "be able to retrieve all contacts" do
|
32
17
|
cons = @co_api.retrieve_all_contacts
|
33
18
|
assert_kind_of Array, cons
|
34
19
|
|
35
20
|
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# should "be able to create a contact" do
|
47
|
-
# contact = ContactEntity.new(:id => "_new_", :name => "Bizarre Test", :emails => {:work => "james.stuart+bizarretest@columbia.edu", :home => "james.stuart+bizarretest@gmail.com"}, :primary_email => :work)
|
48
|
-
# res = @co_api.create_contact(contact, :debug => true)
|
49
|
-
#
|
50
|
-
# assert_kind_of ContactEntity, res
|
51
|
-
#
|
52
|
-
# puts res.inspect
|
53
|
-
#
|
54
|
-
# # @co_api.remove_contact(res, :debug => true)
|
55
|
-
#
|
56
|
-
# end
|
57
|
-
#
|
21
|
+
|
22
|
+
should "be able to create a contact" do
|
23
|
+
contact = ContactEntity.new(:id => "_new_", :name => "Bizarre Test", :emails => {:work => "james.stuart+bizarretest@columbia.edu", :home => "james.stuart+bizarretest@gmail.com"}, :primary_email => :work)
|
24
|
+
res = @co_api.create_contact(contact)
|
25
|
+
|
26
|
+
assert_kind_of ContactEntity, res
|
27
|
+
|
28
|
+
@co_api.remove_contact(res)
|
29
|
+
end
|
30
|
+
|
58
31
|
|
59
32
|
|
60
33
|
#
|