google-api 0.0.1.alpha → 0.0.1.beta
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/CHANGELOG.md +11 -1
- data/README.md +16 -12
- data/google-api.gemspec +4 -4
- data/lib/google-api/active_record_inclusions.rb +4 -0
- data/lib/google-api/api.rb +110 -84
- data/lib/google-api/client.rb +23 -23
- data/lib/google-api/oauth2.rb +16 -0
- data/lib/google-api/railtie.rb +1 -1
- data/lib/google-api.rb +43 -6
- data/spec/fixtures/discovery_drive.json +22 -0
- data/spec/fixtures/discovery_rest_drive.json +2348 -0
- data/spec/fixtures/drive_error.json +13 -0
- data/spec/fixtures/drive_files.json +51 -0
- data/spec/fixtures/refresh_access_token.json +5 -0
- data/spec/google-api/api_spec.rb +201 -0
- data/spec/google-api/client_spec.rb +115 -0
- data/spec/google-api_spec.rb +102 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/faraday_stubs.rb +17 -0
- data/spec/support/fixture.rb +9 -0
- data/spec/support/oauth2_response.rb +17 -0
- data/spec/support/oauthable_object.rb +27 -0
- metadata +42 -17
- data/lib/google-api/api/calendar.rb +0 -44
- data/lib/google-api/api/drive.rb +0 -53
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,40 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: mime-types
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: '1.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: oauth2
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
37
|
+
version: 0.8.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
45
|
+
version: 0.8.0
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: bundler
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -125,11 +125,23 @@ files:
|
|
125
125
|
- lib/google-api.rb
|
126
126
|
- lib/google-api/active_record_inclusions.rb
|
127
127
|
- lib/google-api/api.rb
|
128
|
-
- lib/google-api/api/calendar.rb
|
129
|
-
- lib/google-api/api/drive.rb
|
130
128
|
- lib/google-api/client.rb
|
129
|
+
- lib/google-api/oauth2.rb
|
131
130
|
- lib/google-api/railtie.rb
|
132
|
-
|
131
|
+
- spec/fixtures/discovery_drive.json
|
132
|
+
- spec/fixtures/discovery_rest_drive.json
|
133
|
+
- spec/fixtures/drive_error.json
|
134
|
+
- spec/fixtures/drive_files.json
|
135
|
+
- spec/fixtures/refresh_access_token.json
|
136
|
+
- spec/google-api/api_spec.rb
|
137
|
+
- spec/google-api/client_spec.rb
|
138
|
+
- spec/google-api_spec.rb
|
139
|
+
- spec/spec_helper.rb
|
140
|
+
- spec/support/faraday_stubs.rb
|
141
|
+
- spec/support/fixture.rb
|
142
|
+
- spec/support/oauth2_response.rb
|
143
|
+
- spec/support/oauthable_object.rb
|
144
|
+
homepage: https://github.com/agrobbin/google-api
|
133
145
|
licenses: []
|
134
146
|
post_install_message:
|
135
147
|
rdoc_options: []
|
@@ -143,7 +155,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
143
155
|
version: '0'
|
144
156
|
segments:
|
145
157
|
- 0
|
146
|
-
hash:
|
158
|
+
hash: -2769347911649466323
|
147
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
160
|
none: false
|
149
161
|
requirements:
|
@@ -156,4 +168,17 @@ rubygems_version: 1.8.24
|
|
156
168
|
signing_key:
|
157
169
|
specification_version: 3
|
158
170
|
summary: A simple but powerful ruby API wrapper for Google's services.
|
159
|
-
test_files:
|
171
|
+
test_files:
|
172
|
+
- spec/fixtures/discovery_drive.json
|
173
|
+
- spec/fixtures/discovery_rest_drive.json
|
174
|
+
- spec/fixtures/drive_error.json
|
175
|
+
- spec/fixtures/drive_files.json
|
176
|
+
- spec/fixtures/refresh_access_token.json
|
177
|
+
- spec/google-api/api_spec.rb
|
178
|
+
- spec/google-api/client_spec.rb
|
179
|
+
- spec/google-api_spec.rb
|
180
|
+
- spec/spec_helper.rb
|
181
|
+
- spec/support/faraday_stubs.rb
|
182
|
+
- spec/support/fixture.rb
|
183
|
+
- spec/support/oauth2_response.rb
|
184
|
+
- spec/support/oauthable_object.rb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
module GoogleAPI
|
2
|
-
class Calendar < API
|
3
|
-
|
4
|
-
ENDPOINT = 'https://www.googleapis.com/calendar/v3'
|
5
|
-
|
6
|
-
# Fetch all calendars for a particular user, returning an array of calendar hashes.
|
7
|
-
def all
|
8
|
-
response = get('/users/me/calendarList')
|
9
|
-
response['items']
|
10
|
-
end
|
11
|
-
|
12
|
-
# Fetch a particular calendar based on the ID, returning a calendar hash.
|
13
|
-
def find(id)
|
14
|
-
get("/users/me/calendarList/#{id}")
|
15
|
-
end
|
16
|
-
|
17
|
-
# Delegates to #find, checking if the particular calendar exists.
|
18
|
-
def exists?(id)
|
19
|
-
find(id)['kind'].present?
|
20
|
-
end
|
21
|
-
|
22
|
-
# Create a calendar for a particular user, returning a calendar hash.
|
23
|
-
def create(calendar)
|
24
|
-
post('/calendars', body: calendar)
|
25
|
-
end
|
26
|
-
|
27
|
-
# Destroy a particular calendar based on the ID, returning true if successful.
|
28
|
-
def destroy(id)
|
29
|
-
delete("/calendars/#{id}")
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
def parse_calendar(response)
|
34
|
-
{
|
35
|
-
id: response['selfLink'],
|
36
|
-
title: response['title'],
|
37
|
-
updated_at: DateTime.parse(response['updated']),
|
38
|
-
details: response['details'],
|
39
|
-
eventFeed: response['eventFeedLink']
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
44
|
-
end
|
data/lib/google-api/api/drive.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
module GoogleAPI
|
2
|
-
class Drive < API
|
3
|
-
|
4
|
-
ENDPOINT = 'https://www.googleapis.com/drive/v2'
|
5
|
-
|
6
|
-
# Fetch all files and folders for a particular user, returning an array of file/folder hashes.
|
7
|
-
def all
|
8
|
-
response = get('/files')
|
9
|
-
response['items']
|
10
|
-
end
|
11
|
-
|
12
|
-
# Fetch a particular file/folder based on the ID, returning a file/folder hash.
|
13
|
-
def find(id)
|
14
|
-
get("/files/#{id}")
|
15
|
-
end
|
16
|
-
|
17
|
-
# Delegates to #find, checking if the particular file/folder exists.
|
18
|
-
def exists?(id)
|
19
|
-
find(id)['kind'].present?
|
20
|
-
end
|
21
|
-
|
22
|
-
# Create a file/folder for a particular user, returning a file/folder hash.
|
23
|
-
# When you want to upload a file, pass a secondary parameter with the path to the file.
|
24
|
-
def create(object, file_path = nil)
|
25
|
-
response = if file_path
|
26
|
-
# Upload a file
|
27
|
-
upload('/files', object, file_path)
|
28
|
-
else
|
29
|
-
# Create a folder
|
30
|
-
object[:mimeType] = 'application/vnd.google-apps.folder'
|
31
|
-
post('/files', body: object)
|
32
|
-
end
|
33
|
-
response
|
34
|
-
end
|
35
|
-
|
36
|
-
# Destroy a particular file/folder based on the ID, returning true if successful.
|
37
|
-
def destroy(id)
|
38
|
-
delete("/files/#{id}")
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
def parse_object(response)
|
43
|
-
{
|
44
|
-
id: response['selfLink'],
|
45
|
-
title: response['title'],
|
46
|
-
updated_at: DateTime.parse(response['updated']),
|
47
|
-
details: response['details'],
|
48
|
-
eventFeed: response['eventFeedLink']
|
49
|
-
}
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|