google-api-middle_man 0.1.5 → 0.2.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3cd49b7b4ca549fc5c73c150613690f7251dae90
4
- data.tar.gz: afe0469e7ddbbb58f869b5cc6573a9a332db22a5
3
+ metadata.gz: fed3737c50d22494dfd1aa3492cc033464d2bbc2
4
+ data.tar.gz: e5b62b7d06ba37da1676d1aad49abc34ed6d54c3
5
5
  SHA512:
6
- metadata.gz: a046c76856558e05f71a531e6e32106840fd0648414e41d489df85f4756b59c1a94de2eeeaa03aebd48e86692ea027c0f8c702584bca3e54b0877f5bda5c3fe7
7
- data.tar.gz: 60763a23c5b3c675f3455fbe78bf4d267900fbd84baccc03dbbf30264e1457f5f8862d5570dd39f805be0ea9500d8d782d8aa2191cefe4d8c56eb26d9f5a8d02
6
+ metadata.gz: 67d2132979d467647947622df9ea93e913a6f1ba26c234dbe14be35cd7046f0aa4bddf14d2fb6bcdba8a08be2b749af9d4e9bfec4cb7b2e36288b675d17f72aa
7
+ data.tar.gz: e4ae0af28ae423845c47dac3f2e6e13f0ce319a28ddf8d31091ac795d4b0fb8950572c736dd19bdeae2e07d13f7d208f651f2b750aca9d68c5512b1fc533ea3d
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in google-api-middle_man.gemspec
4
4
  gemspec
5
+
6
+ gem 'pry'
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
- #!/usr/bin/env ruby
22
+ #!/usr/bin/env ruby
23
23
 
24
- require 'google-api-middle_man'
24
+ require 'google-api-middle_man'
25
25
 
26
- email = "google_service_account@email"
27
- calendarId = "google_calendar_id"
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
- google_config = {
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
- agent = GoogleAPIMiddleMan::Agent.new(google_config)
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: "google_project_name",
6
+ application_name: "Google Project Name"
10
7
  key_location: 'client.p12',
11
- google_service_email: 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 'rspec'
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 = {'calendarId' => calendar_id}
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
 
@@ -1,3 +1,3 @@
1
1
  module GoogleTravelAgent
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -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 a scopes" do
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.5
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-19 00:00:00.000000000 Z
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.3
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