cronofy 0.22.0 → 0.23.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/cronofy.rb +3 -0
- data/lib/cronofy/client.rb +32 -8
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +51 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f49556775f54db6e9d33b86eb11a597abd666d74
|
4
|
+
data.tar.gz: b1fcdc132ab95869f21173f4e5b2f0d07f75ae89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 079b7acfd635b54c5455e729825e501ed0a98468b0879159ea5bb7949ca0088e41cddbc55d139a8de077e864403a643e4fc5d8f2e656c001921a1a8ba500b5c1
|
7
|
+
data.tar.gz: 9c21a0271003820802875da88e19b8fa157e37720ac2f5c434ec3cd8d1b945c7220b3fce18071b2c02f402ee6b8fd88d1fe871651a6e019bc8edd74e8d900d01
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.23.0]
|
2
|
+
|
3
|
+
* Support for color with calendar creation and event upsert [#46]
|
4
|
+
* Helper to verify push notification HMACs [#45]
|
5
|
+
|
1
6
|
## [0.22.0]
|
2
7
|
|
3
8
|
* Splitting of Add to Calendar and Real time scheduling [#44]
|
@@ -64,6 +69,7 @@
|
|
64
69
|
[0.20.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.20.0
|
65
70
|
[0.21.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.21.0
|
66
71
|
[0.22.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.22.0
|
72
|
+
[0.23.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.23.0
|
67
73
|
|
68
74
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
69
75
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -82,3 +88,5 @@
|
|
82
88
|
[#40]: https://github.com/cronofy/cronofy-ruby/pull/40
|
83
89
|
[#43]: https://github.com/cronofy/cronofy-ruby/pull/43
|
84
90
|
[#44]: https://github.com/cronofy/cronofy-ruby/pull/44
|
91
|
+
[#45]: https://github.com/cronofy/cronofy-ruby/pull/45
|
92
|
+
[#46]: https://github.com/cronofy/cronofy-ruby/pull/46
|
data/lib/cronofy.rb
CHANGED
data/lib/cronofy/client.rb
CHANGED
@@ -42,13 +42,15 @@ module Cronofy
|
|
42
42
|
)
|
43
43
|
end
|
44
44
|
|
45
|
-
# Public: Creates a new calendar for the
|
45
|
+
# Public: Creates a new calendar for the profile.
|
46
46
|
#
|
47
47
|
# profile_id - The String ID of the profile to create the calendar within.
|
48
|
-
# name -
|
48
|
+
# name - The String to use as the name of the calendar.
|
49
|
+
# options - The Hash options used to customize the calendar
|
50
|
+
# (default: {}):
|
51
|
+
# :color - The color to make the calendar (optional).
|
49
52
|
#
|
50
|
-
# See
|
51
|
-
# reference.
|
53
|
+
# See https://www.cronofy.com/developers/api/#create-calendar for reference.
|
52
54
|
#
|
53
55
|
# Returns the created Calendar
|
54
56
|
#
|
@@ -63,8 +65,9 @@ module Cronofy
|
|
63
65
|
# state and so a calendar cannot be created.
|
64
66
|
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
65
67
|
# limits for the application.
|
66
|
-
def create_calendar(profile_id, name)
|
67
|
-
|
68
|
+
def create_calendar(profile_id, name, options = {})
|
69
|
+
request = options.merge(profile_id: profile_id, name: name)
|
70
|
+
response = post("/v1/calendars", request)
|
68
71
|
parse_json(Calendar, "calendar", response)
|
69
72
|
end
|
70
73
|
|
@@ -120,6 +123,7 @@ module Cronofy
|
|
120
123
|
# occur.
|
121
124
|
# :transparency - The transparency state for the event (optional).
|
122
125
|
# Accepted values are "transparent" and "opaque".
|
126
|
+
# :color - The color of the event (optional).
|
123
127
|
# :attendees - A Hash of :invite and :reject, each of which is
|
124
128
|
# an array of invitees to invite to or reject from
|
125
129
|
# the event. Invitees are represented by a hash of
|
@@ -254,7 +258,7 @@ module Cronofy
|
|
254
258
|
# The first page will be retrieved eagerly so that common errors will happen
|
255
259
|
# inline. However, subsequent pages (if any) will be requested lazily.
|
256
260
|
#
|
257
|
-
# See http://www.cronofy.com/developers/api
|
261
|
+
# See http://www.cronofy.com/developers/api/#free-busy for reference.
|
258
262
|
#
|
259
263
|
# Returns a lazily-evaluated Enumerable of FreeBusy
|
260
264
|
#
|
@@ -394,6 +398,26 @@ module Cronofy
|
|
394
398
|
parse_json(Channel, "channel", response)
|
395
399
|
end
|
396
400
|
|
401
|
+
# Public: Verifies a HMAC from a push notification using the client secret.
|
402
|
+
#
|
403
|
+
# args - A Hash containing the details of the push notification:
|
404
|
+
# :body - A String of the body of the notification.
|
405
|
+
# :hmac - A String of the HMAC of the notification taken from the
|
406
|
+
# Cronofy-HMAC-SHA256 header.
|
407
|
+
#
|
408
|
+
# Returns true if the HMAC provided matches the one calculated using the
|
409
|
+
# client secret, otherwise false.
|
410
|
+
def hmac_match?(args)
|
411
|
+
body = args[:body]
|
412
|
+
hmac = args[:hmac]
|
413
|
+
|
414
|
+
sha256 = OpenSSL::Digest.new('sha256')
|
415
|
+
digest = OpenSSL::HMAC.digest(sha256, @client_secret, body)
|
416
|
+
calculated = Base64.encode64(digest).strip
|
417
|
+
|
418
|
+
calculated == hmac
|
419
|
+
end
|
420
|
+
|
397
421
|
# Public: Lists all the notification channels for the account.
|
398
422
|
#
|
399
423
|
# See http://www.cronofy.com/developers/api#list-channels for reference.
|
@@ -453,7 +477,7 @@ module Cronofy
|
|
453
477
|
|
454
478
|
# Public: Lists all the profiles for the account.
|
455
479
|
#
|
456
|
-
# See https://www.cronofy.com/developers/api
|
480
|
+
# See https://www.cronofy.com/developers/api/#profiles for reference.
|
457
481
|
#
|
458
482
|
# Returns an Array of Profiles
|
459
483
|
#
|
data/lib/cronofy/version.rb
CHANGED
@@ -136,12 +136,10 @@ describe Cronofy::Client do
|
|
136
136
|
describe '#create_calendar' do
|
137
137
|
let(:request_url) { 'https://api.cronofy.com/v1/calendars' }
|
138
138
|
let(:method) { :post }
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
}
|
144
|
-
end
|
139
|
+
|
140
|
+
let(:profile_id) { "pro_1234" }
|
141
|
+
let(:calendar_name) { "Home" }
|
142
|
+
let(:color) { "#49BED8" }
|
145
143
|
|
146
144
|
let(:correct_response_code) { 200 }
|
147
145
|
let(:correct_response_body) do
|
@@ -161,10 +159,34 @@ describe Cronofy::Client do
|
|
161
159
|
Cronofy::Calendar.new(correct_response_body["calendar"])
|
162
160
|
end
|
163
161
|
|
164
|
-
|
162
|
+
context "with mandatory arguments" do
|
163
|
+
let(:request_body) do
|
164
|
+
{
|
165
|
+
profile_id: profile_id,
|
166
|
+
name: calendar_name,
|
167
|
+
}
|
168
|
+
end
|
165
169
|
|
166
|
-
|
167
|
-
|
170
|
+
subject { client.create_calendar(profile_id, calendar_name) }
|
171
|
+
|
172
|
+
it_behaves_like 'a Cronofy request'
|
173
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
174
|
+
end
|
175
|
+
|
176
|
+
context "with color" do
|
177
|
+
let(:request_body) do
|
178
|
+
{
|
179
|
+
profile_id: profile_id,
|
180
|
+
name: calendar_name,
|
181
|
+
color: color,
|
182
|
+
}
|
183
|
+
end
|
184
|
+
|
185
|
+
subject { client.create_calendar(profile_id, calendar_name, color: color) }
|
186
|
+
|
187
|
+
it_behaves_like 'a Cronofy request'
|
188
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
189
|
+
end
|
168
190
|
end
|
169
191
|
|
170
192
|
describe '#list_calendars' do
|
@@ -1688,4 +1710,24 @@ describe Cronofy::Client do
|
|
1688
1710
|
end
|
1689
1711
|
end
|
1690
1712
|
end
|
1713
|
+
|
1714
|
+
describe "HMAC verification" do
|
1715
|
+
let(:client) do
|
1716
|
+
Cronofy::Client.new(
|
1717
|
+
client_secret: 'pDY0Oi7TJSP2hfNmZNkm5',
|
1718
|
+
access_token: token,
|
1719
|
+
refresh_token: 'refresh_token_456',
|
1720
|
+
)
|
1721
|
+
end
|
1722
|
+
|
1723
|
+
let(:body) { "{\"example\":\"well-known\"}" }
|
1724
|
+
|
1725
|
+
it "verifies the correct HMAC" do
|
1726
|
+
expect(client.hmac_match?(body: body, hmac: "6r2/HjBkqymGegX0wOfifieeUXbbHwtV/LohHS+jv6c=")).to be true
|
1727
|
+
end
|
1728
|
+
|
1729
|
+
it "rejects an incorrect HMAC" do
|
1730
|
+
expect(client.hmac_match?(body: body, hmac: "something-else")).to be false
|
1731
|
+
end
|
1732
|
+
end
|
1691
1733
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergii Paryzhskyi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
149
|
version: '0'
|
150
150
|
requirements: []
|
151
151
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.6.
|
152
|
+
rubygems_version: 2.6.6
|
153
153
|
signing_key:
|
154
154
|
specification_version: 4
|
155
155
|
summary: Cronofy - one API for all the calendars
|