cronofy 0.37.5 → 0.37.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/cronofy/client.rb +53 -0
- data/lib/cronofy/types.rb +4 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +226 -110
- metadata +3 -3
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,3 +1,7 @@
|
|
1
|
+
## [0.37.6]
|
2
|
+
|
3
|
+
* Adds support for disabling and fetching the status of Real-Time Scheduling links [#100]
|
4
|
+
|
1
5
|
## [0.37.5]
|
2
6
|
|
3
7
|
* Support `query_periods` as well as the original `available_periods` for Real-Time Scheduling and Real-Time Sequencing [#99]
|
@@ -202,6 +206,7 @@
|
|
202
206
|
[0.37.3]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.3
|
203
207
|
[0.37.4]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.4
|
204
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
|
205
210
|
|
206
211
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
207
212
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -249,3 +254,4 @@
|
|
249
254
|
[#95]: https://github.com/cronofy/cronofy-ruby/pull/95
|
250
255
|
[#97]: https://github.com/cronofy/cronofy-ruby/pull/97
|
251
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
@@ -1117,6 +1117,59 @@ module Cronofy
|
|
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
|
#
|
data/lib/cronofy/types.rb
CHANGED
data/lib/cronofy/version.rb
CHANGED
@@ -2190,25 +2190,8 @@ describe Cronofy::Client do
|
|
2190
2190
|
end
|
2191
2191
|
|
2192
2192
|
describe "Real time scheduling" do
|
2193
|
-
let(:request_url) { "https://api.cronofy.com/v1/real_time_scheduling" }
|
2194
|
-
let(:url) { URI("https://example.com") }
|
2195
|
-
let(:method) { :post }
|
2196
|
-
|
2197
|
-
let(:request_headers) do
|
2198
|
-
{
|
2199
|
-
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2200
|
-
"Content-Type" => "application/json; charset=utf-8",
|
2201
|
-
}
|
2202
|
-
end
|
2203
|
-
|
2204
|
-
let(:location) { { :description => "Board room" } }
|
2205
|
-
let(:transparency) { nil }
|
2206
2193
|
let(:client_id) { 'example_id' }
|
2207
2194
|
let(:client_secret) { 'example_secret' }
|
2208
|
-
let(:scope) { 'read_events delete_events' }
|
2209
|
-
let(:state) { 'example_state' }
|
2210
|
-
let(:redirect_uri) { 'http://example.com/redirect' }
|
2211
|
-
|
2212
2195
|
let(:client) do
|
2213
2196
|
Cronofy::Client.new(
|
2214
2197
|
client_id: client_id,
|
@@ -2216,6 +2199,9 @@ describe Cronofy::Client do
|
|
2216
2199
|
)
|
2217
2200
|
end
|
2218
2201
|
|
2202
|
+
let(:url) { URI("https://example.com") }
|
2203
|
+
let(:location) { { :description => "Board room" } }
|
2204
|
+
let(:transparency) { nil }
|
2219
2205
|
let(:event) do
|
2220
2206
|
{
|
2221
2207
|
:event_id => "qTtZdczOccgaPncGJaCiLg",
|
@@ -2232,121 +2218,251 @@ describe Cronofy::Client do
|
|
2232
2218
|
}
|
2233
2219
|
end
|
2234
2220
|
|
2235
|
-
let(:
|
2221
|
+
let(:real_time_scheduling_status_response) do
|
2236
2222
|
{
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
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
|
+
}
|
2240
2229
|
}
|
2241
2230
|
end
|
2242
2231
|
|
2243
|
-
|
2244
|
-
|
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
|
2245
2238
|
{
|
2246
|
-
|
2247
|
-
|
2239
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2240
|
+
"Content-Type" => "application/json; charset=utf-8",
|
2248
2241
|
}
|
2249
|
-
|
2250
|
-
end
|
2242
|
+
end
|
2251
2243
|
|
2252
|
-
|
2253
|
-
{
|
2254
|
-
|
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
|
+
[
|
2255
2258
|
{
|
2256
|
-
|
2257
|
-
|
2258
|
-
|
2259
|
-
|
2260
|
-
|
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 },
|
2261
2285
|
}
|
2262
|
-
],
|
2263
|
-
required_duration: { minutes: 60 },
|
2264
|
-
available_periods: [{
|
2265
|
-
start: Time.utc(2017, 1, 1, 9, 00),
|
2266
|
-
end: Time.utc(2017, 1, 1, 17, 00),
|
2267
|
-
}],
|
2268
|
-
start_interval: { minutes: 60 },
|
2269
|
-
buffer: {
|
2270
|
-
before: { minutes: 30 },
|
2271
|
-
after: { minutes: 45 },
|
2272
2286
|
}
|
2273
|
-
|
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
|
2274
2365
|
end
|
2275
2366
|
|
2276
|
-
|
2277
|
-
{
|
2278
|
-
|
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
|
2279
2391
|
{
|
2280
|
-
|
2281
|
-
sub: "acc_567236000909002",
|
2282
|
-
calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
|
2283
|
-
}],
|
2284
|
-
required: 'all'
|
2392
|
+
id: 'example_id'
|
2285
2393
|
}
|
2286
|
-
|
2287
|
-
required_duration: { minutes: 60 },
|
2288
|
-
start_interval: { minutes: 60 },
|
2289
|
-
buffer: {
|
2290
|
-
before: { minutes: 30 },
|
2291
|
-
after: { minutes: 45 },
|
2292
|
-
},
|
2293
|
-
available_periods: [{
|
2294
|
-
start: "2017-01-01T09:00:00Z",
|
2295
|
-
end: "2017-01-01T17:00:00Z",
|
2296
|
-
}]
|
2297
|
-
}
|
2298
|
-
end
|
2394
|
+
end
|
2299
2395
|
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
event: event,
|
2304
|
-
target_calendars: target_calendars,
|
2305
|
-
availability: availability,
|
2306
|
-
}
|
2307
|
-
end
|
2396
|
+
it_behaves_like 'a Cronofy request'
|
2397
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2398
|
+
end
|
2308
2399
|
|
2309
|
-
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
:summary => "Board meeting",
|
2317
|
-
:description => "Discuss plans for the next quarter.",
|
2318
|
-
:url => url.to_s,
|
2319
|
-
:location => location,
|
2320
|
-
:transparency => transparency,
|
2321
|
-
:reminders => [
|
2322
|
-
{ :minutes => 60 },
|
2323
|
-
{ :minutes => 0 },
|
2324
|
-
{ :minutes => 10 },
|
2325
|
-
],
|
2326
|
-
},
|
2327
|
-
target_calendars: target_calendars,
|
2328
|
-
availability: mapped_availability,
|
2329
|
-
}
|
2330
|
-
end
|
2331
|
-
let(:correct_response_code) { 202 }
|
2332
|
-
let(:correct_response_body) do
|
2333
|
-
{
|
2334
|
-
oauth_url: "http://www.example.com/oauth?token=example"
|
2335
|
-
}
|
2336
|
-
end
|
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
|
2337
2407
|
|
2338
|
-
|
2408
|
+
it_behaves_like 'a Cronofy request'
|
2409
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2410
|
+
end
|
2339
2411
|
|
2340
|
-
|
2341
|
-
|
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
|
2342
2418
|
end
|
2343
2419
|
|
2344
|
-
|
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) }
|
2452
|
+
|
2345
2453
|
it_behaves_like 'a Cronofy request'
|
2454
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2346
2455
|
|
2347
|
-
|
2348
|
-
|
2349
|
-
|
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
|
2350
2466
|
end
|
2351
2467
|
end
|
2352
2468
|
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.37.
|
4
|
+
version: 0.37.6
|
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: 2022-
|
12
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hashie
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
159
|
+
rubygems_version: 3.3.8
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Cronofy - the scheduling platform for business
|