google_calendar 0.6.4 → 0.7.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.
- checksums.yaml +5 -5
- data/.env.test +1 -1
- data/.github/workflows/ci.yml +27 -0
- data/Gemfile +1 -2
- data/Gemfile.lock +70 -44
- data/LICENSE.txt +1 -1
- data/README.rdoc +15 -12
- data/VERSION +1 -1
- data/google_calendar.gemspec +10 -7
- data/lib/google/calendar.rb +6 -6
- data/lib/google/calendar_list.rb +1 -1
- data/lib/google/connection.rb +7 -5
- data/lib/google/event.rb +4 -3
- data/lib/google/freebusy.rb +3 -4
- data/readme_code.rb +2 -2
- data/test/helper.rb +1 -1
- data/test/test_google_calendar.rb +132 -22
- metadata +63 -19
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: acefcd4148fb09fb9ae42a28e6e2ebe85507e3388cc9a83c9ae79ec36eaa9349
|
|
4
|
+
data.tar.gz: b4df360b6242f88fcbd9d85cf32200bd47561e3482a0fad413904fc421e6832c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7705625116e7cc2c86f74c88d22f714d210f6ba955eab9775520883ee9274b6d624e118cae0d1401775bc2b28b4d5ed2ee4842652afdd2eb5dc019b61e904e50
|
|
7
|
+
data.tar.gz: 99e7c4f88747a310a2cafebd561a521c432b10fe40b7ddc658d891297fe978ec15f9d4f6ffa01c0b379800983d11ffbda3474ace8aa40e2a2ba028459a08d64e
|
data/.env.test
CHANGED
|
@@ -3,4 +3,4 @@ CLIENT_SECRET='roBgdbfEmJwPgrgi2mRbbO-f'
|
|
|
3
3
|
REFRESH_TOKEN='1/eiqBWx8aj-BsdhwvlzDMFOUN1IN_HyThvYTujyksO4c'
|
|
4
4
|
CALENDAR_ID='klei8jnelo09nflqehnvfzipgs@group.calendar.google.com'
|
|
5
5
|
ACCESS_TOKEN='ya29.hYjPO0uHt63uWr5qmQtMEReZEvILcdGlPCOHDy6quKPyEQaQQvqaVAlLAVASaRm_O0a7vkZ91T8xyQ'
|
|
6
|
-
REDIRECT_URL='
|
|
6
|
+
REDIRECT_URL='https://mytesturl.com/'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
ruby-version:
|
|
16
|
+
- '3.2'
|
|
17
|
+
- '3.3'
|
|
18
|
+
- '3.4'
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
22
|
+
uses: ruby/setup-ruby@v1
|
|
23
|
+
with:
|
|
24
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
25
|
+
bundler-cache: true
|
|
26
|
+
- name: Run tests
|
|
27
|
+
run: bundle exec rake test
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,78 +1,104 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
google_calendar (0.
|
|
5
|
-
TimezoneParser (
|
|
4
|
+
google_calendar (0.7.0)
|
|
5
|
+
TimezoneParser (>= 0.3, < 1.1)
|
|
6
|
+
addressable (> 2.7.0)
|
|
6
7
|
json (>= 1.8.3)
|
|
7
8
|
signet (~> 0.7)
|
|
9
|
+
sorted_set (~> 1.0)
|
|
8
10
|
|
|
9
11
|
GEM
|
|
10
12
|
remote: https://rubygems.org/
|
|
11
13
|
specs:
|
|
12
|
-
TimezoneParser (0.
|
|
14
|
+
TimezoneParser (1.0.0)
|
|
13
15
|
insensitive_hash
|
|
16
|
+
sqlite3
|
|
14
17
|
tzinfo
|
|
15
|
-
addressable (2.
|
|
16
|
-
public_suffix (>= 2.0.2, <
|
|
18
|
+
addressable (2.9.0)
|
|
19
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
17
20
|
ansi (1.5.0)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
base64 (0.3.0)
|
|
22
|
+
builder (3.2.4)
|
|
23
|
+
concurrent-ruby (1.3.7)
|
|
21
24
|
docile (1.1.5)
|
|
22
|
-
dotenv (2.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
dotenv (2.7.6)
|
|
26
|
+
erb (6.0.4)
|
|
27
|
+
faraday (2.14.3)
|
|
28
|
+
faraday-net_http (>= 2.0, < 3.5)
|
|
29
|
+
json
|
|
30
|
+
logger
|
|
31
|
+
faraday-net_http (3.4.4)
|
|
32
|
+
net-http (~> 0.5)
|
|
25
33
|
insensitive_hash (0.3.3)
|
|
26
|
-
json (2.1
|
|
27
|
-
jwt (2.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
json (2.3.1)
|
|
35
|
+
jwt (3.2.0)
|
|
36
|
+
base64
|
|
37
|
+
logger (1.7.0)
|
|
38
|
+
mini_portile2 (2.8.9)
|
|
39
|
+
minitest (5.27.0)
|
|
40
|
+
minitest-reporters (1.4.2)
|
|
31
41
|
ansi
|
|
32
42
|
builder
|
|
33
43
|
minitest (>= 5.0)
|
|
34
44
|
ruby-progressbar
|
|
35
|
-
mocha (
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
mocha (2.8.2)
|
|
46
|
+
ruby2_keywords (>= 0.0.5)
|
|
47
|
+
net-http (0.9.1)
|
|
48
|
+
uri (>= 0.11.1)
|
|
49
|
+
prism (1.9.0)
|
|
50
|
+
public_suffix (7.0.5)
|
|
51
|
+
rake (13.0.1)
|
|
52
|
+
rb-fsevent (0.10.4)
|
|
53
|
+
rbs (4.0.3)
|
|
54
|
+
logger
|
|
55
|
+
prism (>= 1.6.0)
|
|
56
|
+
tsort
|
|
57
|
+
rbtree (0.4.7)
|
|
58
|
+
rdoc (8.0.0)
|
|
59
|
+
erb
|
|
60
|
+
prism (>= 1.6.0)
|
|
61
|
+
rbs (>= 4.0.0)
|
|
62
|
+
tsort
|
|
63
|
+
ruby-progressbar (1.10.1)
|
|
64
|
+
ruby2_keywords (0.0.5)
|
|
65
|
+
shoulda-context (2.0.0)
|
|
66
|
+
signet (0.22.0)
|
|
67
|
+
addressable (~> 2.8)
|
|
68
|
+
faraday (>= 0.17.5, < 3.a)
|
|
69
|
+
jwt (>= 1.5, < 4.0)
|
|
70
|
+
simplecov (0.22.0)
|
|
71
|
+
docile (~> 1.1)
|
|
72
|
+
simplecov-html (~> 0.11)
|
|
73
|
+
simplecov_json_formatter (~> 0.1)
|
|
74
|
+
simplecov-html (0.13.2)
|
|
75
|
+
simplecov_json_formatter (0.1.4)
|
|
76
|
+
sorted_set (1.1.0)
|
|
77
|
+
rbtree
|
|
78
|
+
sqlite3 (2.9.5)
|
|
79
|
+
mini_portile2 (~> 2.8.0)
|
|
55
80
|
terminal-notifier-guard (1.7.0)
|
|
56
|
-
|
|
57
|
-
tzinfo (
|
|
58
|
-
|
|
81
|
+
tsort (0.2.0)
|
|
82
|
+
tzinfo (2.0.2)
|
|
83
|
+
concurrent-ruby (~> 1.0)
|
|
84
|
+
uri (1.1.1)
|
|
59
85
|
|
|
60
86
|
PLATFORMS
|
|
61
87
|
ruby
|
|
62
88
|
|
|
63
89
|
DEPENDENCIES
|
|
64
90
|
bundler (>= 1.2)
|
|
65
|
-
codeclimate-test-reporter
|
|
66
91
|
dotenv (~> 2.1)
|
|
67
92
|
google_calendar!
|
|
68
93
|
minitest (~> 5.1)
|
|
69
94
|
minitest-reporters (~> 1.2)
|
|
70
|
-
mocha (~>
|
|
95
|
+
mocha (~> 2.0)
|
|
71
96
|
rake (>= 11)
|
|
72
97
|
rb-fsevent (~> 0.9)
|
|
73
|
-
rdoc (
|
|
74
|
-
shoulda-context (~>
|
|
98
|
+
rdoc (> 6.3.1)
|
|
99
|
+
shoulda-context (~> 2.0)
|
|
100
|
+
simplecov (~> 0.22)
|
|
75
101
|
terminal-notifier-guard (~> 1.6)
|
|
76
102
|
|
|
77
103
|
BUNDLED WITH
|
|
78
|
-
|
|
104
|
+
4.0.3
|
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
A fast lightweight and minimalist wrapper around the {Google Calendar}[https://www.google.com/calendar/] api.
|
|
4
4
|
|
|
5
|
-
{<img src="https://badge.fury.io/rb/google_calendar.svg" alt="Gem Version" />}[http://badge.fury.io/rb/google_calendar] {<img src="https://
|
|
5
|
+
{<img src="https://badge.fury.io/rb/google_calendar.svg" alt="Gem Version" />}[http://badge.fury.io/rb/google_calendar] {<img src="https://github.com/northworld/google_calendar/actions/workflows/ci.yml/badge.svg" alt="Build Status" />}[https://github.com/northworld/google_calendar/actions/workflows/ci.yml]
|
|
6
6
|
== Install
|
|
7
7
|
[sudo] gem install 'google_calendar'
|
|
8
8
|
|
|
9
9
|
== Setup
|
|
10
10
|
|
|
11
|
+
<b>Important Changes: Google no longer supports the 'urn:ietf:wg:oauth:2.0:oob' out-of-band OAuth method. You must setup your OAuth Credentials with a publically accessible URL where you can grab your code from the URL paramaters after approving the OAuth request. If your product is a Web Application, you can automate this set up by pointing the redirect_url to the appropriate method of your application.</b>
|
|
12
|
+
|
|
11
13
|
<b>Obtain a Client ID and Secret</b>
|
|
12
14
|
|
|
13
15
|
1. Go to the {Google Developers Console}[https://console.developers.google.com/].
|
|
@@ -16,19 +18,20 @@ A fast lightweight and minimalist wrapper around the {Google Calendar}[https://w
|
|
|
16
18
|
1. Type in 'Google Calendar' in the search box and click on 'Google Calendar API' in the results.
|
|
17
19
|
1. Click on the 'Enable' link at the top of the page.
|
|
18
20
|
1. In the sidebar on the left, select Credentials.
|
|
19
|
-
1. If you haven't done so already, create your 'OAuth client ID' by clicking Create Credentials
|
|
20
|
-
1.
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
1. If you haven't done so already, create your 'OAuth client ID' by clicking 'Create Credentials -> OAuth client ID'. Choose Web Application as the type.
|
|
22
|
+
1. You must also provide an "Authorized redirect URIs" which is a publically reachable URL where google will redirect to after the OAuth approval. Google will append the paramater 'code=<your auth code>' to this URL during redirection which will include the necessary code to authenticate the usage of this application.
|
|
23
|
+
1. <em>Take note of the Client ID and Client Secret as you'll need to add it to your code later.</em>
|
|
24
|
+
1. In the sidebar on the left, select "OAuth consent screen". You must setup your Application Name, and add "Test users" if this is for personal use (i.e. you are setting up links to at limited set of known users' calendars), or "Publish" your app if this is for public use.
|
|
23
25
|
|
|
24
26
|
<b>Find your calendar ID</b>
|
|
25
27
|
|
|
26
28
|
1. Visit {Google Calendar}[https://www.google.com/calendar/] in your web browser.
|
|
27
|
-
1. In the calendar list on the left, click the
|
|
28
|
-
1.
|
|
29
|
+
1. In the calendar list on the left, click the three vertical dots next to the appropriate calendar, then select 'Settings and sharing'.
|
|
30
|
+
1. From the left toolbar, choose 'Integrate Calendar'.
|
|
31
|
+
1. In the Integrate Calendar section, locate the Calendar ID at the top of the section.
|
|
29
32
|
1. Copy the Calendar ID.
|
|
30
33
|
|
|
31
|
-
== Usage
|
|
34
|
+
== Usage (readme_code.rb)
|
|
32
35
|
require 'rubygems'
|
|
33
36
|
require 'google_calendar'
|
|
34
37
|
|
|
@@ -36,7 +39,7 @@ A fast lightweight and minimalist wrapper around the {Google Calendar}[https://w
|
|
|
36
39
|
cal = Google::Calendar.new(:client_id => YOUR_CLIENT_ID,
|
|
37
40
|
:client_secret => YOUR_SECRET,
|
|
38
41
|
:calendar => YOUR_CALENDAR_ID,
|
|
39
|
-
:redirect_url =>
|
|
42
|
+
:redirect_url => YOUR_REDIRECT_URL # This must match a url you permitted in your OAuth setting
|
|
40
43
|
)
|
|
41
44
|
|
|
42
45
|
puts "Do you already have a refresh token? (y/n)"
|
|
@@ -47,7 +50,7 @@ A fast lightweight and minimalist wrapper around the {Google Calendar}[https://w
|
|
|
47
50
|
# A user needs to approve access in order to work with their calendars.
|
|
48
51
|
puts "Visit the following web page in your browser and approve access."
|
|
49
52
|
puts cal.authorize_url
|
|
50
|
-
puts "\nCopy the code
|
|
53
|
+
puts "\nCopy the code out of the paramters after Google redirects you to your provided redirect_url"
|
|
51
54
|
|
|
52
55
|
# Pass the ONE TIME USE access code here to login and get a refresh token that you can use for access from now on.
|
|
53
56
|
refresh_token = cal.login_with_auth_code( $stdin.gets.chomp )
|
|
@@ -91,7 +94,7 @@ A fast lightweight and minimalist wrapper around the {Google Calendar}[https://w
|
|
|
91
94
|
This sample code is located in readme_code.rb in the root folder.
|
|
92
95
|
|
|
93
96
|
== Ruby Support
|
|
94
|
-
The current google_calendar gem supports Ruby 2
|
|
97
|
+
The current google_calendar gem supports Ruby 3.2 and higher -- the +signet+ OAuth2 dependency requires it. Older Ruby versions (1.8.7 through 2.7) are maintained on different branches.
|
|
95
98
|
|
|
96
99
|
== Notes
|
|
97
100
|
* This is not a complete implementation of the calendar api, it just includes the features we needed to support our internal calendar integration. Feel free to add additional features and we will happily integrate them.
|
|
@@ -118,4 +121,4 @@ accidentally committing to the repo as +.env+ is in the +.gitignore+.
|
|
|
118
121
|
|
|
119
122
|
== Copyright
|
|
120
123
|
|
|
121
|
-
Copyright (c) 2010-
|
|
124
|
+
Copyright (c) 2010-2022 Northworld, LLC. See LICENSE.txt for further details.
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.7.0
|
data/google_calendar.gemspec
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = "google_calendar"
|
|
5
|
-
s.version = "0.
|
|
6
|
-
s.date = "
|
|
5
|
+
s.version = "0.7.0"
|
|
6
|
+
s.date = "2026-07-07"
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
9
|
+
s.required_ruby_version = ">= 3.2"
|
|
9
10
|
|
|
10
11
|
s.authors = ["Steve Zich"]
|
|
11
12
|
s.email = "steve.zich@gmail.com"
|
|
@@ -24,21 +25,23 @@ Gem::Specification.new do |s|
|
|
|
24
25
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
25
26
|
|
|
26
27
|
s.require_paths = ["lib"]
|
|
27
|
-
s.rubygems_version = "2.6.14"
|
|
28
28
|
|
|
29
|
+
s.add_runtime_dependency(%q<addressable>, ["> 2.7.0"])
|
|
29
30
|
s.add_runtime_dependency(%q<signet>, ["~> 0.7"])
|
|
30
31
|
s.add_runtime_dependency(%q<json>, [">= 1.8.3"])
|
|
31
|
-
s.add_runtime_dependency(%q<TimezoneParser>,
|
|
32
|
+
s.add_runtime_dependency(%q<TimezoneParser>, ">= 0.3", "< 1.1")
|
|
33
|
+
s.add_runtime_dependency(%q<sorted_set>, ["~> 1.0"])
|
|
32
34
|
|
|
33
35
|
s.add_development_dependency(%q<terminal-notifier-guard>, ["~> 1.6"])
|
|
34
36
|
s.add_development_dependency(%q<rb-fsevent>, ["~> 0.9"])
|
|
35
37
|
s.add_development_dependency(%q<minitest>, ["~> 5.1"])
|
|
36
38
|
s.add_development_dependency(%q<minitest-reporters>, ["~> 1.2"])
|
|
37
|
-
s.add_development_dependency(%q<shoulda-context>,
|
|
39
|
+
s.add_development_dependency(%q<shoulda-context>, "~> 2.0")
|
|
38
40
|
s.add_development_dependency(%q<bundler>, [">= 1.2"])
|
|
39
|
-
s.add_development_dependency(%q<mocha>, ["~>
|
|
41
|
+
s.add_development_dependency(%q<mocha>, ["~> 2.0"])
|
|
40
42
|
s.add_development_dependency(%q<rake>, [">= 11"])
|
|
41
|
-
s.add_development_dependency(%q<rdoc>, ["
|
|
43
|
+
s.add_development_dependency(%q<rdoc>, ["> 6.3.1"])
|
|
42
44
|
s.add_development_dependency(%q<dotenv>, ["~> 2.1"])
|
|
45
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.22"])
|
|
43
46
|
|
|
44
47
|
end
|
data/lib/google/calendar.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Google
|
|
|
13
13
|
# the +params+ paramater accepts
|
|
14
14
|
# * :client_id => the client ID that you received from Google after registering your application with them (https://console.developers.google.com/). REQUIRED
|
|
15
15
|
# * :client_secret => the client secret you received from Google after registering your application with them. REQUIRED
|
|
16
|
-
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars.
|
|
16
|
+
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars. REQUIRED
|
|
17
17
|
# * :calendar => the id of the calendar you would like to work with (see Readme.rdoc for instructions on how to find yours). REQUIRED
|
|
18
18
|
# * :refresh_token => if a user has already given you access to their calendars, you can specify their refresh token here and you will be 'logged on' automatically (i.e. they don't need to authorize access again). OPTIONAL
|
|
19
19
|
#
|
|
@@ -23,7 +23,7 @@ module Google
|
|
|
23
23
|
# Google::Calendar.new(:client_id => YOUR_CLIENT_ID,
|
|
24
24
|
# :client_secret => YOUR_SECRET,
|
|
25
25
|
# :calendar => YOUR_CALENDAR_ID,
|
|
26
|
-
# :redirect_url => "
|
|
26
|
+
# :redirect_url => "http://myapplicationurl.com/"
|
|
27
27
|
# )
|
|
28
28
|
#
|
|
29
29
|
def initialize(params={}, connection=nil)
|
|
@@ -36,7 +36,7 @@ module Google
|
|
|
36
36
|
# the +params+ paramater accepts
|
|
37
37
|
# * :client_id => the client ID that you received from Google after registering your application with them (https://console.developers.google.com/). REQUIRED
|
|
38
38
|
# * :client_secret => the client secret you received from Google after registering your application with them. REQUIRED
|
|
39
|
-
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars.
|
|
39
|
+
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars. REQUIRED
|
|
40
40
|
# * :summary => title of the calendar being created. OPTIONAL
|
|
41
41
|
# * :location => geographic location of the calendar as free-form text. OPTIONAL
|
|
42
42
|
# * :time_zone => the time zone of the calendar. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) OPTIONAL
|
|
@@ -53,7 +53,7 @@ module Google
|
|
|
53
53
|
# :location => 'Somewhere',
|
|
54
54
|
# :description => 'Test Calendar Description',
|
|
55
55
|
# :time_zone => 'Europe/Zurich',
|
|
56
|
-
# :redirect_url => "
|
|
56
|
+
# :redirect_url => "http://myapplicationurl.com/"
|
|
57
57
|
# )
|
|
58
58
|
#
|
|
59
59
|
def self.create(params={}, connection=nil)
|
|
@@ -71,7 +71,7 @@ module Google
|
|
|
71
71
|
# the +params+ paramater accepts
|
|
72
72
|
# * :client_id => the client ID that you received from Google after registering your application with them (https://console.developers.google.com/). REQUIRED
|
|
73
73
|
# * :client_secret => the client secret you received from Google after registering your application with them. REQUIRED
|
|
74
|
-
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars.
|
|
74
|
+
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars. REQUIRED
|
|
75
75
|
# * :calendar => the id of the calendar you would like to work with (see Readme.rdoc for instructions on how to find yours). REQUIRED
|
|
76
76
|
# * :refresh_token => if a user has already given you access to their calendars, you can specify their refresh token here and you will be 'logged on' automatically (i.e. they don't need to authorize access again). OPTIONAL
|
|
77
77
|
#
|
|
@@ -82,7 +82,7 @@ module Google
|
|
|
82
82
|
# :client_id => YOUR_CLIENT_ID,
|
|
83
83
|
# :client_secret => YOUR_SECRET,
|
|
84
84
|
# :calendar => YOUR_CALENDAR_ID,
|
|
85
|
-
# :redirect_url => "
|
|
85
|
+
# :redirect_url => "http://myapplicationurl.com/"
|
|
86
86
|
# )
|
|
87
87
|
#
|
|
88
88
|
def self.get(params={}, connection=nil)
|
data/lib/google/calendar_list.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Google
|
|
|
13
13
|
# The +params+ parameter accepts
|
|
14
14
|
# * :client_id => the client ID that you received from Google after registering your application with them (https://console.developers.google.com/). REQUIRED
|
|
15
15
|
# * :client_secret => the client secret you received from Google after registering your application with them. REQUIRED
|
|
16
|
-
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars.
|
|
16
|
+
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars. REQUIRED
|
|
17
17
|
# * :refresh_token => if a user has already given you access to their calendars, you can specify their refresh token here and you will be 'logged on' automatically (i.e. they don't need to authorize access again). OPTIONAL
|
|
18
18
|
#
|
|
19
19
|
# See Readme.rdoc or readme_code.rb for an explication on the OAuth2 authorization process.
|
data/lib/google/connection.rb
CHANGED
|
@@ -9,12 +9,13 @@ module Google
|
|
|
9
9
|
BASE_URI = "https://www.googleapis.com/calendar/v3"
|
|
10
10
|
TOKEN_URI ="https://accounts.google.com/o/oauth2/token"
|
|
11
11
|
AUTH_URI = "https://accounts.google.com/o/oauth2/auth"
|
|
12
|
-
|
|
12
|
+
DEFAULT_SCOPE = "https://www.googleapis.com/auth/calendar"
|
|
13
|
+
|
|
13
14
|
attr_accessor :client
|
|
14
15
|
|
|
15
16
|
def self.new_with_service_account(params)
|
|
16
17
|
client = Signet::OAuth2::Client.new(
|
|
17
|
-
:scope =>
|
|
18
|
+
:scope => params.fetch(:scope, DEFAULT_SCOPE),
|
|
18
19
|
:issuer => params[:client_id],
|
|
19
20
|
:audience => TOKEN_URI,
|
|
20
21
|
:token_credential_uri => TOKEN_URI,
|
|
@@ -43,8 +44,9 @@ module Google
|
|
|
43
44
|
# the +params+ paramater accepts
|
|
44
45
|
# * :client_id => the client ID that you received from Google after registering your application with them (https://console.developers.google.com/)
|
|
45
46
|
# * :client_secret => the client secret you received from Google after registering your application with them.
|
|
46
|
-
# * :redirect_uri => the url where your users will be redirected to after they have successfully permitted access to their calendars.
|
|
47
|
+
# * :redirect_uri => the url where your users will be redirected to after they have successfully permitted access to their calendars."
|
|
47
48
|
# * :refresh_token => if a user has already given you access to their calendars, you can specify their refresh token here and you will be 'logged on' automatically (i.e. they don't need to authorize access again)
|
|
49
|
+
# * :scope => Optional. The scope of the access request, expressed either as an Array or as a space-delimited String.
|
|
48
50
|
#
|
|
49
51
|
def initialize(params, client=nil)
|
|
50
52
|
|
|
@@ -58,7 +60,7 @@ module Google
|
|
|
58
60
|
:state => params[:state],
|
|
59
61
|
:authorization_uri => AUTH_URI,
|
|
60
62
|
:token_credential_uri => TOKEN_URI,
|
|
61
|
-
:scope =>
|
|
63
|
+
:scope => params.fetch(:scope, DEFAULT_SCOPE)
|
|
62
64
|
)
|
|
63
65
|
|
|
64
66
|
# try to get an access token if possible.
|
|
@@ -178,7 +180,7 @@ module Google
|
|
|
178
180
|
when "Rate Limit Exceeded" then raise RateLimitExceededError, response.body
|
|
179
181
|
when "Calendar usage limits exceeded." then raise CalendarUsageLimitExceededError, response.body
|
|
180
182
|
else raise ForbiddenError, response.body
|
|
181
|
-
end
|
|
183
|
+
end
|
|
182
184
|
end
|
|
183
185
|
|
|
184
186
|
#
|
data/lib/google/event.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'time'
|
|
2
2
|
require 'json'
|
|
3
|
+
require 'sorted_set' # TimezoneParser relies on the top-level SortedSet, removed from stdlib in Ruby 3.2+
|
|
3
4
|
require 'timezone_parser'
|
|
4
5
|
|
|
5
6
|
module Google
|
|
@@ -216,10 +217,10 @@ module Google
|
|
|
216
217
|
# You can pass true or false. Defaults to transparent.
|
|
217
218
|
#
|
|
218
219
|
def transparency=(val)
|
|
219
|
-
if val ==
|
|
220
|
-
@transparency = 'opaque'
|
|
221
|
-
else
|
|
220
|
+
if val == true || val.to_s.downcase == 'transparent'
|
|
222
221
|
@transparency = 'transparent'
|
|
222
|
+
else
|
|
223
|
+
@transparency = 'opaque'
|
|
223
224
|
end
|
|
224
225
|
end
|
|
225
226
|
|
data/lib/google/freebusy.rb
CHANGED
|
@@ -16,7 +16,7 @@ module Google
|
|
|
16
16
|
# The +params+ parameter accepts
|
|
17
17
|
# * :client_id => the client ID that you received from Google after registering your application with them (https://console.developers.google.com/). REQUIRED
|
|
18
18
|
# * :client_secret => the client secret you received from Google after registering your application with them. REQUIRED
|
|
19
|
-
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars.
|
|
19
|
+
# * :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars. REQUIRED
|
|
20
20
|
# * :refresh_token => if a user has already given you access to their calendars, you can specify their refresh token here and you will be 'logged on' automatically (i.e. they don't need to authorize access again). OPTIONAL
|
|
21
21
|
#
|
|
22
22
|
# See Readme.rdoc or readme_code.rb for an explication on the OAuth2 authorization process.
|
|
@@ -46,7 +46,7 @@ module Google
|
|
|
46
46
|
private
|
|
47
47
|
|
|
48
48
|
#
|
|
49
|
-
# Prepare the JSON
|
|
49
|
+
# Prepare the JSON
|
|
50
50
|
#
|
|
51
51
|
def json_for_query(calendar_ids, start_time, end_time)
|
|
52
52
|
{}.tap{ |obj|
|
|
@@ -62,10 +62,9 @@ module Google
|
|
|
62
62
|
return nil unless query_result['calendars'].is_a? Hash
|
|
63
63
|
|
|
64
64
|
query_result['calendars'].each_with_object({}) do |(calendar_id, value), result|
|
|
65
|
+
value['busy'].each { |date_times| date_times.transform_values! { |date_time| DateTime.parse(date_time) } }
|
|
65
66
|
result[calendar_id] = value['busy'] || []
|
|
66
67
|
end
|
|
67
68
|
end
|
|
68
|
-
|
|
69
69
|
end
|
|
70
|
-
|
|
71
70
|
end
|
data/readme_code.rb
CHANGED
|
@@ -12,7 +12,7 @@ require 'google_calendar'
|
|
|
12
12
|
cal = Google::Calendar.new(:client_id => YOUR_CLIENT_ID,
|
|
13
13
|
:client_secret => YOUR_SECRET,
|
|
14
14
|
:calendar => YOUR_CALENDAR_ID,
|
|
15
|
-
:redirect_url =>
|
|
15
|
+
:redirect_url => YOUR_REDIRECT_URL # this is what Google uses for 'applications'
|
|
16
16
|
)
|
|
17
17
|
|
|
18
18
|
puts "Do you already have a refresh token? (y/n)"
|
|
@@ -23,7 +23,7 @@ if has_token.downcase != 'y'
|
|
|
23
23
|
# A user needs to approve access in order to work with their calendars.
|
|
24
24
|
puts "Visit the following web page in your browser and approve access."
|
|
25
25
|
puts cal.authorize_url
|
|
26
|
-
puts "\nCopy the code
|
|
26
|
+
puts "\nCopy the code out of the paramters after Google redirects you to your provided redirect_url"
|
|
27
27
|
|
|
28
28
|
# Pass the ONE TIME USE access code here to login and get a refresh token that you can use for access from now on.
|
|
29
29
|
refresh_token = cal.login_with_auth_code( $stdin.gets.chomp )
|
data/test/helper.rb
CHANGED
|
@@ -13,16 +13,16 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
13
13
|
@refresh_token = ENV['REFRESH_TOKEN']
|
|
14
14
|
@calendar_id = ENV['CALENDAR_ID']
|
|
15
15
|
@access_token = ENV['ACCESS_TOKEN']
|
|
16
|
-
@redirect_url =
|
|
16
|
+
@redirect_url = ENV['REDIRECT_URL']
|
|
17
17
|
|
|
18
|
-
@calendar = Calendar.new(:client_id => @client_id, :client_secret => @client_secret, :redirect_url =>
|
|
18
|
+
@calendar = Calendar.new(:client_id => @client_id, :client_secret => @client_secret, :redirect_url => @redirect_url, :refresh_token => @refresh_token, :calendar => @calendar_id)
|
|
19
19
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
context "a calendar" do
|
|
23
23
|
|
|
24
24
|
should "generate auth url" do
|
|
25
|
-
assert_equal @calendar.authorize_url.to_s, 'https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=671053090364-ntifn8rauvhib9h3vnsegi6dhfglk9ue.apps.googleusercontent.com&redirect_uri=
|
|
25
|
+
assert_equal @calendar.authorize_url.to_s, 'https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=671053090364-ntifn8rauvhib9h3vnsegi6dhfglk9ue.apps.googleusercontent.com&redirect_uri=https://mytesturl.com/&response_type=code&scope=https://www.googleapis.com/auth/calendar'
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
should "login with auth code" do
|
|
@@ -42,14 +42,14 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
should "login with get method" do
|
|
45
|
-
cal = Calendar.get(:client_id => @client_id, :client_secret => @client_secret, :redirect_url => @redirect_url,
|
|
45
|
+
cal = Calendar.get(:client_id => @client_id, :client_secret => @client_secret, :redirect_url => @redirect_url,
|
|
46
46
|
:calendar => @calendar_id, :refresh_token => @refresh_token)
|
|
47
47
|
@client_mock.stubs(:body).returns( get_mock_body("get_calendar.json") )
|
|
48
48
|
assert_equal cal.id, @calendar_id
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
should "update calendar" do
|
|
52
|
-
cal = Calendar.get(:client_id => @client_id, :client_secret => @client_secret, :redirect_url => @redirect_url,
|
|
52
|
+
cal = Calendar.get(:client_id => @client_id, :client_secret => @client_secret, :redirect_url => @redirect_url,
|
|
53
53
|
:calendar => @calendar_id, :refresh_token => @refresh_token)
|
|
54
54
|
@client_mock.stubs(:body).returns( get_mock_body("update_calendar.json") )
|
|
55
55
|
cal.update(:summary => 'Our Company', :description => "Work event list")
|
|
@@ -57,16 +57,24 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
should "create calendar" do
|
|
60
|
-
cal = Calendar.create(:client_id => @client_id, :client_secret => @client_secret, :redirect_url => @redirect_url,
|
|
61
|
-
:refresh_token => @refresh_token, :summary => 'A New Calendar', :description => 'Our new calendar')
|
|
60
|
+
cal = Calendar.create(:client_id => @client_id, :client_secret => @client_secret, :redirect_url => @redirect_url,
|
|
61
|
+
:refresh_token => @refresh_token, :summary => 'A New Calendar', :description => 'Our new calendar')
|
|
62
62
|
assert_equal cal.summary, 'A New Calendar'
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
should "destroy a calendar" do
|
|
66
|
+
reusable_connection = mock('Google::Connection')
|
|
67
|
+
reusable_connection.expects(:send).with("/calendars/#{@calendar_id}", :delete, '').returns(@client_mock)
|
|
68
|
+
|
|
69
|
+
calendar = Calendar.new({:calendar => @calendar_id}, reusable_connection)
|
|
70
|
+
calendar.destroy
|
|
71
|
+
end
|
|
72
|
+
|
|
65
73
|
should "catch login with invalid credentials" do
|
|
66
74
|
@client_mock.stubs(:status).returns(403)
|
|
67
75
|
@client_mock.stubs(:body).returns( get_mock_body("403.json") )
|
|
68
76
|
assert_raises(HTTPAuthorizationFailed) do
|
|
69
|
-
Calendar.new(:client_id => 'abadid', :client_secret => 'abadsecret', :redirect_url => @redirect_url,
|
|
77
|
+
Calendar.new(:client_id => 'abadid', :client_secret => 'abadsecret', :redirect_url => @redirect_url,
|
|
70
78
|
:refresh_token => @refresh_token, :calendar => @calendar_id)
|
|
71
79
|
end
|
|
72
80
|
end
|
|
@@ -86,7 +94,7 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
86
94
|
|
|
87
95
|
calendar = Calendar.new({:calendar => @calendar_id}, reusable_connection)
|
|
88
96
|
calendar.events
|
|
89
|
-
end
|
|
97
|
+
end
|
|
90
98
|
|
|
91
99
|
should "throw ForbiddenError if not logged in" do
|
|
92
100
|
@client_mock.stubs(:status).returns(403)
|
|
@@ -95,7 +103,7 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
95
103
|
assert_raises(ForbiddenError) do
|
|
96
104
|
@calendar.find_event_by_id('1234')
|
|
97
105
|
end
|
|
98
|
-
end
|
|
106
|
+
end
|
|
99
107
|
|
|
100
108
|
should "throw ForbiddenError if unknown 403 response" do
|
|
101
109
|
@client_mock.stubs(:status).returns(403)
|
|
@@ -104,7 +112,7 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
104
112
|
assert_raises(ForbiddenError) do
|
|
105
113
|
@calendar.find_event_by_id('1234')
|
|
106
114
|
end
|
|
107
|
-
end
|
|
115
|
+
end
|
|
108
116
|
|
|
109
117
|
end # login context
|
|
110
118
|
|
|
@@ -210,7 +218,7 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
210
218
|
e.description = "A new event with &"
|
|
211
219
|
e.location = "Joe's House & Backyard"
|
|
212
220
|
end
|
|
213
|
-
end
|
|
221
|
+
end
|
|
214
222
|
end
|
|
215
223
|
|
|
216
224
|
should "throw DailyLimitExceededError when limit exceeded" do
|
|
@@ -220,7 +228,7 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
220
228
|
assert_raises(DailyLimitExceededError) do
|
|
221
229
|
@calendar.find_event_by_id('1234')
|
|
222
230
|
end
|
|
223
|
-
end
|
|
231
|
+
end
|
|
224
232
|
|
|
225
233
|
should "throw RateLimitExceededError when rate limit exceeded" do
|
|
226
234
|
@client_mock.stubs(:status).returns(403)
|
|
@@ -229,7 +237,7 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
229
237
|
assert_raises(RateLimitExceededError) do
|
|
230
238
|
@calendar.find_event_by_id('1234')
|
|
231
239
|
end
|
|
232
|
-
end
|
|
240
|
+
end
|
|
233
241
|
|
|
234
242
|
should "throw UserRateLimitExceededError when user rate limit exceeded" do
|
|
235
243
|
@client_mock.stubs(:status).returns(403)
|
|
@@ -399,6 +407,17 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
399
407
|
assert_equal event.title, 'New Event Update when id is nil'
|
|
400
408
|
end
|
|
401
409
|
|
|
410
|
+
should "create an event with a specified id when none is found on the server" do
|
|
411
|
+
@client_mock.stubs(:body).returns( get_mock_body("empty_events.json") )
|
|
412
|
+
|
|
413
|
+
event = @calendar.find_or_create_event_by_id('fhru34kt6ikmr20knd2456l08n') do |e|
|
|
414
|
+
e.title = 'New Event With Predefined Id'
|
|
415
|
+
end
|
|
416
|
+
|
|
417
|
+
assert_equal event.title, 'New Event With Predefined Id'
|
|
418
|
+
assert_equal event.id, 'fhru34kt6ikmr20knd2456l08n'
|
|
419
|
+
end
|
|
420
|
+
|
|
402
421
|
should "provide the calendar summary" do
|
|
403
422
|
@client_mock.stubs(:body).returns( get_mock_body("events.json") )
|
|
404
423
|
@calendar.events
|
|
@@ -502,15 +521,30 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
502
521
|
end
|
|
503
522
|
|
|
504
523
|
context "transparency" do
|
|
505
|
-
should "be
|
|
506
|
-
@event = Event.new
|
|
507
|
-
assert @event.
|
|
524
|
+
should "be opaque when nil" do
|
|
525
|
+
@event = Event.new
|
|
526
|
+
assert @event.opaque?
|
|
527
|
+
end
|
|
528
|
+
|
|
529
|
+
should "be opaque when transparency = opaque" do
|
|
530
|
+
@event = Event.new(:transparency => 'opaque')
|
|
531
|
+
assert @event.opaque?
|
|
508
532
|
end
|
|
509
533
|
|
|
510
534
|
should "be opaque?" do
|
|
511
535
|
@event = Event.new(:transparency => false)
|
|
512
536
|
assert @event.opaque?
|
|
513
537
|
end
|
|
538
|
+
|
|
539
|
+
should "be transparent" do
|
|
540
|
+
@event = Event.new(:transparency => true)
|
|
541
|
+
assert @event.transparent?
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
should "be transparent when transparency = transparent" do
|
|
545
|
+
@event = Event.new(:transparency => 'transparent')
|
|
546
|
+
assert @event.transparent?
|
|
547
|
+
end
|
|
514
548
|
end
|
|
515
549
|
|
|
516
550
|
context "event json" do
|
|
@@ -640,6 +674,67 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
640
674
|
assert_equal correct_hash.inspect, Event.parse_recurrence_rule(rrule).inspect
|
|
641
675
|
end
|
|
642
676
|
end
|
|
677
|
+
|
|
678
|
+
context "visibility" do
|
|
679
|
+
should "default to 'default' when not specified" do
|
|
680
|
+
assert_equal Event.new.visibility, "default"
|
|
681
|
+
end
|
|
682
|
+
|
|
683
|
+
should "accept a valid visibility" do
|
|
684
|
+
assert_equal Event.new(:visibility => "private").visibility, "private"
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
should "raise an error on an invalid visibility" do
|
|
688
|
+
assert_raises(ArgumentError) { Event.new(:visibility => "bogus") }
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
context "default hashes" do
|
|
693
|
+
should "return an empty hash for recurrence when unset" do
|
|
694
|
+
assert_equal Event.new.recurrence, {}
|
|
695
|
+
end
|
|
696
|
+
|
|
697
|
+
should "return an empty hash for extended_properties when unset" do
|
|
698
|
+
assert_equal Event.new.extended_properties, {}
|
|
699
|
+
end
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
context "attribute JSON helpers" do
|
|
703
|
+
setup do
|
|
704
|
+
@event = Event.new(
|
|
705
|
+
:color_id => 5,
|
|
706
|
+
:attendees => [{'email' => 'a@example.com', 'displayName' => 'A', 'responseStatus' => 'accepted'}],
|
|
707
|
+
:reminders => { 'useDefault' => false, 'overrides' => [{'minutes' => 10, 'method' => 'popup'}] },
|
|
708
|
+
:recurrence => { freq: 'weekly' },
|
|
709
|
+
:extended_properties => { 'shared' => { 'key' => 'value' } }
|
|
710
|
+
)
|
|
711
|
+
end
|
|
712
|
+
|
|
713
|
+
should "expose colorId as a hash and as json" do
|
|
714
|
+
assert_equal @event.color_attributes, { "colorId" => "5" }
|
|
715
|
+
assert_equal JSON.parse(@event.color_json), { "colorId" => "5" }
|
|
716
|
+
end
|
|
717
|
+
|
|
718
|
+
should "expose attendees as json" do
|
|
719
|
+
assert_equal JSON.parse(@event.attendees_json)["attendees"].first["email"], 'a@example.com'
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
should "expose reminders as json" do
|
|
723
|
+
assert_equal JSON.parse(@event.reminders_json)["useDefault"], false
|
|
724
|
+
end
|
|
725
|
+
|
|
726
|
+
should "expose recurrence as json" do
|
|
727
|
+
assert_equal JSON.parse(@event.recurrence_json)["recurrence"], ["RRULE:FREQ=WEEKLY"]
|
|
728
|
+
end
|
|
729
|
+
|
|
730
|
+
should "expose extended properties as json" do
|
|
731
|
+
assert_equal JSON.parse(@event.extended_properties_json)["extendedProperties"]["shared"]["key"], 'value'
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
should "expose the local timezone as json" do
|
|
735
|
+
assert_equal JSON.parse(@event.local_timezone_json)["timeZone"], TimezoneParser::getTimezones(Time.now.getlocal.zone).last
|
|
736
|
+
end
|
|
737
|
+
end
|
|
643
738
|
end
|
|
644
739
|
|
|
645
740
|
context "a calendar list" do
|
|
@@ -650,7 +745,7 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
650
745
|
@client_id = "671053090364-ntifn8rauvhib9h3vnsegi6dhfglk9ue.apps.googleusercontent.com"
|
|
651
746
|
@client_secret = "roBgdbfEmJwPgrgi2mRbbO-f"
|
|
652
747
|
@refresh_token = "1/eiqBWx8aj-BsdhwvlzDMFOUN1IN_HyThvYTujyksO4c"
|
|
653
|
-
@redirect_url = "
|
|
748
|
+
@redirect_url = "https://mytesturl.com/"
|
|
654
749
|
|
|
655
750
|
@calendar_list = Google::CalendarList.new(
|
|
656
751
|
:client_id => @client_id,
|
|
@@ -698,14 +793,13 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
698
793
|
end
|
|
699
794
|
|
|
700
795
|
context "a freebusy query" do
|
|
701
|
-
|
|
702
796
|
setup do
|
|
703
797
|
@client_mock = setup_mock_client
|
|
704
798
|
|
|
705
799
|
@client_id = "671053090364-ntifn8rauvhib9h3vnsegi6dhfglk9ue.apps.googleusercontent.com"
|
|
706
800
|
@client_secret = "roBgdbfEmJwPgrgi2mRbbO-f"
|
|
707
801
|
@refresh_token = "1/eiqBWx8aj-BsdhwvlzDMFOUN1IN_HyThvYTujyksO4c"
|
|
708
|
-
@redirect_url = "
|
|
802
|
+
@redirect_url = "https://mytesturl.com/"
|
|
709
803
|
|
|
710
804
|
@freebusy = Google::Freebusy.new(
|
|
711
805
|
:client_id => @client_id,
|
|
@@ -728,12 +822,28 @@ class TestGoogleCalendar < Minitest::Test
|
|
|
728
822
|
should "returns the busy times for each calendar supplied" do
|
|
729
823
|
freebusy_result = @freebusy.query(@calendar_ids, @start_time, @end_time)
|
|
730
824
|
|
|
731
|
-
assert_equal ({'start' =>
|
|
732
|
-
assert_equal ({'start' =>
|
|
825
|
+
assert_equal ({'start' => DateTime.new(2015, 3, 6, 10, 0, 0, 0), 'end' => DateTime.new(2015, 3, 6, 11, 0, 0, 0) }), freebusy_result['busy-calendar-id'].first
|
|
826
|
+
assert_equal ({'start' => DateTime.new(2015, 3, 6, 11, 30, 0, 0), 'end' => DateTime.new(2015, 3, 6, 11, 30, 0, 0) }), freebusy_result['busy-calendar-id'].last
|
|
733
827
|
assert_equal [], freebusy_result['not-busy-calendar-id']
|
|
734
828
|
end
|
|
735
829
|
end
|
|
736
830
|
|
|
831
|
+
context "with a service account" do
|
|
832
|
+
setup do
|
|
833
|
+
@client_mock = setup_mock_client
|
|
834
|
+
end
|
|
835
|
+
|
|
836
|
+
should "connect and obtain an access token" do
|
|
837
|
+
connection = Google::Connection.new_with_service_account(
|
|
838
|
+
:client_id => "the-issuer@example.iam.gserviceaccount.com",
|
|
839
|
+
:signing_key => OpenSSL::PKey::RSA.new(2048),
|
|
840
|
+
:person => "user@example.com"
|
|
841
|
+
)
|
|
842
|
+
|
|
843
|
+
assert_equal connection.access_token, ENV['ACCESS_TOKEN']
|
|
844
|
+
end
|
|
845
|
+
end
|
|
846
|
+
|
|
737
847
|
protected
|
|
738
848
|
|
|
739
849
|
def get_mock_body(name)
|
metadata
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: google_calendar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Steve Zich
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 2026-07-07 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: addressable
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 2.7.0
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: 2.7.0
|
|
13
26
|
- !ruby/object:Gem::Dependency
|
|
14
27
|
name: signet
|
|
15
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -40,18 +53,38 @@ dependencies:
|
|
|
40
53
|
version: 1.8.3
|
|
41
54
|
- !ruby/object:Gem::Dependency
|
|
42
55
|
name: TimezoneParser
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0.3'
|
|
61
|
+
- - "<"
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '1.1'
|
|
64
|
+
type: :runtime
|
|
65
|
+
prerelease: false
|
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '0.3'
|
|
71
|
+
- - "<"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '1.1'
|
|
74
|
+
- !ruby/object:Gem::Dependency
|
|
75
|
+
name: sorted_set
|
|
43
76
|
requirement: !ruby/object:Gem::Requirement
|
|
44
77
|
requirements:
|
|
45
78
|
- - "~>"
|
|
46
79
|
- !ruby/object:Gem::Version
|
|
47
|
-
version:
|
|
80
|
+
version: '1.0'
|
|
48
81
|
type: :runtime
|
|
49
82
|
prerelease: false
|
|
50
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
84
|
requirements:
|
|
52
85
|
- - "~>"
|
|
53
86
|
- !ruby/object:Gem::Version
|
|
54
|
-
version:
|
|
87
|
+
version: '1.0'
|
|
55
88
|
- !ruby/object:Gem::Dependency
|
|
56
89
|
name: terminal-notifier-guard
|
|
57
90
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,14 +147,14 @@ dependencies:
|
|
|
114
147
|
requirements:
|
|
115
148
|
- - "~>"
|
|
116
149
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: '
|
|
150
|
+
version: '2.0'
|
|
118
151
|
type: :development
|
|
119
152
|
prerelease: false
|
|
120
153
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
154
|
requirements:
|
|
122
155
|
- - "~>"
|
|
123
156
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: '
|
|
157
|
+
version: '2.0'
|
|
125
158
|
- !ruby/object:Gem::Dependency
|
|
126
159
|
name: bundler
|
|
127
160
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -142,14 +175,14 @@ dependencies:
|
|
|
142
175
|
requirements:
|
|
143
176
|
- - "~>"
|
|
144
177
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '
|
|
178
|
+
version: '2.0'
|
|
146
179
|
type: :development
|
|
147
180
|
prerelease: false
|
|
148
181
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
182
|
requirements:
|
|
150
183
|
- - "~>"
|
|
151
184
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: '
|
|
185
|
+
version: '2.0'
|
|
153
186
|
- !ruby/object:Gem::Dependency
|
|
154
187
|
name: rake
|
|
155
188
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -168,16 +201,16 @@ dependencies:
|
|
|
168
201
|
name: rdoc
|
|
169
202
|
requirement: !ruby/object:Gem::Requirement
|
|
170
203
|
requirements:
|
|
171
|
-
- - "
|
|
204
|
+
- - ">"
|
|
172
205
|
- !ruby/object:Gem::Version
|
|
173
|
-
version:
|
|
206
|
+
version: 6.3.1
|
|
174
207
|
type: :development
|
|
175
208
|
prerelease: false
|
|
176
209
|
version_requirements: !ruby/object:Gem::Requirement
|
|
177
210
|
requirements:
|
|
178
|
-
- - "
|
|
211
|
+
- - ">"
|
|
179
212
|
- !ruby/object:Gem::Version
|
|
180
|
-
version:
|
|
213
|
+
version: 6.3.1
|
|
181
214
|
- !ruby/object:Gem::Dependency
|
|
182
215
|
name: dotenv
|
|
183
216
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -192,6 +225,20 @@ dependencies:
|
|
|
192
225
|
- - "~>"
|
|
193
226
|
- !ruby/object:Gem::Version
|
|
194
227
|
version: '2.1'
|
|
228
|
+
- !ruby/object:Gem::Dependency
|
|
229
|
+
name: simplecov
|
|
230
|
+
requirement: !ruby/object:Gem::Requirement
|
|
231
|
+
requirements:
|
|
232
|
+
- - "~>"
|
|
233
|
+
- !ruby/object:Gem::Version
|
|
234
|
+
version: '0.22'
|
|
235
|
+
type: :development
|
|
236
|
+
prerelease: false
|
|
237
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
238
|
+
requirements:
|
|
239
|
+
- - "~>"
|
|
240
|
+
- !ruby/object:Gem::Version
|
|
241
|
+
version: '0.22'
|
|
195
242
|
description: A minimal wrapper around the google calendar API
|
|
196
243
|
email: steve.zich@gmail.com
|
|
197
244
|
executables: []
|
|
@@ -203,8 +250,8 @@ files:
|
|
|
203
250
|
- ".document"
|
|
204
251
|
- ".env.default"
|
|
205
252
|
- ".env.test"
|
|
253
|
+
- ".github/workflows/ci.yml"
|
|
206
254
|
- ".gitignore"
|
|
207
|
-
- ".travis.yml"
|
|
208
255
|
- Gemfile
|
|
209
256
|
- Gemfile.lock
|
|
210
257
|
- Guardfile
|
|
@@ -261,7 +308,6 @@ homepage: http://northworld.github.io/google_calendar/
|
|
|
261
308
|
licenses:
|
|
262
309
|
- MIT
|
|
263
310
|
metadata: {}
|
|
264
|
-
post_install_message:
|
|
265
311
|
rdoc_options: []
|
|
266
312
|
require_paths:
|
|
267
313
|
- lib
|
|
@@ -269,16 +315,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
269
315
|
requirements:
|
|
270
316
|
- - ">="
|
|
271
317
|
- !ruby/object:Gem::Version
|
|
272
|
-
version: '
|
|
318
|
+
version: '3.2'
|
|
273
319
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
320
|
requirements:
|
|
275
321
|
- - ">="
|
|
276
322
|
- !ruby/object:Gem::Version
|
|
277
323
|
version: '0'
|
|
278
324
|
requirements: []
|
|
279
|
-
|
|
280
|
-
rubygems_version: 2.6.14
|
|
281
|
-
signing_key:
|
|
325
|
+
rubygems_version: 3.7.1
|
|
282
326
|
specification_version: 4
|
|
283
327
|
summary: A lightweight Google Calendar API wrapper
|
|
284
328
|
test_files:
|
data/.travis.yml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.1
|
|
4
|
-
- 2.2
|
|
5
|
-
- 2.3
|
|
6
|
-
- 2.4
|
|
7
|
-
- 2.5
|
|
8
|
-
addons:
|
|
9
|
-
code_climate:
|
|
10
|
-
repo_token: 35bb9d218078742d37436a9c9a8b78199e8c7312d034081881de670e95b8dcad
|
|
11
|
-
after_success:
|
|
12
|
-
- bundle exec codeclimate-test-reporter
|
|
13
|
-
# uncomment this line if your project needs to run something other than `rake`:
|
|
14
|
-
# script: bundle exec rspec spec
|