google_apps_api 0.1.0
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/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +56 -0
- data/VERSION +1 -0
- data/google_apps_api.gemspec +85 -0
- data/lib/config/calendar.yml +34 -0
- data/lib/config/provisioning.yml +36 -0
- data/lib/google_apps_api/base_api.rb +157 -0
- data/lib/google_apps_api/calendar.rb +65 -0
- data/lib/google_apps_api/calendar_resources.rb +34 -0
- data/lib/google_apps_api/contacts.rb +53 -0
- data/lib/google_apps_api/exceptions.rb +19 -0
- data/lib/google_apps_api/provisioning.rb +294 -0
- data/lib/google_apps_api/user_profiles.rb +101 -0
- data/lib/google_apps_api.rb +15 -0
- data/lib/load_config.rb +17 -0
- data/private/gapps-config.yml +5 -0
- data/private/userscalendars.xml +113 -0
- data/test/google_apps_api-calendar_resources_test.rb +41 -0
- data/test/google_apps_api_calendar_test.rb +81 -0
- data/test/google_apps_api_contacts_test.rb +27 -0
- data/test/google_apps_api_provisioning_test.rb +78 -0
- data/test/google_apps_api_user_profiles_test.rb +30 -0
- data/test/helper.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +127 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GoogleAppsApiCalendarTest < Test::Unit::TestCase
|
4
|
+
include GoogleAppsApi
|
5
|
+
|
6
|
+
|
7
|
+
context "given a connection to apps.cul" do
|
8
|
+
setup do
|
9
|
+
gapps_config =YAML::load_file("private/gapps-config.yml")["apps_ocelot"].symbolize_keys!
|
10
|
+
@api = Calendar::Api.new(gapps_config)
|
11
|
+
end
|
12
|
+
|
13
|
+
should "have a token" do
|
14
|
+
assert @api.token
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# should "be able to retrieve all calendars" do
|
19
|
+
# calendars = @api.retrieve_all_calendars
|
20
|
+
#
|
21
|
+
# assert calendars
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# should "be able to retrieve all calendars for self" do
|
25
|
+
# calendars = @api.retrieve_users_calendars(:username => "_sc_api@ocelot.cul.columbia.edu")
|
26
|
+
# puts calendars.class
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
#
|
30
|
+
should "be able to retrieve own calendars" do
|
31
|
+
calendars = @api.retrieve_users_own_calendars(:username => "nco2104@ocelot.cul.columbia.edu")
|
32
|
+
|
33
|
+
|
34
|
+
calendars.each { |c| assert_kind_of CalendarEntry, c }
|
35
|
+
end
|
36
|
+
|
37
|
+
should "be able to retrieve all calendars subscribed to" do
|
38
|
+
calendars = @api.retrieve_users_calendars(:username => "nco2104@ocelot.cul.columbia.edu")
|
39
|
+
|
40
|
+
calendars.each { |c| assert_kind_of CalendarEntry, c }
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
should "be able to add and remove other calendars" do
|
46
|
+
jws_cal = CalendarEntry.new
|
47
|
+
jws_cal.id = "jws2135%40ocelot.cul.columbia.edu"
|
48
|
+
jws_cal.title = "James Stuart"
|
49
|
+
|
50
|
+
res = @api.delete_calendar_from_user(jws_cal, "nco2104@ocelot.cul.columbia.edu")
|
51
|
+
|
52
|
+
count = @api.retrieve_users_calendars(:username => "nco2104@ocelot.cul.columbia.edu").length
|
53
|
+
|
54
|
+
res = @api.add_calendar_to_user(jws_cal, "nco2104@ocelot.cul.columbia.edu")
|
55
|
+
assert_kind_of CalendarEntry, res
|
56
|
+
|
57
|
+
assert_equal count + 1, @api.retrieve_users_calendars(:username => "nco2104@ocelot.cul.columbia.edu").length
|
58
|
+
|
59
|
+
res = @api.delete_calendar_from_user(res, "nco2104@ocelot.cul.columbia.edu")
|
60
|
+
|
61
|
+
assert_equal count , @api.retrieve_users_calendars(:username => "nco2104@ocelot.cul.columbia.edu").length
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
context "given a calendar entry" do
|
69
|
+
setup do
|
70
|
+
@jws_cal = CalendarEntry.new
|
71
|
+
@jws_cal.id = "jws2135%40ocelot.cul.columbia.edu"
|
72
|
+
@jws_cal.title = "James Stuart"
|
73
|
+
end
|
74
|
+
|
75
|
+
should "generate an add message" do
|
76
|
+
assert_kind_of String, @jws_cal.add_message
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# require 'test_helper'
|
2
|
+
#
|
3
|
+
# class GappsContactsTest < Test::Unit::TestCase
|
4
|
+
#
|
5
|
+
# context "given a connection to apps.cul" do
|
6
|
+
# setup do
|
7
|
+
# gapps_config =YAML::load_file("private/gapps-config.yml")["apps_ocelot"].symbolize_keys!
|
8
|
+
# @api = GoogleAppsApi::SharedContacts::Api.new(gapps_config)
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# should "have a token" do
|
12
|
+
# assert @api.token
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# should "be able to create user" do
|
16
|
+
# @api.create_contact(:name => "Nada API O'Neal", :email => { "home" => "nco2104@columbia.edu", "work" => "nco2104@apps.cul.columbia.edu"})
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# should "be able to retrieve user" do
|
20
|
+
# assert @api.retrieve_all
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GoogleAppsApiProvisioningTest < Test::Unit::TestCase
|
4
|
+
include GoogleAppsApi
|
5
|
+
|
6
|
+
context "given a connection to apps.cul" do
|
7
|
+
setup do
|
8
|
+
gapps_config =YAML::load_file("private/gapps-config.yml")["apps_ocelot"].symbolize_keys!
|
9
|
+
@api = Provisioning::Api.new(gapps_config)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "have a token" do
|
13
|
+
assert @api.token
|
14
|
+
end
|
15
|
+
|
16
|
+
should "be able to retrieve user" do
|
17
|
+
resp = @api.retrieve_user("jws2135")
|
18
|
+
|
19
|
+
assert_kind_of UserEntry, resp
|
20
|
+
|
21
|
+
assert_equal resp.username, "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
|
+
|
31
|
+
should "be able to retrieve all users" do
|
32
|
+
assert_kind_of Array, @api.retrieve_all_users
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
should "be able to create and delete a user" do
|
38
|
+
uid = random_letters(9, "_t_")
|
39
|
+
|
40
|
+
assert_raises GDataError do
|
41
|
+
@api.retrieve_user(uid)
|
42
|
+
end
|
43
|
+
|
44
|
+
ue = UserEntry.new()
|
45
|
+
@api.create_user(uid, :given_name => random_letters(5), :family_name => random_letters(5), :password => random_letters(10))
|
46
|
+
|
47
|
+
assert_kind_of UserEntry, @api.retrieve_user(uid)
|
48
|
+
|
49
|
+
@api.delete_user(uid)
|
50
|
+
|
51
|
+
|
52
|
+
assert_raises GDataError do
|
53
|
+
@api.retrieve_user(uid)
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
should "be able to update a user" do
|
63
|
+
uid = "jws2135"
|
64
|
+
|
65
|
+
@api.update_user(uid, :given_name => "Jimmy", :family_name => "Stuart")
|
66
|
+
|
67
|
+
assert_equal "Jimmy", @api.retrieve_user(uid).given_name
|
68
|
+
|
69
|
+
@api.update_user(uid, :given_name => "James", :family_name => "Stuart")
|
70
|
+
|
71
|
+
assert_equal "James", @api.retrieve_user(uid).given_name
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# require 'test_helper'
|
2
|
+
#
|
3
|
+
# class GappsUserProfilesTest < Test::Unit::TestCase
|
4
|
+
#
|
5
|
+
# context "given a connection to apps.cul" do
|
6
|
+
# setup do
|
7
|
+
# gapps_config =YAML::load_file("private/gapps-config.yml")["apps_ocelot"].symbolize_keys!
|
8
|
+
# @api = GoogleAppsApi::UserProfiles::Api.new(gapps_config)
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# should "have a token" do
|
12
|
+
# assert @api.token
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
#
|
16
|
+
# should "be able to retrieve all users" do
|
17
|
+
# # raise @api.retrieve_all.to_s
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# should "be able to retrieve one user" do
|
21
|
+
# assert @api.retrieve_user("nco2104").to_s
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# should "be able to set email" do
|
25
|
+
# assert @api.set_emails("jws2135",:primary => :work, :home => "james.stuart+profilesapi@gmail.com", :work => "james.stuart+profilesapi@columbia.edu").to_s
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# end
|
data/test/helper.rb
ADDED
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'ruby-debug'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
7
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
8
|
+
require 'google_apps_api'
|
9
|
+
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
|
12
|
+
def random_letters(num, prefix = "", suffix = "")
|
13
|
+
prefix + (0...num).map{65.+(rand(25)).chr}.join + suffix
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google_apps_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Stuart
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-05-05 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: httpclient
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: activesupport
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: shoulda
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0"
|
54
|
+
version:
|
55
|
+
description: APIs for Google Apps (currently Provisioning, Calendar, Calendar Resources)
|
56
|
+
email: tastyhat@jamesstuart.org
|
57
|
+
executables: []
|
58
|
+
|
59
|
+
extensions: []
|
60
|
+
|
61
|
+
extra_rdoc_files:
|
62
|
+
- LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
files:
|
65
|
+
- .document
|
66
|
+
- .gitignore
|
67
|
+
- LICENSE
|
68
|
+
- README.rdoc
|
69
|
+
- Rakefile
|
70
|
+
- VERSION
|
71
|
+
- google_apps_api.gemspec
|
72
|
+
- lib/config/calendar.yml
|
73
|
+
- lib/config/provisioning.yml
|
74
|
+
- lib/google_apps_api.rb
|
75
|
+
- lib/google_apps_api/base_api.rb
|
76
|
+
- lib/google_apps_api/calendar.rb
|
77
|
+
- lib/google_apps_api/calendar_resources.rb
|
78
|
+
- lib/google_apps_api/contacts.rb
|
79
|
+
- lib/google_apps_api/exceptions.rb
|
80
|
+
- lib/google_apps_api/provisioning.rb
|
81
|
+
- lib/google_apps_api/user_profiles.rb
|
82
|
+
- lib/load_config.rb
|
83
|
+
- private/gapps-config.yml
|
84
|
+
- private/userscalendars.xml
|
85
|
+
- test/google_apps_api-calendar_resources_test.rb
|
86
|
+
- test/google_apps_api_calendar_test.rb
|
87
|
+
- test/google_apps_api_contacts_test.rb
|
88
|
+
- test/google_apps_api_provisioning_test.rb
|
89
|
+
- test/google_apps_api_user_profiles_test.rb
|
90
|
+
- test/helper.rb
|
91
|
+
- test/test_helper.rb
|
92
|
+
has_rdoc: true
|
93
|
+
homepage: http://github.com/tastyhat/google_apps_api
|
94
|
+
licenses: []
|
95
|
+
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options:
|
98
|
+
- --charset=UTF-8
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: "0"
|
106
|
+
version:
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: "0"
|
112
|
+
version:
|
113
|
+
requirements: []
|
114
|
+
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 1.3.5
|
117
|
+
signing_key:
|
118
|
+
specification_version: 3
|
119
|
+
summary: Various APIs for Google Apps
|
120
|
+
test_files:
|
121
|
+
- test/google_apps_api-calendar_resources_test.rb
|
122
|
+
- test/google_apps_api_calendar_test.rb
|
123
|
+
- test/google_apps_api_contacts_test.rb
|
124
|
+
- test/google_apps_api_provisioning_test.rb
|
125
|
+
- test/google_apps_api_user_profiles_test.rb
|
126
|
+
- test/helper.rb
|
127
|
+
- test/test_helper.rb
|