bps-google-api 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/Readme.md +49 -1
- data/bps-google-api.gemspec +1 -1
- data/lib/google_api/calendar.rb +16 -0
- data/lib/google_api/configured/calendar.rb +4 -0
- data/spec/lib/google_api/calendar_spec.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b77040196a93c3ed682e0bcd28b1db7ef594bb49
|
4
|
+
data.tar.gz: 9aa7deb73ce20a9dea1ecc582c627d7120c76fae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c017f0c3170205f69642fce1e107ce705a76bf7b2d233ad60a3c63425aa24ea4db3599063cdcc209366043399178173cbc992e7931a97600752d129b11e2539
|
7
|
+
data.tar.gz: b659861c968fc28453cd7b1e4cc467445aade4c60356ddf19a2d44c96fd52ec1f566bc1ef5ac15ff2179e10e4a1ed5b3734661ba36cd133b95b197eee24e4a6c
|
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -62,13 +62,20 @@ TZ # Timezone
|
|
62
62
|
By default, if no configuration is available, `.new` will automatically run
|
63
63
|
`.authorize!` and return a URL to generate an authorization token.
|
64
64
|
|
65
|
+
### Configured Classes
|
66
|
+
|
67
|
+
There are configured classes for both calendars and groups. This allows you to
|
68
|
+
only specify the parent id once.
|
69
|
+
|
65
70
|
```ruby
|
66
71
|
calendar = GoogleAPI::Configured::Calendar.new(calendar_id)
|
67
72
|
|
68
73
|
calendar.create(event_options)
|
69
74
|
calendar.list(max_results: 2500, page_token: nil)
|
70
75
|
calendar.get(event_id)
|
71
|
-
calendar.
|
76
|
+
calendar.patch(event_id, patch_options)
|
77
|
+
calendar.update(event_id, updated_event_options)
|
78
|
+
calendar.add_conference(event_id)
|
72
79
|
calendar.delete(event_id)
|
73
80
|
|
74
81
|
calendar.permit(user)
|
@@ -84,6 +91,18 @@ group.add('somebody@example.com')
|
|
84
91
|
group.remove('somebody@example.com')
|
85
92
|
```
|
86
93
|
|
94
|
+
There is also an event-specific configured class:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
event = GoogleAPI::Configured::Calendar::Event.new(calendar_id, event_id)
|
98
|
+
|
99
|
+
event.get
|
100
|
+
event.patch(patch_options)
|
101
|
+
event.update(updated_event_options)
|
102
|
+
event.add_conference
|
103
|
+
event.delete
|
104
|
+
```
|
105
|
+
|
87
106
|
### Event Options
|
88
107
|
|
89
108
|
Available event options are listed in `GoogleAPI::Calendar::VALID_EVENT_KEYS`.
|
@@ -104,3 +123,32 @@ To add a Meet call to an event, merge the following into `event_options`:
|
|
104
123
|
```ruby
|
105
124
|
{ conference: { id: meeting_id, signature: meeting_signature } }
|
106
125
|
```
|
126
|
+
|
127
|
+
To create a new Meet call on an event, merge the following into
|
128
|
+
`event_options` instead:
|
129
|
+
|
130
|
+
```ruby
|
131
|
+
{ conference: { id: :new } }
|
132
|
+
```
|
133
|
+
|
134
|
+
## Testing
|
135
|
+
|
136
|
+
### Rspec
|
137
|
+
|
138
|
+
Rspec testing is available:
|
139
|
+
|
140
|
+
`bundle exec rspec`
|
141
|
+
|
142
|
+
The spec suite will fail if under 100% coverage.
|
143
|
+
|
144
|
+
### Rubocop
|
145
|
+
|
146
|
+
Rubocop formatting validation is available:
|
147
|
+
|
148
|
+
`bundle exec rubocop`
|
149
|
+
|
150
|
+
### Automatic Builds
|
151
|
+
|
152
|
+
Builds are generated automatically by [Travis CI](https://travis-ci.org/jfiander/bps-google-api).
|
153
|
+
|
154
|
+
Build success requires both `rspec` and `rubocop` to pass.
|
data/bps-google-api.gemspec
CHANGED
data/lib/google_api/calendar.rb
CHANGED
@@ -30,6 +30,22 @@ class GoogleAPI
|
|
30
30
|
call(:list_events, calendar_id, max_results: max_results, page_token: page_token)
|
31
31
|
end
|
32
32
|
|
33
|
+
def list_all(calendar_id, verbose: false)
|
34
|
+
events = []
|
35
|
+
|
36
|
+
list = call(:list_events, calendar_id)
|
37
|
+
events += list.items
|
38
|
+
|
39
|
+
while (page_token = list.next_page_token)
|
40
|
+
list = call(:list_events, calendar_id, page_token: page_token)
|
41
|
+
page_token = list.next_page_token
|
42
|
+
events += list.items
|
43
|
+
print('.') if verbose
|
44
|
+
end
|
45
|
+
|
46
|
+
events
|
47
|
+
end
|
48
|
+
|
33
49
|
def get(calendar_id, event_id)
|
34
50
|
call(:get_event, calendar_id, event_id)
|
35
51
|
end
|
@@ -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
|
@@ -77,6 +77,10 @@ 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
|
+
expect(subject.list_all.map(&:class).uniq).to eql([Google::Apis::CalendarV3::Event])
|
82
|
+
end
|
83
|
+
|
80
84
|
it 'creates an event' do
|
81
85
|
expect(subject.create(test_event)).to be_a(Google::Apis::CalendarV3::Event)
|
82
86
|
end
|