cronofy 0.37.3 → 0.37.6
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 +22 -4
- data/lib/cronofy/client.rb +76 -9
- data/lib/cronofy/types.rb +4 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +386 -105
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7a632c7e4036fef7e004f6310425d235fea56520b297b4a3a0c644fe57a0011
|
4
|
+
data.tar.gz: 0fc429f25dc4ff14003629e81139047c36ccdf7ba2e06631c0b22d913e709bb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92488cee8fea969192bc9ef1aa624872201c4928087b385f5d10cac11720575191cfbc89db86016c31ba87bac8f57b6d7890ab8e3beb2925a8eafc87cb98b08f
|
7
|
+
data.tar.gz: 7c0651b6b64c64e50ce356699b9ea3ba58928dee2ccdb3922ae4cbbd6a6b4fd572f36871e045567675d6166e93d55c86afee92a6fba4e01e370f980fbd385d77
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,30 @@
|
|
1
|
+
## [0.37.6]
|
2
|
+
|
3
|
+
* Adds support for disabling and fetching the status of Real-Time Scheduling links [#100]
|
4
|
+
|
5
|
+
## [0.37.5]
|
6
|
+
|
7
|
+
* Support `query_periods` as well as the original `available_periods` for Real-Time Scheduling and Real-Time Sequencing [#99]
|
8
|
+
|
9
|
+
## [0.37.4]
|
10
|
+
|
11
|
+
* Support client_secret only clients being able to authorize `#availability` calls. [#97]
|
12
|
+
|
1
13
|
## [0.37.3]
|
2
14
|
|
3
|
-
* Support `hmac_valid` as well as the original `hmac_match` for Client to verify a HMAC from a push notification using the client's secret.[#95]
|
15
|
+
* Support `hmac_valid` as well as the original `hmac_match` for Client to verify a HMAC from a push notification using the client's secret.[#95]
|
4
16
|
|
5
17
|
## [0.37.2]
|
6
18
|
|
7
|
-
* Support `query_periods` as well as the original `available_periods` for Availability Query and Sequenced Availability [#91]
|
19
|
+
* Support `query_periods` as well as the original `available_periods` for Availability Query and Sequenced Availability [#91]
|
8
20
|
|
9
21
|
## [0.37.1]
|
10
22
|
|
11
|
-
* Rename `data_centre` to `data_centre` (with aliases for backwards compatibility) [#90]
|
23
|
+
* Rename `data_centre` to `data_centre` (with aliases for backwards compatibility) [#90]
|
12
24
|
|
13
25
|
## [0.37.0]
|
14
26
|
|
15
|
-
* Add `revoke_by_token` and `revoke_by_sub` to the Client [#86]
|
27
|
+
* Add `revoke_by_token` and `revoke_by_sub` to the Client [#86]
|
16
28
|
|
17
29
|
## [0.36.1]
|
18
30
|
|
@@ -192,6 +204,9 @@
|
|
192
204
|
[0.37.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.1
|
193
205
|
[0.37.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.2
|
194
206
|
[0.37.3]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.3
|
207
|
+
[0.37.4]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.4
|
208
|
+
[0.37.5]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.5
|
209
|
+
[0.37.6]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.6
|
195
210
|
|
196
211
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
197
212
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -237,3 +252,6 @@
|
|
237
252
|
[#90]: https://github.com/cronofy/cronofy-ruby/pull/90
|
238
253
|
[#91]: https://github.com/cronofy/cronofy-ruby/pull/91
|
239
254
|
[#95]: https://github.com/cronofy/cronofy-ruby/pull/95
|
255
|
+
[#97]: https://github.com/cronofy/cronofy-ruby/pull/97
|
256
|
+
[#99]: https://github.com/cronofy/cronofy-ruby/pull/99
|
257
|
+
[#100]: https://github.com/cronofy/cronofy-ruby/pull/100
|
data/lib/cronofy/client.rb
CHANGED
@@ -844,7 +844,7 @@ module Cronofy
|
|
844
844
|
|
845
845
|
translate_available_periods(options[:query_periods] || options[:available_periods])
|
846
846
|
|
847
|
-
response =
|
847
|
+
response = availability_post("/v1/availability", options)
|
848
848
|
|
849
849
|
parse_collections(
|
850
850
|
response,
|
@@ -889,7 +889,7 @@ module Cronofy
|
|
889
889
|
|
890
890
|
translate_available_periods(options[:query_periods] || options[:available_periods])
|
891
891
|
|
892
|
-
response =
|
892
|
+
response = availability_post("/v1/sequenced_availability", options)
|
893
893
|
parse_collection(Sequence, "sequences", response)
|
894
894
|
end
|
895
895
|
|
@@ -1033,7 +1033,7 @@ module Cronofy
|
|
1033
1033
|
# call
|
1034
1034
|
# :required_duration - A hash stating the length of time the event will
|
1035
1035
|
# last for
|
1036
|
-
# :
|
1036
|
+
# :query_periods - A hash stating the available periods for the event
|
1037
1037
|
# :start_interval - An Integer representing the start interval
|
1038
1038
|
# of minutes for the availability query.
|
1039
1039
|
# :buffer - An Hash containing the buffer to apply to
|
@@ -1069,7 +1069,7 @@ module Cronofy
|
|
1069
1069
|
# }
|
1070
1070
|
# ],
|
1071
1071
|
# required_duration: { minutes: 60 },
|
1072
|
-
#
|
1072
|
+
# query_periods: [{
|
1073
1073
|
# start: Time.utc(2017, 1, 1, 9, 00),
|
1074
1074
|
# end: Time.utc(2017, 1, 1, 17, 00),
|
1075
1075
|
# }]
|
@@ -1110,13 +1110,66 @@ module Cronofy
|
|
1110
1110
|
end
|
1111
1111
|
end
|
1112
1112
|
|
1113
|
-
translate_available_periods(availability[:available_periods])
|
1113
|
+
translate_available_periods(availability[:query_periods] || availability[:available_periods])
|
1114
1114
|
body[:availability] = availability
|
1115
1115
|
|
1116
1116
|
response = raw_post("/v1/real_time_scheduling", body)
|
1117
1117
|
parse_json(AddToCalendarResponse, nil , response)
|
1118
1118
|
end
|
1119
1119
|
|
1120
|
+
# Public: Gets the status of a Real-Time Scheduling link.
|
1121
|
+
#
|
1122
|
+
# Provide one of the following arguments to identify the link:
|
1123
|
+
# id - A String uniquely identifying the link, returned on initial
|
1124
|
+
# creation
|
1125
|
+
# token - The token portion of the link's URL
|
1126
|
+
#
|
1127
|
+
# See https://docs.cronofy.com/developers/api/scheduling/real-time-scheduling/status/ for reference.
|
1128
|
+
#
|
1129
|
+
# Returns a RealTimeSchedulingStatus.
|
1130
|
+
#
|
1131
|
+
# Raises ArgumentError if neither 'id' nor 'token' arguments are passed.
|
1132
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1133
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1134
|
+
# limits for the application.
|
1135
|
+
def get_real_time_scheduling_status(args = {})
|
1136
|
+
if args[:token]
|
1137
|
+
url = "/v1/real_time_scheduling?token=#{args[:token]}"
|
1138
|
+
elsif args[:id]
|
1139
|
+
url = "/v1/real_time_scheduling/#{args[:id]}"
|
1140
|
+
else
|
1141
|
+
raise ArgumentError.new("Must pass either token or id argument")
|
1142
|
+
end
|
1143
|
+
|
1144
|
+
response = wrapped_request { api_key!.get(url) }
|
1145
|
+
parse_json(RealTimeSchedulingStatus, 'real_time_scheduling' , response)
|
1146
|
+
end
|
1147
|
+
|
1148
|
+
# Public: Disables a Real-Time Scheduling link.
|
1149
|
+
#
|
1150
|
+
# id - A String uniquely identifying the link, returned
|
1151
|
+
# on initial creation
|
1152
|
+
# display_message - A message to display to visitors of the disabled link
|
1153
|
+
#
|
1154
|
+
# See https://docs.cronofy.com/developers/api/scheduling/real-time-scheduling/disable/ for reference.
|
1155
|
+
#
|
1156
|
+
# Returns a RealTimeSchedulingStatus.
|
1157
|
+
#
|
1158
|
+
# Raises ArgumentError if no 'id' argument is passed.
|
1159
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1160
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1161
|
+
# parameters.
|
1162
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1163
|
+
# limits for the application.
|
1164
|
+
def disable_real_time_scheduling(args = {})
|
1165
|
+
id = args.delete(:id)
|
1166
|
+
|
1167
|
+
raise ArgumentError.new('id argument is required') unless id
|
1168
|
+
|
1169
|
+
response = wrapped_request { api_key!.post("/v1/real_time_scheduling/#{id}/disable", json_request_args(args)) }
|
1170
|
+
parse_json(RealTimeSchedulingStatus, 'real_time_scheduling' , response)
|
1171
|
+
end
|
1172
|
+
|
1120
1173
|
# Public: Generates an real time sequencing link to start the OAuth process with
|
1121
1174
|
# an event to be automatically upserted
|
1122
1175
|
#
|
@@ -1176,7 +1229,7 @@ module Cronofy
|
|
1176
1229
|
# an array of invitees to invite to or reject from
|
1177
1230
|
# the event. Invitees are represented by a hash of
|
1178
1231
|
# :email and :display_name (optional).
|
1179
|
-
# :
|
1232
|
+
# :query_periods - A hash stating the query periods for the event
|
1180
1233
|
# target_calendars - An array of hashes stating into which calendars to insert the created
|
1181
1234
|
# event
|
1182
1235
|
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
@@ -1194,7 +1247,8 @@ module Cronofy
|
|
1194
1247
|
|
1195
1248
|
if availability = args[:availability]
|
1196
1249
|
availability[:sequence] = map_availability_sequence(availability[:sequence])
|
1197
|
-
|
1250
|
+
periods = availability[:query_periods] || availability[:available_periods]
|
1251
|
+
translate_available_periods(periods) if periods
|
1198
1252
|
end
|
1199
1253
|
|
1200
1254
|
body[:availability] = availability
|
@@ -1748,8 +1802,10 @@ module Cronofy
|
|
1748
1802
|
hash[:required_duration] = map_availability_required_duration(value)
|
1749
1803
|
end
|
1750
1804
|
|
1751
|
-
|
1752
|
-
|
1805
|
+
periods = sequence_item[:query_periods] || sequence_item[:available_periods]
|
1806
|
+
|
1807
|
+
if periods
|
1808
|
+
translate_available_periods(periods)
|
1753
1809
|
end
|
1754
1810
|
|
1755
1811
|
if value = sequence_item[:start_interval]
|
@@ -1811,6 +1867,17 @@ module Cronofy
|
|
1811
1867
|
wrapped_request { @auth.api_client.request(:post, url, json_request_args(body)) }
|
1812
1868
|
end
|
1813
1869
|
|
1870
|
+
# Availability Query could originally be authenticated via an access_token
|
1871
|
+
# Whilst it should be authed via an API key now, we try access_token first
|
1872
|
+
# for backward compatibility
|
1873
|
+
def availability_post(url, body)
|
1874
|
+
if @auth.access_token
|
1875
|
+
post(url, body)
|
1876
|
+
else
|
1877
|
+
wrapped_request { api_key!.post(url, json_request_args(body)) }
|
1878
|
+
end
|
1879
|
+
end
|
1880
|
+
|
1814
1881
|
def wrapped_request
|
1815
1882
|
yield
|
1816
1883
|
rescue OAuth2::Error => e
|
data/lib/cronofy/types.rb
CHANGED
data/lib/cronofy/version.rb
CHANGED
@@ -1257,6 +1257,17 @@ describe Cronofy::Client do
|
|
1257
1257
|
let(:request_url) { 'https://api.cronofy.com/v1/availability' }
|
1258
1258
|
let(:request_headers) { json_request_headers }
|
1259
1259
|
|
1260
|
+
let(:client_id) { 'example_id' }
|
1261
|
+
let(:client_secret) { 'example_secret' }
|
1262
|
+
let(:token) { client_secret }
|
1263
|
+
|
1264
|
+
let(:client) do
|
1265
|
+
Cronofy::Client.new(
|
1266
|
+
client_id: client_id,
|
1267
|
+
client_secret: client_secret,
|
1268
|
+
)
|
1269
|
+
end
|
1270
|
+
|
1260
1271
|
let(:request_body) do
|
1261
1272
|
{
|
1262
1273
|
"participants" => [
|
@@ -1770,6 +1781,87 @@ describe Cronofy::Client do
|
|
1770
1781
|
it_behaves_like 'a Cronofy request'
|
1771
1782
|
it_behaves_like 'a Cronofy request with mapped return value'
|
1772
1783
|
end
|
1784
|
+
|
1785
|
+
context "when trying to auth with only an access_token, as originally implemented" do
|
1786
|
+
let(:access_token) { "access_token_123"}
|
1787
|
+
let(:client) { Cronofy::Client.new(access_token: access_token) }
|
1788
|
+
let(:request_headers) do
|
1789
|
+
{
|
1790
|
+
"Authorization" => "Bearer #{access_token}",
|
1791
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
1792
|
+
"Content-Type" => "application/json; charset=utf-8",
|
1793
|
+
}
|
1794
|
+
end
|
1795
|
+
|
1796
|
+
let(:participants) do
|
1797
|
+
{ members: %w{acc_567236000909002 acc_678347111010113} }
|
1798
|
+
end
|
1799
|
+
|
1800
|
+
let(:required_duration) { 60 }
|
1801
|
+
|
1802
|
+
let(:available_periods) do
|
1803
|
+
[
|
1804
|
+
{ start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T18:00:00Z") },
|
1805
|
+
{ start: Time.parse("2017-01-04T09:00:00Z"), end: Time.parse("2017-01-04T18:00:00Z") },
|
1806
|
+
]
|
1807
|
+
end
|
1808
|
+
|
1809
|
+
it_behaves_like 'a Cronofy request'
|
1810
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
1811
|
+
end
|
1812
|
+
|
1813
|
+
context "when trying to auth with both a client_secret and access_token" do
|
1814
|
+
let(:access_token) { "access_token_123" }
|
1815
|
+
let(:client_secret) { "client_secret_456" }
|
1816
|
+
let(:client) { Cronofy::Client.new(access_token: access_token, client_secret: client_secret) }
|
1817
|
+
let(:request_headers) do
|
1818
|
+
{
|
1819
|
+
"Authorization" => "Bearer #{access_token}",
|
1820
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
1821
|
+
"Content-Type" => "application/json; charset=utf-8",
|
1822
|
+
}
|
1823
|
+
end
|
1824
|
+
|
1825
|
+
let(:participants) do
|
1826
|
+
{ members: %w{acc_567236000909002 acc_678347111010113} }
|
1827
|
+
end
|
1828
|
+
|
1829
|
+
let(:required_duration) { 60 }
|
1830
|
+
|
1831
|
+
let(:available_periods) do
|
1832
|
+
[
|
1833
|
+
{ start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T18:00:00Z") },
|
1834
|
+
{ start: Time.parse("2017-01-04T09:00:00Z"), end: Time.parse("2017-01-04T18:00:00Z") },
|
1835
|
+
]
|
1836
|
+
end
|
1837
|
+
|
1838
|
+
describe "it prefers the access_token for backward compatibility" do
|
1839
|
+
it_behaves_like 'a Cronofy request'
|
1840
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
1841
|
+
end
|
1842
|
+
end
|
1843
|
+
|
1844
|
+
context "when trying to auth without a client_secret or access_token" do
|
1845
|
+
let(:client) { Cronofy::Client.new }
|
1846
|
+
|
1847
|
+
let(:participants) do
|
1848
|
+
{ members: %w{acc_567236000909002 acc_678347111010113} }
|
1849
|
+
end
|
1850
|
+
|
1851
|
+
let(:required_duration) { 60 }
|
1852
|
+
|
1853
|
+
let(:available_periods) do
|
1854
|
+
[
|
1855
|
+
{ start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T18:00:00Z") },
|
1856
|
+
{ start: Time.parse("2017-01-04T09:00:00Z"), end: Time.parse("2017-01-04T18:00:00Z") },
|
1857
|
+
]
|
1858
|
+
end
|
1859
|
+
|
1860
|
+
|
1861
|
+
it "raises an API Key error" do
|
1862
|
+
expect{ subject }.to raise_error(Cronofy::CredentialsMissingError)
|
1863
|
+
end
|
1864
|
+
end
|
1773
1865
|
end
|
1774
1866
|
end
|
1775
1867
|
|
@@ -1779,6 +1871,17 @@ describe Cronofy::Client do
|
|
1779
1871
|
let(:request_url) { 'https://api.cronofy.com/v1/sequenced_availability' }
|
1780
1872
|
let(:request_headers) { json_request_headers }
|
1781
1873
|
|
1874
|
+
let(:client_id) { 'example_id' }
|
1875
|
+
let(:client_secret) { 'example_secret' }
|
1876
|
+
let(:token) { client_secret }
|
1877
|
+
|
1878
|
+
let(:client) do
|
1879
|
+
Cronofy::Client.new(
|
1880
|
+
client_id: client_id,
|
1881
|
+
client_secret: client_secret,
|
1882
|
+
)
|
1883
|
+
end
|
1884
|
+
|
1782
1885
|
let(:request_body) do
|
1783
1886
|
{
|
1784
1887
|
"sequence" => [
|
@@ -1937,6 +2040,45 @@ describe Cronofy::Client do
|
|
1937
2040
|
it_behaves_like 'a Cronofy request'
|
1938
2041
|
it_behaves_like 'a Cronofy request with mapped return value'
|
1939
2042
|
end
|
2043
|
+
|
2044
|
+
context "when trying to auth with access_token only" do
|
2045
|
+
let(:access_token) { "access_token_123"}
|
2046
|
+
let(:client) { Cronofy::Client.new(access_token: access_token) }
|
2047
|
+
let(:request_headers) do
|
2048
|
+
{
|
2049
|
+
"Authorization" => "Bearer #{access_token}",
|
2050
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2051
|
+
"Content-Type" => "application/json; charset=utf-8",
|
2052
|
+
}
|
2053
|
+
end
|
2054
|
+
|
2055
|
+
it_behaves_like 'a Cronofy request'
|
2056
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2057
|
+
end
|
2058
|
+
|
2059
|
+
context "when trying to auth with both access_token and client_secret provided" do
|
2060
|
+
let(:client_id) { 'example_id' }
|
2061
|
+
let(:client_secret) { 'example_secret' }
|
2062
|
+
let(:access_token) { "access_token_123"}
|
2063
|
+
|
2064
|
+
let(:client) do
|
2065
|
+
Cronofy::Client.new(
|
2066
|
+
client_id: client_id,
|
2067
|
+
client_secret: client_secret,
|
2068
|
+
access_token: access_token,
|
2069
|
+
)
|
2070
|
+
end
|
2071
|
+
let(:request_headers) do
|
2072
|
+
{
|
2073
|
+
"Authorization" => "Bearer #{access_token}",
|
2074
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2075
|
+
"Content-Type" => "application/json; charset=utf-8",
|
2076
|
+
}
|
2077
|
+
end
|
2078
|
+
|
2079
|
+
it_behaves_like 'a Cronofy request'
|
2080
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2081
|
+
end
|
1940
2082
|
end
|
1941
2083
|
end
|
1942
2084
|
|
@@ -2048,25 +2190,8 @@ describe Cronofy::Client do
|
|
2048
2190
|
end
|
2049
2191
|
|
2050
2192
|
describe "Real time scheduling" do
|
2051
|
-
let(:request_url) { "https://api.cronofy.com/v1/real_time_scheduling" }
|
2052
|
-
let(:url) { URI("https://example.com") }
|
2053
|
-
let(:method) { :post }
|
2054
|
-
|
2055
|
-
let(:request_headers) do
|
2056
|
-
{
|
2057
|
-
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2058
|
-
"Content-Type" => "application/json; charset=utf-8",
|
2059
|
-
}
|
2060
|
-
end
|
2061
|
-
|
2062
|
-
let(:location) { { :description => "Board room" } }
|
2063
|
-
let(:transparency) { nil }
|
2064
2193
|
let(:client_id) { 'example_id' }
|
2065
2194
|
let(:client_secret) { 'example_secret' }
|
2066
|
-
let(:scope) { 'read_events delete_events' }
|
2067
|
-
let(:state) { 'example_state' }
|
2068
|
-
let(:redirect_uri) { 'http://example.com/redirect' }
|
2069
|
-
|
2070
2195
|
let(:client) do
|
2071
2196
|
Cronofy::Client.new(
|
2072
2197
|
client_id: client_id,
|
@@ -2074,6 +2199,9 @@ describe Cronofy::Client do
|
|
2074
2199
|
)
|
2075
2200
|
end
|
2076
2201
|
|
2202
|
+
let(:url) { URI("https://example.com") }
|
2203
|
+
let(:location) { { :description => "Board room" } }
|
2204
|
+
let(:transparency) { nil }
|
2077
2205
|
let(:event) do
|
2078
2206
|
{
|
2079
2207
|
:event_id => "qTtZdczOccgaPncGJaCiLg",
|
@@ -2090,115 +2218,253 @@ describe Cronofy::Client do
|
|
2090
2218
|
}
|
2091
2219
|
end
|
2092
2220
|
|
2093
|
-
let(:
|
2221
|
+
let(:real_time_scheduling_status_response) do
|
2094
2222
|
{
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2223
|
+
real_time_scheduling: {
|
2224
|
+
real_time_scheduling_id: 'example_id',
|
2225
|
+
url: 'https://app.cronofy.com/real_time_scheduling/example_token',
|
2226
|
+
event: event,
|
2227
|
+
status: 'disabled',
|
2228
|
+
}
|
2098
2229
|
}
|
2099
2230
|
end
|
2100
2231
|
|
2101
|
-
|
2102
|
-
|
2232
|
+
describe "#real_time_scheduling" do
|
2233
|
+
let(:request_url) { "https://api.cronofy.com/v1/real_time_scheduling" }
|
2234
|
+
|
2235
|
+
let(:method) { :post }
|
2236
|
+
|
2237
|
+
let(:request_headers) do
|
2103
2238
|
{
|
2104
|
-
|
2105
|
-
|
2239
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2240
|
+
"Content-Type" => "application/json; charset=utf-8",
|
2106
2241
|
}
|
2107
|
-
|
2108
|
-
end
|
2242
|
+
end
|
2109
2243
|
|
2110
|
-
|
2111
|
-
{
|
2112
|
-
|
2244
|
+
let(:scope) { 'read_events delete_events' }
|
2245
|
+
let(:state) { 'example_state' }
|
2246
|
+
let(:redirect_uri) { 'http://example.com/redirect' }
|
2247
|
+
|
2248
|
+
let(:oauth_body) do
|
2249
|
+
{
|
2250
|
+
scope: scope,
|
2251
|
+
redirect_uri: redirect_uri,
|
2252
|
+
state: state,
|
2253
|
+
}
|
2254
|
+
end
|
2255
|
+
|
2256
|
+
let(:target_calendars) do
|
2257
|
+
[
|
2113
2258
|
{
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2259
|
+
sub: "acc_567236000909002",
|
2260
|
+
calendar_id: "cal_n23kjnwrw2_jsdfjksn234",
|
2261
|
+
}
|
2262
|
+
]
|
2263
|
+
end
|
2264
|
+
|
2265
|
+
let(:availability) do
|
2266
|
+
{
|
2267
|
+
participants: [
|
2268
|
+
{
|
2269
|
+
members: [{
|
2270
|
+
sub: "acc_567236000909002",
|
2271
|
+
calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
|
2272
|
+
}],
|
2273
|
+
required: 'all'
|
2274
|
+
}
|
2275
|
+
],
|
2276
|
+
required_duration: { minutes: 60 },
|
2277
|
+
available_periods: [{
|
2278
|
+
start: Time.utc(2017, 1, 1, 9, 00),
|
2279
|
+
end: Time.utc(2017, 1, 1, 17, 00),
|
2280
|
+
}],
|
2281
|
+
start_interval: { minutes: 60 },
|
2282
|
+
buffer: {
|
2283
|
+
before: { minutes: 30 },
|
2284
|
+
after: { minutes: 45 },
|
2119
2285
|
}
|
2120
|
-
],
|
2121
|
-
required_duration: { minutes: 60 },
|
2122
|
-
available_periods: [{
|
2123
|
-
start: Time.utc(2017, 1, 1, 9, 00),
|
2124
|
-
end: Time.utc(2017, 1, 1, 17, 00),
|
2125
|
-
}],
|
2126
|
-
start_interval: { minutes: 60 },
|
2127
|
-
buffer: {
|
2128
|
-
before: { minutes: 30 },
|
2129
|
-
after: { minutes: 45 },
|
2130
2286
|
}
|
2131
|
-
|
2287
|
+
end
|
2288
|
+
|
2289
|
+
let(:mapped_availability) do
|
2290
|
+
{
|
2291
|
+
participants: [
|
2292
|
+
{
|
2293
|
+
members: [{
|
2294
|
+
sub: "acc_567236000909002",
|
2295
|
+
calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
|
2296
|
+
}],
|
2297
|
+
required: 'all'
|
2298
|
+
}
|
2299
|
+
],
|
2300
|
+
required_duration: { minutes: 60 },
|
2301
|
+
start_interval: { minutes: 60 },
|
2302
|
+
buffer: {
|
2303
|
+
before: { minutes: 30 },
|
2304
|
+
after: { minutes: 45 },
|
2305
|
+
},
|
2306
|
+
available_periods: [{
|
2307
|
+
start: "2017-01-01T09:00:00Z",
|
2308
|
+
end: "2017-01-01T17:00:00Z",
|
2309
|
+
}]
|
2310
|
+
}
|
2311
|
+
end
|
2312
|
+
|
2313
|
+
let(:args) do
|
2314
|
+
{
|
2315
|
+
oauth: oauth_body,
|
2316
|
+
event: event,
|
2317
|
+
target_calendars: target_calendars,
|
2318
|
+
availability: availability,
|
2319
|
+
}
|
2320
|
+
end
|
2321
|
+
|
2322
|
+
let(:request_body) do
|
2323
|
+
{
|
2324
|
+
client_id: client_id,
|
2325
|
+
client_secret: client_secret,
|
2326
|
+
oauth: oauth_body,
|
2327
|
+
event: {
|
2328
|
+
:event_id => "qTtZdczOccgaPncGJaCiLg",
|
2329
|
+
:summary => "Board meeting",
|
2330
|
+
:description => "Discuss plans for the next quarter.",
|
2331
|
+
:url => url.to_s,
|
2332
|
+
:location => location,
|
2333
|
+
:transparency => transparency,
|
2334
|
+
:reminders => [
|
2335
|
+
{ :minutes => 60 },
|
2336
|
+
{ :minutes => 0 },
|
2337
|
+
{ :minutes => 10 },
|
2338
|
+
],
|
2339
|
+
},
|
2340
|
+
target_calendars: target_calendars,
|
2341
|
+
availability: mapped_availability,
|
2342
|
+
}
|
2343
|
+
end
|
2344
|
+
let(:correct_response_code) { 202 }
|
2345
|
+
let(:correct_response_body) do
|
2346
|
+
{
|
2347
|
+
oauth_url: "http://www.example.com/oauth?token=example"
|
2348
|
+
}
|
2349
|
+
end
|
2350
|
+
|
2351
|
+
subject { client.real_time_scheduling(args) }
|
2352
|
+
|
2353
|
+
context 'when start/end are Times' do
|
2354
|
+
it_behaves_like 'a Cronofy request'
|
2355
|
+
end
|
2356
|
+
|
2357
|
+
context 'when passing query periods' do
|
2358
|
+
it_behaves_like 'a Cronofy request'
|
2359
|
+
|
2360
|
+
before do
|
2361
|
+
availability[:query_periods] = availability.delete(:available_periods)
|
2362
|
+
mapped_availability[:query_periods] = mapped_availability.delete(:available_periods)
|
2363
|
+
end
|
2364
|
+
end
|
2132
2365
|
end
|
2133
2366
|
|
2134
|
-
|
2135
|
-
{
|
2136
|
-
|
2367
|
+
describe "#get_real_time_scheduling_status" do
|
2368
|
+
let(:request_url) { "https://api.cronofy.com/v1/real_time_scheduling" }
|
2369
|
+
let(:method) { :get }
|
2370
|
+
let(:url) { "https://example.com" }
|
2371
|
+
let(:request_headers) do
|
2372
|
+
{
|
2373
|
+
"Authorization" => "Bearer #{client_secret}",
|
2374
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2375
|
+
"Accept" => "*/*",
|
2376
|
+
"Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3",
|
2377
|
+
}
|
2378
|
+
end
|
2379
|
+
let(:correct_response_code) { 200 }
|
2380
|
+
let(:correct_response_body) { real_time_scheduling_status_response }
|
2381
|
+
let(:correct_mapped_result) do
|
2382
|
+
Cronofy::RealTimeSchedulingStatus.new(correct_response_body[:real_time_scheduling])
|
2383
|
+
end
|
2384
|
+
|
2385
|
+
subject { client.get_real_time_scheduling_status(args) }
|
2386
|
+
|
2387
|
+
context 'when passing id' do
|
2388
|
+
let(:request_url) { "https://api.cronofy.com/v1/real_time_scheduling/example_id" }
|
2389
|
+
|
2390
|
+
let(:args) do
|
2137
2391
|
{
|
2138
|
-
|
2139
|
-
sub: "acc_567236000909002",
|
2140
|
-
calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
|
2141
|
-
}],
|
2142
|
-
required: 'all'
|
2392
|
+
id: 'example_id'
|
2143
2393
|
}
|
2144
|
-
|
2145
|
-
required_duration: { minutes: 60 },
|
2146
|
-
start_interval: { minutes: 60 },
|
2147
|
-
buffer: {
|
2148
|
-
before: { minutes: 30 },
|
2149
|
-
after: { minutes: 45 },
|
2150
|
-
},
|
2151
|
-
available_periods: [{
|
2152
|
-
start: "2017-01-01T09:00:00Z",
|
2153
|
-
end: "2017-01-01T17:00:00Z",
|
2154
|
-
}]
|
2155
|
-
}
|
2156
|
-
end
|
2394
|
+
end
|
2157
2395
|
|
2158
|
-
|
2159
|
-
|
2160
|
-
|
2161
|
-
event: event,
|
2162
|
-
target_calendars: target_calendars,
|
2163
|
-
availability: availability,
|
2164
|
-
}
|
2165
|
-
end
|
2396
|
+
it_behaves_like 'a Cronofy request'
|
2397
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2398
|
+
end
|
2166
2399
|
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
2170
|
-
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
2176
|
-
|
2177
|
-
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
2182
|
-
|
2183
|
-
|
2184
|
-
|
2185
|
-
target_calendars: target_calendars,
|
2186
|
-
availability: mapped_availability,
|
2187
|
-
}
|
2188
|
-
end
|
2189
|
-
let(:correct_response_code) { 202 }
|
2190
|
-
let(:correct_response_body) do
|
2191
|
-
{
|
2192
|
-
oauth_url: "http://www.example.com/oauth?token=example"
|
2193
|
-
}
|
2400
|
+
context 'when passing token' do
|
2401
|
+
let(:request_url) { "https://api.cronofy.com/v1/real_time_scheduling?token=example_token" }
|
2402
|
+
let(:args) do
|
2403
|
+
{
|
2404
|
+
token: 'example_token'
|
2405
|
+
}
|
2406
|
+
end
|
2407
|
+
|
2408
|
+
it_behaves_like 'a Cronofy request'
|
2409
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2410
|
+
end
|
2411
|
+
|
2412
|
+
context 'when passing neither id nor token' do
|
2413
|
+
let(:args) { Hash.new }
|
2414
|
+
it 'raises an ArgumentError' do
|
2415
|
+
expect { subject }.to raise_error(ArgumentError)
|
2416
|
+
end
|
2417
|
+
end
|
2194
2418
|
end
|
2195
2419
|
|
2196
|
-
|
2420
|
+
describe "#disable_real_time_scheduling" do
|
2421
|
+
let(:request_url) { "https://api.cronofy.com/v1/real_time_scheduling/example_id/disable" }
|
2422
|
+
let(:url) { "https://example.com" }
|
2423
|
+
let(:method) { :post }
|
2424
|
+
let(:request_headers) do
|
2425
|
+
{
|
2426
|
+
"Authorization" => "Bearer #{client_secret}",
|
2427
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2428
|
+
"Content-Type" => "application/json; charset=utf-8",
|
2429
|
+
}
|
2430
|
+
end
|
2431
|
+
|
2432
|
+
let(:args) do
|
2433
|
+
{
|
2434
|
+
id: 'example_id',
|
2435
|
+
display_message: 'example message'
|
2436
|
+
}
|
2437
|
+
end
|
2438
|
+
|
2439
|
+
let(:request_body) do
|
2440
|
+
{
|
2441
|
+
display_message: 'example message'
|
2442
|
+
}
|
2443
|
+
end
|
2444
|
+
|
2445
|
+
let(:correct_response_code) { 200 }
|
2446
|
+
let(:correct_response_body) { real_time_scheduling_status_response }
|
2447
|
+
let(:correct_mapped_result) do
|
2448
|
+
Cronofy::RealTimeSchedulingStatus.new(correct_response_body[:real_time_scheduling])
|
2449
|
+
end
|
2450
|
+
|
2451
|
+
subject { client.disable_real_time_scheduling(args) }
|
2197
2452
|
|
2198
|
-
context 'when start/end are Times' do
|
2199
2453
|
it_behaves_like 'a Cronofy request'
|
2200
|
-
|
2454
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2201
2455
|
|
2456
|
+
context 'when omitting id argument' do
|
2457
|
+
let(:args) do
|
2458
|
+
{
|
2459
|
+
display_message: 'example message'
|
2460
|
+
}
|
2461
|
+
end
|
2462
|
+
|
2463
|
+
it 'raises an ArgumentError' do
|
2464
|
+
expect { subject }.to raise_error(ArgumentError)
|
2465
|
+
end
|
2466
|
+
end
|
2467
|
+
end
|
2202
2468
|
end
|
2203
2469
|
|
2204
2470
|
describe "Real time sequencing" do
|
@@ -2387,6 +2653,21 @@ describe Cronofy::Client do
|
|
2387
2653
|
it_behaves_like 'a Cronofy request'
|
2388
2654
|
end
|
2389
2655
|
|
2656
|
+
context 'when passing query periods' do
|
2657
|
+
it_behaves_like 'a Cronofy request'
|
2658
|
+
|
2659
|
+
before do
|
2660
|
+
availability[:query_periods] = availability.delete(:available_periods)
|
2661
|
+
availability[:sequence].each do |sequence|
|
2662
|
+
sequence[:query_periods] = sequence.delete(:available_periods)
|
2663
|
+
end
|
2664
|
+
|
2665
|
+
mapped_availability[:query_periods] = mapped_availability.delete(:available_periods)
|
2666
|
+
mapped_availability[:sequence].each do |sequence|
|
2667
|
+
sequence[:query_periods] = sequence.delete(:available_periods)
|
2668
|
+
end
|
2669
|
+
end
|
2670
|
+
end
|
2390
2671
|
end
|
2391
2672
|
|
2392
2673
|
describe "specifying data_centre" do
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.37.
|
4
|
+
version: 0.37.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergii Paryzhskyi
|
8
8
|
- Garry Shutler
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -141,7 +141,7 @@ homepage: https://github.com/cronofy/cronofy-ruby
|
|
141
141
|
licenses:
|
142
142
|
- MIT
|
143
143
|
metadata: {}
|
144
|
-
post_install_message:
|
144
|
+
post_install_message:
|
145
145
|
rdoc_options: []
|
146
146
|
require_paths:
|
147
147
|
- lib
|
@@ -156,8 +156,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
160
|
-
signing_key:
|
159
|
+
rubygems_version: 3.3.8
|
160
|
+
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Cronofy - the scheduling platform for business
|
163
163
|
test_files:
|