bps-google-api 0.4.0 → 0.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/Gemfile.lock +18 -18
- data/Readme.md +58 -1
- data/bps-google-api.gemspec +3 -3
- data/lib/google_api.rb +6 -0
- data/lib/google_api/calendar.rb +17 -2
- data/lib/google_api/calendar/conference.rb +7 -0
- data/lib/google_api/config.rb +1 -1
- data/lib/google_api/configured/calendar.rb +8 -0
- data/lib/google_api/configured/event.rb +4 -0
- data/spec/lib/google_api/calendar_spec.rb +32 -13
- data/spec/lib/google_api/event_spec.rb +13 -2
- data/spec/spec_helper.rb +2 -0
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f9ffa3df8c2ddfecc62cfe5a9830ea2c48293aef1952240e9dd5acd12b260ca1
|
4
|
+
data.tar.gz: 1f3079fcec7a957a890fa217ee44e4ddcf664c31c0bc8129502ca70b92b0503f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6412ddc986f1aff995bde999836779c649d9025fd885ab98e7ebb6dd1cc1e35c02f7685648cfa5308069e641e9c1da4bcb435c48a1274ccf7621bfc191849253
|
7
|
+
data.tar.gz: 7745f51650c013b668e1bdb535db57f5957f9ad5cf5b49b785e8280b91f0aeab2bef2f9964c1e6735b50ec87d45b48a954ee89e516098c4f3b36d7b1c8ee348a
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bps-google-api (0.4.
|
5
|
-
exp_retry (~> 0.0.
|
4
|
+
bps-google-api (0.4.6)
|
5
|
+
exp_retry (~> 0.0.13)
|
6
6
|
fileutils (~> 1.2)
|
7
7
|
google-api-client (~> 0.23.4)
|
8
8
|
ruby-progressbar (~> 1.10)
|
@@ -10,17 +10,17 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
addressable (2.
|
14
|
-
public_suffix (>= 2.0.2, <
|
13
|
+
addressable (2.7.0)
|
14
|
+
public_suffix (>= 2.0.2, < 5.0)
|
15
15
|
ast (2.4.0)
|
16
|
-
declarative (0.0.
|
16
|
+
declarative (0.0.20)
|
17
17
|
declarative-option (0.1.0)
|
18
18
|
diff-lcs (1.3)
|
19
19
|
docile (1.3.2)
|
20
|
-
exp_retry (0.0.
|
21
|
-
faraday (0.
|
20
|
+
exp_retry (0.0.13)
|
21
|
+
faraday (0.17.3)
|
22
22
|
multipart-post (>= 1.2, < 3)
|
23
|
-
fileutils (1.
|
23
|
+
fileutils (1.5.0)
|
24
24
|
google-api-client (0.23.9)
|
25
25
|
addressable (~> 2.5, >= 2.5.1)
|
26
26
|
googleauth (>= 0.5, < 0.7.0)
|
@@ -38,19 +38,19 @@ GEM
|
|
38
38
|
signet (~> 0.7)
|
39
39
|
httpclient (2.8.3)
|
40
40
|
jaro_winkler (1.5.3)
|
41
|
-
json (2.
|
42
|
-
jwt (2.2.
|
43
|
-
memoist (0.16.
|
44
|
-
mime-types (3.
|
41
|
+
json (2.3.1)
|
42
|
+
jwt (2.2.2)
|
43
|
+
memoist (0.16.2)
|
44
|
+
mime-types (3.3.1)
|
45
45
|
mime-types-data (~> 3.2015)
|
46
|
-
mime-types-data (3.
|
47
|
-
multi_json (1.
|
46
|
+
mime-types-data (3.2020.1104)
|
47
|
+
multi_json (1.15.0)
|
48
48
|
multipart-post (2.1.1)
|
49
|
-
os (1.
|
49
|
+
os (1.1.1)
|
50
50
|
parallel (1.17.0)
|
51
51
|
parser (2.6.3.0)
|
52
52
|
ast (~> 2.4.0)
|
53
|
-
public_suffix (
|
53
|
+
public_suffix (4.0.6)
|
54
54
|
rainbow (3.0.0)
|
55
55
|
representable (3.0.4)
|
56
56
|
declarative (< 0.1.0)
|
@@ -78,9 +78,9 @@ GEM
|
|
78
78
|
ruby-progressbar (~> 1.7)
|
79
79
|
unicode-display_width (>= 1.4.0, < 1.7)
|
80
80
|
ruby-progressbar (1.10.1)
|
81
|
-
signet (0.
|
81
|
+
signet (0.14.1)
|
82
82
|
addressable (~> 2.3)
|
83
|
-
faraday (
|
83
|
+
faraday (>= 0.17.3, < 2.0)
|
84
84
|
jwt (>= 1.5, < 3.0)
|
85
85
|
multi_json (~> 1.10)
|
86
86
|
simplecov (0.16.1)
|
data/Readme.md
CHANGED
@@ -36,6 +36,12 @@ GoogleAPI.configure do |config|
|
|
36
36
|
end
|
37
37
|
```
|
38
38
|
|
39
|
+
You can also alter the logging level using:
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
GoogleAPI.logging!(:FATAL) # %i[INFO WARN ERROR FATAL]
|
43
|
+
```
|
44
|
+
|
39
45
|
Then add the following in `config/application.rb`:
|
40
46
|
|
41
47
|
```ruby
|
@@ -62,13 +68,22 @@ TZ # Timezone
|
|
62
68
|
By default, if no configuration is available, `.new` will automatically run
|
63
69
|
`.authorize!` and return a URL to generate an authorization token.
|
64
70
|
|
71
|
+
### Configured Classes
|
72
|
+
|
73
|
+
There are configured classes for both calendars and groups. This allows you to
|
74
|
+
only specify the parent id once.
|
75
|
+
|
65
76
|
```ruby
|
66
77
|
calendar = GoogleAPI::Configured::Calendar.new(calendar_id)
|
67
78
|
|
68
79
|
calendar.create(event_options)
|
69
80
|
calendar.list(max_results: 2500, page_token: nil)
|
81
|
+
calendar.list_all
|
70
82
|
calendar.get(event_id)
|
71
|
-
calendar.
|
83
|
+
calendar.patch(event_id, patch_options)
|
84
|
+
calendar.update(event_id, updated_event_options)
|
85
|
+
calendar.add_conference(event_id)
|
86
|
+
calendar.conference_info(event_id, all: false)
|
72
87
|
calendar.delete(event_id)
|
73
88
|
|
74
89
|
calendar.permit(user)
|
@@ -84,6 +99,19 @@ group.add('somebody@example.com')
|
|
84
99
|
group.remove('somebody@example.com')
|
85
100
|
```
|
86
101
|
|
102
|
+
There is also an event-specific configured class:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
event = GoogleAPI::Configured::Calendar::Event.new(calendar_id, event_id)
|
106
|
+
|
107
|
+
event.get
|
108
|
+
event.patch(patch_options)
|
109
|
+
event.update(updated_event_options)
|
110
|
+
event.add_conference
|
111
|
+
event.conference_info(all: false)
|
112
|
+
event.delete
|
113
|
+
```
|
114
|
+
|
87
115
|
### Event Options
|
88
116
|
|
89
117
|
Available event options are listed in `GoogleAPI::Calendar::VALID_EVENT_KEYS`.
|
@@ -104,3 +132,32 @@ To add a Meet call to an event, merge the following into `event_options`:
|
|
104
132
|
```ruby
|
105
133
|
{ conference: { id: meeting_id, signature: meeting_signature } }
|
106
134
|
```
|
135
|
+
|
136
|
+
To create a new Meet call on an event, merge the following into
|
137
|
+
`event_options` instead:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
{ conference: { id: :new } }
|
141
|
+
```
|
142
|
+
|
143
|
+
## Testing
|
144
|
+
|
145
|
+
### Rspec
|
146
|
+
|
147
|
+
Rspec testing is available:
|
148
|
+
|
149
|
+
`bundle exec rspec`
|
150
|
+
|
151
|
+
The spec suite will fail if under 100% coverage.
|
152
|
+
|
153
|
+
### Rubocop
|
154
|
+
|
155
|
+
Rubocop formatting validation is available:
|
156
|
+
|
157
|
+
`bundle exec rubocop`
|
158
|
+
|
159
|
+
### Automatic Builds
|
160
|
+
|
161
|
+
Builds are generated automatically by [Travis CI](https://travis-ci.org/jfiander/bps-google-api).
|
162
|
+
|
163
|
+
Build success requires both `rspec` and `rubocop` to pass.
|
data/bps-google-api.gemspec
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'bps-google-api'
|
5
|
-
s.version = '0.4.
|
6
|
-
s.date = '
|
5
|
+
s.version = '0.4.6'
|
6
|
+
s.date = '2021-01-30'
|
7
7
|
s.summary = 'Configured Google API'
|
8
8
|
s.description = 'A configured Google API wrapper.'
|
9
9
|
s.homepage = 'http://rubygems.org/gems/bps-google-api'
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.required_ruby_version = '~> 2.4'
|
17
17
|
|
18
|
-
s.add_runtime_dependency 'exp_retry', '~> 0.0.
|
18
|
+
s.add_runtime_dependency 'exp_retry', '~> 0.0.13'
|
19
19
|
s.add_runtime_dependency 'fileutils', '~> 1.2'
|
20
20
|
s.add_runtime_dependency 'google-api-client', '~> 0.23.4'
|
21
21
|
s.add_runtime_dependency 'ruby-progressbar', '~> 1.10'
|
data/lib/google_api.rb
CHANGED
@@ -29,6 +29,12 @@ class GoogleAPI
|
|
29
29
|
configuration
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.logging!(level = :FATAL)
|
33
|
+
raise ArgumentError, 'Unknown logging level' unless %i[INFO WARN ERROR FATAL].include?(level)
|
34
|
+
|
35
|
+
Google::Apis.logger.level = Logger.const_get(level)
|
36
|
+
end
|
37
|
+
|
32
38
|
# Internal requires
|
33
39
|
require 'google_api/base'
|
34
40
|
require 'google_api/calendar'
|
data/lib/google_api/calendar.rb
CHANGED
@@ -14,8 +14,7 @@ class GoogleAPI
|
|
14
14
|
|
15
15
|
SERVICE_CLASS = Google::Apis::CalendarV3::CalendarService
|
16
16
|
VALID_EVENT_KEYS ||= %i[
|
17
|
-
summary start end description location recurrence conference
|
18
|
-
conference_data
|
17
|
+
summary start end description location recurrence conference conference_data
|
19
18
|
].freeze
|
20
19
|
VALID_PATCH_KEYS ||= %i[
|
21
20
|
summary start end description location recurrence conference_data created reminders creator
|
@@ -30,6 +29,22 @@ class GoogleAPI
|
|
30
29
|
call(:list_events, calendar_id, max_results: max_results, page_token: page_token)
|
31
30
|
end
|
32
31
|
|
32
|
+
def list_all(calendar_id, verbose: false)
|
33
|
+
events = []
|
34
|
+
|
35
|
+
list = call(:list_events, calendar_id)
|
36
|
+
events += list.items
|
37
|
+
|
38
|
+
while (page_token = list.next_page_token)
|
39
|
+
list = call(:list_events, calendar_id, page_token: page_token)
|
40
|
+
page_token = list.next_page_token
|
41
|
+
events += list.items
|
42
|
+
print('.') if verbose
|
43
|
+
end
|
44
|
+
|
45
|
+
events
|
46
|
+
end
|
47
|
+
|
33
48
|
def get(calendar_id, event_id)
|
34
49
|
call(:get_event, calendar_id, event_id)
|
35
50
|
end
|
@@ -15,6 +15,13 @@ class GoogleAPI
|
|
15
15
|
call(:patch_event, calendar_id, event_id, patch_options, conference_data_version: 1)
|
16
16
|
end
|
17
17
|
|
18
|
+
def conference_info(calendar_id, event_id, all: false)
|
19
|
+
conf = call(:get_event, calendar_id, event_id).conference_data
|
20
|
+
return conf if all || conf.nil?
|
21
|
+
|
22
|
+
{ id: conf.conference_id, signature: conf.signature }
|
23
|
+
end
|
24
|
+
|
18
25
|
private
|
19
26
|
|
20
27
|
def format_conference_data(event_options)
|
data/lib/google_api/config.rb
CHANGED
@@ -17,6 +17,10 @@ class GoogleAPI
|
|
17
17
|
self.class.api.list(calendar_id, max_results: max_results, page_token: page_token)
|
18
18
|
end
|
19
19
|
|
20
|
+
def list_all
|
21
|
+
self.class.api.list_all(calendar_id)
|
22
|
+
end
|
23
|
+
|
20
24
|
def create(event_options = {})
|
21
25
|
self.class.api.create(calendar_id, event_options)
|
22
26
|
end
|
@@ -54,6 +58,10 @@ class GoogleAPI
|
|
54
58
|
def add_conference(event_id)
|
55
59
|
self.class.api.add_conference(calendar_id, event_id)
|
56
60
|
end
|
61
|
+
|
62
|
+
def conference_info(event_id, all: false)
|
63
|
+
self.class.api.conference_info(calendar_id, event_id, all: all)
|
64
|
+
end
|
57
65
|
end
|
58
66
|
end
|
59
67
|
end
|
@@ -77,26 +77,45 @@ RSpec.describe GoogleAPI::Calendar do
|
|
77
77
|
expect(subject.list).to be_a(Google::Apis::CalendarV3::Events)
|
78
78
|
end
|
79
79
|
|
80
|
+
it 'returns the array of all events from list_all' do
|
81
|
+
subject.create(test_event) # Ensure at least one event exists
|
82
|
+
|
83
|
+
expect(subject.list_all.map(&:class).uniq).to eql([Google::Apis::CalendarV3::Event])
|
84
|
+
end
|
85
|
+
|
80
86
|
it 'creates an event' do
|
81
87
|
expect(subject.create(test_event)).to be_a(Google::Apis::CalendarV3::Event)
|
82
88
|
end
|
83
89
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
90
|
+
describe 'conference data' do
|
91
|
+
it 'creates an event with a new conference' do
|
92
|
+
event = test_event.merge(conference: { id: :new })
|
88
93
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
+
expect(subject.create(event)).to be_a(Google::Apis::CalendarV3::Event)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'creates an event with conference data' do
|
98
|
+
event = subject.create(test_event)
|
99
|
+
event = subject.add_conference(event.id)
|
100
|
+
event_options = test_event.merge(
|
101
|
+
conference: {
|
102
|
+
id: event.conference_data.conference_id,
|
103
|
+
signature: event.conference_data.signature
|
104
|
+
}
|
105
|
+
)
|
106
|
+
|
107
|
+
expect(subject.create(event_options)).to be_a(Google::Apis::CalendarV3::Event)
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'returns valid conference information' do
|
111
|
+
event = subject.create(test_event)
|
112
|
+
event = subject.add_conference(event.id)
|
113
|
+
|
114
|
+
expect(subject.conference_info(event.id)).to eql(
|
94
115
|
id: event.conference_data.conference_id,
|
95
116
|
signature: event.conference_data.signature
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
expect(subject.create(event_options)).to be_a(Google::Apis::CalendarV3::Event)
|
117
|
+
)
|
118
|
+
end
|
100
119
|
end
|
101
120
|
|
102
121
|
it 'gets an event ' do
|
@@ -40,7 +40,18 @@ RSpec.describe GoogleAPI::Configured::Calendar::Event do
|
|
40
40
|
expect(subject.delete).to eql('')
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
43
|
+
describe 'conference data' do
|
44
|
+
it 'adds conference data' do
|
45
|
+
expect(subject.add_conference).to be_a(Google::Apis::CalendarV3::Event)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns valid conference information' do
|
49
|
+
event = subject.add_conference
|
50
|
+
|
51
|
+
expect(subject.conference_info).to eql(
|
52
|
+
id: event.conference_data.conference_id,
|
53
|
+
signature: event.conference_data.signature
|
54
|
+
)
|
55
|
+
end
|
45
56
|
end
|
46
57
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bps-google-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: exp_retry
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.13
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.0.
|
26
|
+
version: 0.0.13
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fileutils
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,8 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
181
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.6.14.1
|
182
|
+
rubygems_version: 3.2.7
|
184
183
|
signing_key:
|
185
184
|
specification_version: 4
|
186
185
|
summary: Configured Google API
|