gaah 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -4
- data/Gemfile.lock +29 -4
- data/README.md +9 -1
- data/gaah.gemspec +1 -0
- data/lib/gaah/base.rb +1 -0
- data/lib/gaah/resource/api.rb +31 -0
- data/lib/gaah/resource/resource.rb +37 -0
- data/lib/gaah/version.rb +1 -1
- data/spec/models/resource_spec.rb +6 -0
- metadata +19 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDhkOTRiM2I1Njk1N2IwODg1ZjA4NTIwYWE4ODhiMDQyMjE5NDA2MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZmE0ZTNjZGZiMTE0Y2JiNDVjOTVkOTI0ZDEzMDdiYTBmMTQyNjJiYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmE3OTIyNjU5MmRiY2VlMWZmN2YyMGQ1YWM4ZjkyMDg3ZTc5ZDAzODA3YmEz
|
10
|
+
YmFjNDRlNWM2MjU1MDI2OWVjNGQxNDRhODQyMGY1N2MwN2I5YWJiZjcwZjU4
|
11
|
+
ZDZiNjdmOGNkYjhmZGE3M2JlMjUxYzhmMzgxYzEzM2M4NTYxZTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NDc4OGU4MjA1MWM0ODM1MmUyOGE4NDdhZThmMzAzYzVlZDI4NGIwNGMzOTA4
|
14
|
+
YjMyNzNlZWM2NWQ2YTcxYmVlZWE0MmFiMjdkZjJhMGUyZDlkNjBlNTM5YjFk
|
15
|
+
YjFlODEyZGM3YjQzYmQ4NmQxODMyY2RlMGVlZGUwY2VjMmE0Mjk=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gaah (0.1.5)
|
5
|
+
nokogiri (~> 1.5)
|
6
|
+
oauth (~> 0.4)
|
7
|
+
oauth2 (~> 0.9)
|
8
|
+
queryparams (= 0.0.3)
|
9
|
+
|
1
10
|
GEM
|
2
11
|
remote: https://rubygems.org/
|
3
12
|
specs:
|
4
13
|
diff-lcs (1.2.2)
|
5
|
-
|
14
|
+
faraday (0.8.8)
|
15
|
+
multipart-post (~> 1.2.0)
|
16
|
+
httpauth (0.2.0)
|
17
|
+
jwt (0.1.8)
|
18
|
+
multi_json (>= 1.5)
|
19
|
+
mini_portile (0.5.1)
|
20
|
+
multi_json (1.7.8)
|
21
|
+
multi_xml (0.5.5)
|
22
|
+
multipart-post (1.2.0)
|
23
|
+
nokogiri (1.6.0)
|
24
|
+
mini_portile (~> 0.5.0)
|
6
25
|
oauth (0.4.7)
|
26
|
+
oauth2 (0.9.2)
|
27
|
+
faraday (~> 0.8)
|
28
|
+
httpauth (~> 0.2)
|
29
|
+
jwt (~> 0.1.4)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
multi_xml (~> 0.5)
|
32
|
+
rack (~> 1.2)
|
7
33
|
queryparams (0.0.3)
|
34
|
+
rack (1.5.2)
|
8
35
|
rspec (2.13.0)
|
9
36
|
rspec-core (~> 2.13.0)
|
10
37
|
rspec-expectations (~> 2.13.0)
|
@@ -18,7 +45,5 @@ PLATFORMS
|
|
18
45
|
ruby
|
19
46
|
|
20
47
|
DEPENDENCIES
|
21
|
-
|
22
|
-
oauth (~> 0.4)
|
23
|
-
queryparams (= 0.0.3)
|
48
|
+
gaah!
|
24
49
|
rspec (~> 2.5)
|
data/README.md
CHANGED
@@ -33,8 +33,16 @@ events = user.events(xoauth_requestor_id)
|
|
33
33
|
event = events.first
|
34
34
|
event.title # "Meeting with Joe"
|
35
35
|
event.when.start_time # 2013-04-16 13:00:00 -0400
|
36
|
+
|
37
|
+
# Get calendar resources *
|
38
|
+
rooms = Gaah::Resource::Api.resources
|
39
|
+
room = rooms.first
|
40
|
+
room.name # "U.S.S. Distill"
|
41
|
+
room.type # "Conference room"
|
36
42
|
```
|
37
43
|
|
44
|
+
* This API requires [admin API access found here](https://admin.google.com/AdminHome#SecuritySettings:flyout=apimanagement).
|
45
|
+
|
38
46
|
### Resources
|
39
47
|
|
40
48
|
Warning: Google documentation links sometimes move without good redirection.
|
@@ -44,8 +52,8 @@ Warning: Google documentation links sometimes move without good redirection.
|
|
44
52
|
* [Google Apps Administrative APIs](https://developers.google.com/google-apps/admin-apis)
|
45
53
|
* [Google Calendar API v2](https://developers.google.com/google-apps/calendar/v2/developers_guide_protocol)
|
46
54
|
* [Google Apps Provisioning API v2](https://developers.google.com/google-apps/provisioning/)
|
55
|
+
* [Google Apps Calendar Resource API](https://developers.google.com/admin-sdk/calendar-resource/)
|
47
56
|
|
48
57
|
### Todo
|
49
58
|
* Provisioning API is deprecated, use Directory API
|
50
|
-
* Possibly integrate [Google Apps Calendar Resource API](https://developers.google.com/google-apps/calendar-resource/)
|
51
59
|
* Error handling
|
data/gaah.gemspec
CHANGED
data/lib/gaah/base.rb
CHANGED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'gaah/resource/resource'
|
2
|
+
|
3
|
+
module Gaah
|
4
|
+
module Resource
|
5
|
+
class Api
|
6
|
+
class << self
|
7
|
+
def resources
|
8
|
+
fetch_resources("https://apps-apis.google.com/a/feeds/#{Gaah.domain}/user/2.0")
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def fetch_resources(url)
|
14
|
+
url = "https://apps-apis.google.com/a/feeds/calendar/resource/2.0/#{Gaah.domain}"
|
15
|
+
xml = ApiClient.instance.get(url)
|
16
|
+
parsed = Nokogiri::XML(xml)
|
17
|
+
|
18
|
+
current_list = Resource.batch_create(parsed/:entry)
|
19
|
+
next_link = (parsed/'link[rel=next]').first
|
20
|
+
|
21
|
+
if next_link.nil?
|
22
|
+
current_list
|
23
|
+
else
|
24
|
+
url = next_link.attr('href')
|
25
|
+
current_list + fetch_resources(url)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Gaah
|
2
|
+
module Resource
|
3
|
+
class Resource < Gaah::ApiModel
|
4
|
+
attr_reader :name, :email, :type
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
store_xml(xml)
|
8
|
+
|
9
|
+
@id = inner_text(:id)
|
10
|
+
(@xml/'apps|property').each do |property|
|
11
|
+
case property.attributes['name'].value
|
12
|
+
when 'resourceCommonName' then @name = property.attributes['value'].value
|
13
|
+
when 'resourceEmail' then @email = property.attributes['value'].value
|
14
|
+
when 'resourceType' then @type = property.attributes['value'].value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_json(*args)
|
20
|
+
{
|
21
|
+
id: @id,
|
22
|
+
name: @name,
|
23
|
+
email: @email,
|
24
|
+
type: @type,
|
25
|
+
}.to_json
|
26
|
+
end
|
27
|
+
|
28
|
+
def marshal_dump
|
29
|
+
[@id, @name, @email, @type]
|
30
|
+
end
|
31
|
+
|
32
|
+
def marshal_load(array)
|
33
|
+
@id, @name, @email, @type = array
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/gaah/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaah
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hwan-Joon Choi
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oauth2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: queryparams
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,10 +104,13 @@ files:
|
|
90
104
|
- lib/gaah/exceptions.rb
|
91
105
|
- lib/gaah/provisioning/api.rb
|
92
106
|
- lib/gaah/provisioning/user.rb
|
107
|
+
- lib/gaah/resource/api.rb
|
108
|
+
- lib/gaah/resource/resource.rb
|
93
109
|
- lib/gaah/version.rb
|
94
110
|
- spec/fixtures/calendar.xml
|
95
111
|
- spec/fixtures/provisioning.xml
|
96
112
|
- spec/models/event_spec.rb
|
113
|
+
- spec/models/resource_spec.rb
|
97
114
|
- spec/models/user_spec.rb
|
98
115
|
- spec/spec_helper.rb
|
99
116
|
homepage: https://github.com/distill-inc/gaah
|
@@ -123,5 +140,6 @@ test_files:
|
|
123
140
|
- spec/fixtures/calendar.xml
|
124
141
|
- spec/fixtures/provisioning.xml
|
125
142
|
- spec/models/event_spec.rb
|
143
|
+
- spec/models/resource_spec.rb
|
126
144
|
- spec/models/user_spec.rb
|
127
145
|
- spec/spec_helper.rb
|