google-api-middle_man 0.1.5 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/README.md +10 -11
- data/examples/google_calendar_example.rb +9 -7
- data/google-api-middle_man.gemspec +4 -4
- data/lib/google-api-middle_man.rb +12 -1
- data/lib/google-api-middle_man/version.rb +1 -1
- data/spec/lib/google-api-middle_man_spec.rb +32 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fed3737c50d22494dfd1aa3492cc033464d2bbc2
|
4
|
+
data.tar.gz: e5b62b7d06ba37da1676d1aad49abc34ed6d54c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67d2132979d467647947622df9ea93e913a6f1ba26c234dbe14be35cd7046f0aa4bddf14d2fb6bcdba8a08be2b749af9d4e9bfec4cb7b2e36288b675d17f72aa
|
7
|
+
data.tar.gz: e4ae0af28ae423845c47dac3f2e6e13f0ce319a28ddf8d31091ac795d4b0fb8950572c736dd19bdeae2e07d13f7d208f651f2b750aca9d68c5512b1fc533ea3d
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -19,21 +19,20 @@ Or install it yourself as:
|
|
19
19
|
## Usage
|
20
20
|
Look under `examples`
|
21
21
|
```ruby
|
22
|
-
|
22
|
+
#!/usr/bin/env ruby
|
23
23
|
|
24
|
-
|
24
|
+
require 'google-api-middle_man'
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
google_config = {
|
27
|
+
application_name: "Google Project Name"
|
28
|
+
key_location: 'client.p12',
|
29
|
+
google_service_email: "google_service_account_email@developer.gserviceaccount.com"
|
30
|
+
}
|
31
|
+
calendar_id = "google_calendar_id@group.calendar.google.com"
|
28
32
|
|
29
|
-
|
30
|
-
application_name: "google_project_name",
|
31
|
-
key_location: 'client.p12',
|
32
|
-
google_service_email: email
|
33
|
-
}
|
33
|
+
agent = GoogleAPIMiddleMan::Agent.new(google_config)
|
34
34
|
|
35
|
-
|
36
|
-
agent.calendar_events(calendar_id)
|
35
|
+
events = agent.calendar_events(calendar_id)
|
37
36
|
```
|
38
37
|
|
39
38
|
## Contributing
|
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
require 'google-api-middle_man'
|
4
4
|
|
5
|
-
email = "google_service_account@email"
|
6
|
-
calendarId = "google_calendar_id"
|
7
|
-
|
8
5
|
google_config = {
|
9
|
-
application_name: "
|
6
|
+
application_name: "Google Project Name"
|
10
7
|
key_location: 'client.p12',
|
11
|
-
google_service_email:
|
8
|
+
google_service_email: "google_service_account_email@developer.gserviceaccount.com"
|
12
9
|
}
|
10
|
+
calendar_id = "google_calendar_id@group.calendar.google.com"
|
11
|
+
|
12
|
+
agent = GoogleAPIMiddleMan::Agent.new(google_config)
|
13
|
+
|
14
|
+
events = agent.calendar_events(calendar_id)
|
15
|
+
|
16
|
+
puts events.items.inspect
|
13
17
|
|
14
|
-
travel_agent = GoogleAPIMiddleMan::Agent.new(google_config)
|
15
|
-
travel_agent.calendar_events(calendar_id)
|
16
18
|
|
@@ -7,9 +7,9 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "google-api-middle_man"
|
8
8
|
spec.version = GoogleTravelAgent::VERSION
|
9
9
|
spec.authors = ["Shaun Dern"]
|
10
|
-
spec.email = ["shaun@substantial.com"]
|
11
|
-
spec.description = %q{Simplify the Google API}
|
12
|
-
spec.summary = %q{Simplify the Google API}
|
10
|
+
spec.email = ["shaun@substantial.com", "dempsey@substantial.com"]
|
11
|
+
spec.description = %q{Simplify the Google API using a service account}
|
12
|
+
spec.summary = %q{Simplify the Google API using a service account}
|
13
13
|
spec.homepage = "https://github.com/substantial/google-api-middle_man"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency
|
23
|
+
spec.add_development_dependency "rspec"
|
24
24
|
|
25
25
|
spec.add_dependency "google-api-client", "~> 0.6.3"
|
26
26
|
end
|
@@ -25,7 +25,8 @@ module GoogleAPIMiddleMan
|
|
25
25
|
def calendar_events(calendar_id)
|
26
26
|
@client.authorization = service_account.authorize
|
27
27
|
|
28
|
-
options =
|
28
|
+
options = events_list_options_hash.merge('calendarId' => calendar_id)
|
29
|
+
|
29
30
|
result = @client.execute(api_method: calendar_service.events.list, parameters: options)
|
30
31
|
|
31
32
|
result.data
|
@@ -59,6 +60,16 @@ module GoogleAPIMiddleMan
|
|
59
60
|
def calendar_service
|
60
61
|
@client.discovered_api('calendar', 'v3')
|
61
62
|
end
|
63
|
+
|
64
|
+
def events_list_options_hash
|
65
|
+
{
|
66
|
+
'singleEvents' => 'true',
|
67
|
+
'orderBy' => 'startTime',
|
68
|
+
'timeMax' => DateTime.now + 1,
|
69
|
+
'timeMin' => DateTime.now,
|
70
|
+
'fields' => 'description,items(colorId,created,creator(displayName,email),description,end,endTimeUnspecified,id,kind,location,start,status,summary),kind,summary,updated'
|
71
|
+
}
|
72
|
+
end
|
62
73
|
end
|
63
74
|
end
|
64
75
|
|
@@ -84,7 +84,7 @@ describe GoogleAPIMiddleMan::Agent do
|
|
84
84
|
travel_agent.send(:calendar_scope).should == calendar_scope
|
85
85
|
end
|
86
86
|
|
87
|
-
it "should have a have
|
87
|
+
it "should have a have scopes" do
|
88
88
|
travel_agent.send(:scopes).should == scopes
|
89
89
|
end
|
90
90
|
end
|
@@ -141,6 +141,37 @@ describe GoogleAPIMiddleMan::Agent do
|
|
141
141
|
travel_agent.send(:calendar_service)
|
142
142
|
end
|
143
143
|
end
|
144
|
+
|
145
|
+
describe "#events_list_options_hash" do
|
146
|
+
|
147
|
+
let(:options_hash) { travel_agent.send(:events_list_options_hash) }
|
148
|
+
let(:now) { DateTime.new(2010, 1, 1, 10, 0, 0) }
|
149
|
+
let(:tomorrow) { now + 1 }
|
150
|
+
|
151
|
+
before do
|
152
|
+
DateTime.stub(:now) { now }
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should only return single events and convert repeating to single" do
|
156
|
+
options_hash['singleEvents'].should == 'true'
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should order by start time" do
|
160
|
+
options_hash['orderBy'].should == 'startTime'
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should only return events that start a day from now" do
|
164
|
+
options_hash['timeMax'].should == tomorrow
|
165
|
+
end
|
166
|
+
|
167
|
+
it "should only return events that end after now" do
|
168
|
+
options_hash['timeMin'].should == now
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should only return the fields specified" do
|
172
|
+
options_hash['fields'].should == 'description,items(colorId,created,creator(displayName,email),description,end,endTimeUnspecified,id,kind,location,start,status,summary),kind,summary,updated'
|
173
|
+
end
|
174
|
+
end
|
144
175
|
end
|
145
176
|
|
146
177
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-api-middle_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shaun Dern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,9 +66,10 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.6.3
|
69
|
-
description: Simplify the Google API
|
69
|
+
description: Simplify the Google API using a service account
|
70
70
|
email:
|
71
71
|
- shaun@substantial.com
|
72
|
+
- dempsey@substantial.com
|
72
73
|
executables: []
|
73
74
|
extensions: []
|
74
75
|
extra_rdoc_files: []
|
@@ -106,10 +107,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
version: '0'
|
107
108
|
requirements: []
|
108
109
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.0.
|
110
|
+
rubygems_version: 2.0.5
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
|
-
summary: Simplify the Google API
|
113
|
+
summary: Simplify the Google API using a service account
|
113
114
|
test_files:
|
114
115
|
- spec/lib/google-api-middle_man_spec.rb
|
115
116
|
- spec/spec_helper.rb
|