cronofy 0.29.0 → 0.30.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 +7 -0
- data/lib/cronofy/client.rb +222 -2
- data/lib/cronofy/errors.rb +4 -0
- data/lib/cronofy/types.rb +17 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +420 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855b1d8409f077ff215dc67c60607b3eb3845164
|
4
|
+
data.tar.gz: 60ded29938e28d782fc0eee85b07ef37ecbbbac0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc85f2f4bd445ba656e08ab9d62e40afdbcb03b2c86929f79b7975e81d759b30a507374b0e6c43b145c835611f711fa418bf4bd5da2eac7f85a9385e2b0ebd02
|
7
|
+
data.tar.gz: bc9795fce358b5e0c7d5b0412bc2de728a764a36a94e800b10da0850101f9f9f49c390db939cf03081117e89057e542b94b1d770fb624647790129934a459e33
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## [0.30.0]
|
2
|
+
|
3
|
+
* Added support for sequencing, buffers and intervals [#62]
|
4
|
+
* Dropped support for Ruby 2.1
|
5
|
+
|
1
6
|
## [0.29.0]
|
2
7
|
|
3
8
|
* Added types for propose new time replies [#60]
|
@@ -121,6 +126,7 @@
|
|
121
126
|
[0.28.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.28.0
|
122
127
|
[0.28.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.28.1
|
123
128
|
[0.29.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.29.0
|
129
|
+
[0.30.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.30.0
|
124
130
|
|
125
131
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
126
132
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -152,3 +158,4 @@
|
|
152
158
|
[#58]: https://github.com/cronofy/cronofy-ruby/pull/58
|
153
159
|
[#59]: https://github.com/cronofy/cronofy-ruby/pull/59
|
154
160
|
[#60]: https://github.com/cronofy/cronofy-ruby/pull/60
|
161
|
+
[#62]: https://github.com/cronofy/cronofy-ruby/pull/62
|
data/lib/cronofy/client.rb
CHANGED
@@ -795,6 +795,10 @@ module Cronofy
|
|
795
795
|
# of minutes of availability required.
|
796
796
|
# :available_periods - An Array of available time periods Hashes,
|
797
797
|
# each must specify a start and end Time.
|
798
|
+
# :start_interval - An Integer representing the start interval
|
799
|
+
# of minutes for the availability query.
|
800
|
+
# :buffer - An Hash containing the buffer to apply to
|
801
|
+
# the availability query.
|
798
802
|
#
|
799
803
|
# Returns an Array of AvailablePeriods.
|
800
804
|
#
|
@@ -811,12 +815,59 @@ module Cronofy
|
|
811
815
|
options[:participants] = map_availability_participants(options[:participants])
|
812
816
|
options[:required_duration] = map_availability_required_duration(options[:required_duration])
|
813
817
|
|
818
|
+
if options[:start_interval]
|
819
|
+
options[:start_interval] = map_availability_required_duration(options[:start_interval])
|
820
|
+
end
|
821
|
+
|
822
|
+
if buffer = options[:buffer]
|
823
|
+
options[:buffer] = map_availability_buffer(buffer)
|
824
|
+
end
|
825
|
+
|
814
826
|
translate_available_periods(options[:available_periods])
|
815
827
|
|
816
828
|
response = post("/v1/availability", options)
|
817
829
|
parse_collection(AvailablePeriod, "available_periods", response)
|
818
830
|
end
|
819
831
|
|
832
|
+
# Public: Performs an sequenced availability query.
|
833
|
+
#
|
834
|
+
# options - The Hash options used to refine the selection (default: {}):
|
835
|
+
# :sequence - An Array of sequence defintions containing
|
836
|
+
# a Hash of:
|
837
|
+
# :sequence_id - A String to uniquely identify this part
|
838
|
+
# of the proposed sequence.
|
839
|
+
# :ordinal - An integer to define the ordering of the
|
840
|
+
# proposed sequence. (Optional)
|
841
|
+
# :participants - An Array of participant groups or a Hash
|
842
|
+
# for a single participant group.
|
843
|
+
# :required_duration - An Integer representing the minimum
|
844
|
+
# number of minutes of availability required.
|
845
|
+
# :start_interval - An Integer representing the start interval
|
846
|
+
# of minutes for the availability query.
|
847
|
+
# :buffer - An Hash containing the buffer to apply to
|
848
|
+
# the availability query.
|
849
|
+
# :available_periods - An Array of available time periods Hashes,
|
850
|
+
# each must specify a start and end Time.
|
851
|
+
#
|
852
|
+
# Returns an Array of Sequences.
|
853
|
+
#
|
854
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
855
|
+
# Raises Cronofy::AuthenticationFailureError if the access token is no
|
856
|
+
# longer valid.
|
857
|
+
# Raises Cronofy::AuthorizationFailureError if the access token does not
|
858
|
+
# include the required scope.
|
859
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
860
|
+
# parameters.
|
861
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
862
|
+
# limits for the application.
|
863
|
+
def sequenced_availability(options = {})
|
864
|
+
options[:sequence] = map_availability_sequence(options[:sequence])
|
865
|
+
|
866
|
+
translate_available_periods(options[:available_periods])
|
867
|
+
|
868
|
+
response = post("/v1/sequenced_availability", options)
|
869
|
+
parse_collection(Sequence, "sequences", response)
|
870
|
+
end
|
820
871
|
|
821
872
|
# Public: Generates an add to calendar link to start the OAuth process with
|
822
873
|
# an event to be automatically upserted
|
@@ -959,6 +1010,10 @@ module Cronofy
|
|
959
1010
|
# :required_duration - A hash stating the length of time the event will
|
960
1011
|
# last for
|
961
1012
|
# :available_periods - A hash stating the available periods for the event
|
1013
|
+
# :start_interval - An Integer representing the start interval
|
1014
|
+
# of minutes for the availability query.
|
1015
|
+
# :buffer - An Hash containing the buffer to apply to
|
1016
|
+
# the availability query.
|
962
1017
|
# target_calendars - An array of hashes stating into which calendars to insert the created
|
963
1018
|
# event
|
964
1019
|
#
|
@@ -1001,7 +1056,7 @@ module Cronofy
|
|
1001
1056
|
# }]
|
1002
1057
|
# )
|
1003
1058
|
#
|
1004
|
-
# See http://www.cronofy.com/developers/api#
|
1059
|
+
# See http://www.cronofy.com/developers/api#real-time-scheduling for reference.
|
1005
1060
|
#
|
1006
1061
|
# Returns a AddToCalendarResponse.
|
1007
1062
|
#
|
@@ -1021,6 +1076,14 @@ module Cronofy
|
|
1021
1076
|
if availability = args[:availability]
|
1022
1077
|
availability[:participants] = map_availability_participants(availability[:participants])
|
1023
1078
|
availability[:required_duration] = map_availability_required_duration(availability[:required_duration])
|
1079
|
+
|
1080
|
+
if value = availability[:start_interval]
|
1081
|
+
availability[:start_interval] = map_availability_required_duration(value)
|
1082
|
+
end
|
1083
|
+
|
1084
|
+
if buffer = availability[:buffer]
|
1085
|
+
availability[:buffer] = map_availability_buffer(buffer)
|
1086
|
+
end
|
1024
1087
|
end
|
1025
1088
|
|
1026
1089
|
translate_available_periods(availability[:available_periods])
|
@@ -1030,6 +1093,92 @@ module Cronofy
|
|
1030
1093
|
parse_json(AddToCalendarResponse, nil , response)
|
1031
1094
|
end
|
1032
1095
|
|
1096
|
+
# Public: Generates an real time sequencing link to start the OAuth process with
|
1097
|
+
# an event to be automatically upserted
|
1098
|
+
#
|
1099
|
+
# oauth - A Hash describing the OAuth flow required:
|
1100
|
+
# :scope - A String representing the scopes to ask for
|
1101
|
+
# within the OAuth flow
|
1102
|
+
# :redirect_uri - A String containing a url to redirect the
|
1103
|
+
# user to after completing the OAuth flow.
|
1104
|
+
# :scope - A String representing additional state to
|
1105
|
+
# be passed within the OAuth flow.
|
1106
|
+
#
|
1107
|
+
# availability - A Hash describing the availability details for the event:
|
1108
|
+
# :sequence - An Array of sequence defintions containing
|
1109
|
+
# a Hash of:
|
1110
|
+
# :sequence_id - A String to uniquely identify this part
|
1111
|
+
# of the proposed sequence.
|
1112
|
+
# :ordinal - An integer to define the ordering of the
|
1113
|
+
# proposed sequence. (Optional)
|
1114
|
+
# :participants - An Array of participant groups or a Hash
|
1115
|
+
# for a single participant group.
|
1116
|
+
# :required_duration - An Integer representing the minimum
|
1117
|
+
# number of minutes of availability required.
|
1118
|
+
# :start_interval - An Integer representing the start interval
|
1119
|
+
# of minutes for the availability query.
|
1120
|
+
# :buffer - An Hash containing the buffer to apply to
|
1121
|
+
# the availability query.
|
1122
|
+
# :event - A Hash describing the event:
|
1123
|
+
# :event_id - A String uniquely identifying the event for
|
1124
|
+
# your application (note: this is NOT an ID
|
1125
|
+
# generated by Cronofy).
|
1126
|
+
# :summary - A String to use as the summary, sometimes
|
1127
|
+
# referred to as the name or title, of the
|
1128
|
+
# event.
|
1129
|
+
# :description - A String to use as the description, sometimes
|
1130
|
+
# referred to as the notes or body, of the
|
1131
|
+
# event.
|
1132
|
+
# :url - The URL associated with the event.
|
1133
|
+
# :location - A Hash describing the location of the event
|
1134
|
+
# with symbolized keys (optional):
|
1135
|
+
# :description - A String describing the
|
1136
|
+
# location.
|
1137
|
+
# :lat - A String of the location's latitude.
|
1138
|
+
# :long - A String of the location's longitude.
|
1139
|
+
# :reminders - An Array of Hashes describing the desired
|
1140
|
+
# reminders for the event. Reminders should be
|
1141
|
+
# specified in priority order as, for example,
|
1142
|
+
# when the underlying provider only supports a
|
1143
|
+
# single reminder then the first reminder will
|
1144
|
+
# be used.
|
1145
|
+
# :minutes - An Integer specifying the number
|
1146
|
+
# of minutes before the start of the
|
1147
|
+
# event that the reminder should
|
1148
|
+
# occur.
|
1149
|
+
# :transparency - The transparency state for the event (optional).
|
1150
|
+
# Accepted values are "transparent" and "opaque".
|
1151
|
+
# :attendees - A Hash of :invite and :reject, each of which is
|
1152
|
+
# an array of invitees to invite to or reject from
|
1153
|
+
# the event. Invitees are represented by a hash of
|
1154
|
+
# :email and :display_name (optional).
|
1155
|
+
# :available_periods - A hash stating the available periods for the event
|
1156
|
+
# target_calendars - An array of hashes stating into which calendars to insert the created
|
1157
|
+
# event
|
1158
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1159
|
+
# Raises Cronofy::AuthenticationFailureError if the access token is no
|
1160
|
+
# longer valid.
|
1161
|
+
# Raises Cronofy::AuthorizationFailureError if the access token does not
|
1162
|
+
# include the required scope.
|
1163
|
+
# Raises Cronofy::NotFoundError if the calendar does not exist.
|
1164
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1165
|
+
# parameters.
|
1166
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1167
|
+
# limits for the application.
|
1168
|
+
def real_time_sequencing(args)
|
1169
|
+
body = args.merge(client_id: @client_id, client_secret: @client_secret)
|
1170
|
+
|
1171
|
+
if availability = args[:availability]
|
1172
|
+
availability[:sequence] = map_availability_sequence(availability[:sequence])
|
1173
|
+
translate_available_periods(availability[:available_periods]) if availability[:available_periods]
|
1174
|
+
end
|
1175
|
+
|
1176
|
+
body[:availability] = availability
|
1177
|
+
|
1178
|
+
response = post("/v1/real_time_sequencing", body)
|
1179
|
+
parse_json(AddToCalendarResponse, nil , response)
|
1180
|
+
end
|
1181
|
+
|
1033
1182
|
# Public: Creates a link_token to allow explicitly linking of an account
|
1034
1183
|
#
|
1035
1184
|
# See https://www.cronofy.com/developers/api/alpha/#auth-explicit-linking for
|
@@ -1069,7 +1218,7 @@ module Cronofy
|
|
1069
1218
|
# send notifications to about user interactions with
|
1070
1219
|
# the Smart Invite.
|
1071
1220
|
# recipient - A Hash containing the intended recipient of the invite
|
1072
|
-
# :email - A String for
|
1221
|
+
# :email - A String for the email address you are
|
1073
1222
|
# going to send the Smart Invite to.
|
1074
1223
|
# event - A Hash describing the event with symbolized keys:
|
1075
1224
|
# :summary - A String to use as the summary, sometimes
|
@@ -1101,6 +1250,9 @@ module Cronofy
|
|
1101
1250
|
# Accepted values are "transparent" and "opaque".
|
1102
1251
|
# :color - The color of the event (optional).
|
1103
1252
|
#
|
1253
|
+
# organizer - A Hash containing the details of the organizer.
|
1254
|
+
# :name - A String value for the display name of the
|
1255
|
+
# event organizer
|
1104
1256
|
# Examples
|
1105
1257
|
#
|
1106
1258
|
# client.upsert_smart_invite(
|
@@ -1118,6 +1270,9 @@ module Cronofy
|
|
1118
1270
|
# description: "Board room",
|
1119
1271
|
# lat: "1.2345",
|
1120
1272
|
# long: "0.1234"
|
1273
|
+
# },
|
1274
|
+
# organizer: {
|
1275
|
+
# name: "Smart invite application"
|
1121
1276
|
# }
|
1122
1277
|
# )
|
1123
1278
|
#
|
@@ -1252,6 +1407,71 @@ module Cronofy
|
|
1252
1407
|
end
|
1253
1408
|
end
|
1254
1409
|
|
1410
|
+
def map_availability_buffer(buffer)
|
1411
|
+
result = {}
|
1412
|
+
|
1413
|
+
unless buffer.is_a?(Hash)
|
1414
|
+
return result
|
1415
|
+
end
|
1416
|
+
|
1417
|
+
if before_buffer = buffer[:before]
|
1418
|
+
result[:before] = map_buffer_details(before_buffer)
|
1419
|
+
end
|
1420
|
+
|
1421
|
+
if after_buffer = buffer[:after]
|
1422
|
+
result[:after] = map_buffer_details(after_buffer)
|
1423
|
+
end
|
1424
|
+
|
1425
|
+
result
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
def map_buffer_details(buffer)
|
1429
|
+
result = map_availability_required_duration(buffer)
|
1430
|
+
|
1431
|
+
if minimum_buffer = buffer[:minimum]
|
1432
|
+
result[:minimum] = map_availability_required_duration(minimum_buffer)
|
1433
|
+
end
|
1434
|
+
|
1435
|
+
if maximum_buffer = buffer[:maximum]
|
1436
|
+
result[:maximum] = map_availability_required_duration(maximum_buffer)
|
1437
|
+
end
|
1438
|
+
|
1439
|
+
result
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
def map_availability_sequence(sequence)
|
1443
|
+
case sequence
|
1444
|
+
when Enumerable
|
1445
|
+
sequence.map do |sequence_item|
|
1446
|
+
hash = {}
|
1447
|
+
|
1448
|
+
if value = sequence_item[:participants]
|
1449
|
+
hash[:participants] = map_availability_participants(value)
|
1450
|
+
end
|
1451
|
+
|
1452
|
+
if value = sequence_item[:required_duration]
|
1453
|
+
hash[:required_duration] = map_availability_required_duration(value)
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
if sequence_item[:available_periods]
|
1457
|
+
translate_available_periods(sequence_item[:available_periods])
|
1458
|
+
end
|
1459
|
+
|
1460
|
+
if value = sequence_item[:start_interval]
|
1461
|
+
hash[:start_interval] = map_availability_required_duration(value)
|
1462
|
+
end
|
1463
|
+
|
1464
|
+
if buffer = sequence_item[:buffer]
|
1465
|
+
hash[:buffer] = map_availability_buffer(buffer)
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
sequence_item.merge(hash)
|
1469
|
+
end
|
1470
|
+
else
|
1471
|
+
sequence
|
1472
|
+
end
|
1473
|
+
end
|
1474
|
+
|
1255
1475
|
AVAILABLE_PERIODS_TIME_PARAMS = %i{
|
1256
1476
|
start
|
1257
1477
|
end
|
data/lib/cronofy/errors.rb
CHANGED
@@ -65,6 +65,9 @@ module Cronofy
|
|
65
65
|
class ServerError < APIError
|
66
66
|
end
|
67
67
|
|
68
|
+
class PaymentRequiredError < APIError
|
69
|
+
end
|
70
|
+
|
68
71
|
class UnknownError < APIError
|
69
72
|
end
|
70
73
|
|
@@ -73,6 +76,7 @@ module Cronofy
|
|
73
76
|
ERROR_MAP = {
|
74
77
|
400 => BadRequestError,
|
75
78
|
401 => AuthenticationFailureError,
|
79
|
+
402 => PaymentRequiredError,
|
76
80
|
403 => AuthorizationFailureError,
|
77
81
|
404 => NotFoundError,
|
78
82
|
422 => InvalidRequestError,
|
data/lib/cronofy/types.rb
CHANGED
@@ -354,6 +354,23 @@ module Cronofy
|
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
|
+
class SequenceItem < CronofyMash
|
358
|
+
coerce_key :start, EventTime
|
359
|
+
coerce_key :end, EventTime
|
360
|
+
|
361
|
+
coerce_key :participants, ParticipantEnumerable
|
362
|
+
end
|
363
|
+
|
364
|
+
module SequenceItemEnumerable
|
365
|
+
def self.coerce(values)
|
366
|
+
values.map { |v| SequenceItem.new(v) }
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
class Sequence < CronofyMash
|
371
|
+
coerce_key :sequence, SequenceItemEnumerable
|
372
|
+
end
|
373
|
+
|
357
374
|
class AvailablePeriod < CronofyMash
|
358
375
|
coerce_key :start, EventTime
|
359
376
|
coerce_key :end, EventTime
|
data/lib/cronofy/version.rb
CHANGED
@@ -1283,6 +1283,77 @@ describe Cronofy::Client do
|
|
1283
1283
|
it_behaves_like 'a Cronofy request with mapped return value'
|
1284
1284
|
end
|
1285
1285
|
|
1286
|
+
context "buffer and start_interval" do
|
1287
|
+
let(:request_body) do
|
1288
|
+
{
|
1289
|
+
"participants" => [
|
1290
|
+
{
|
1291
|
+
"members" => [
|
1292
|
+
{ "sub" => "acc_567236000909002" },
|
1293
|
+
{ "sub" => "acc_678347111010113" }
|
1294
|
+
],
|
1295
|
+
"required" => "all"
|
1296
|
+
}
|
1297
|
+
],
|
1298
|
+
"required_duration" => { "minutes" => 60 },
|
1299
|
+
"buffer" => {
|
1300
|
+
"before": { "minutes": 30 },
|
1301
|
+
"after": { "minutes": 60 },
|
1302
|
+
},
|
1303
|
+
"start_interval" => { "minutes" => 60 },
|
1304
|
+
"available_periods" => [
|
1305
|
+
{
|
1306
|
+
"start" => "2017-01-03T09:00:00Z",
|
1307
|
+
"end" => "2017-01-03T18:00:00Z"
|
1308
|
+
},
|
1309
|
+
{
|
1310
|
+
"start" => "2017-01-04T09:00:00Z",
|
1311
|
+
"end" => "2017-01-04T18:00:00Z"
|
1312
|
+
},
|
1313
|
+
]
|
1314
|
+
}
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
let(:participants) do
|
1318
|
+
[
|
1319
|
+
{
|
1320
|
+
members: [
|
1321
|
+
{ sub: "acc_567236000909002" },
|
1322
|
+
{ sub: "acc_678347111010113" },
|
1323
|
+
],
|
1324
|
+
required: :all,
|
1325
|
+
}
|
1326
|
+
]
|
1327
|
+
end
|
1328
|
+
|
1329
|
+
let(:buffer) do
|
1330
|
+
{
|
1331
|
+
before: { minutes: 30 },
|
1332
|
+
after: { minutes: 60 },
|
1333
|
+
}
|
1334
|
+
end
|
1335
|
+
|
1336
|
+
let(:start_interval) do
|
1337
|
+
{ minutes: 60 }
|
1338
|
+
end
|
1339
|
+
|
1340
|
+
let(:required_duration) do
|
1341
|
+
{ minutes: 60 }
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
let(:available_periods) do
|
1345
|
+
[
|
1346
|
+
{ start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T18:00:00Z") },
|
1347
|
+
{ start: Time.parse("2017-01-04T09:00:00Z"), end: Time.parse("2017-01-04T18:00:00Z") },
|
1348
|
+
]
|
1349
|
+
end
|
1350
|
+
|
1351
|
+
subject { client.availability(participants: participants, required_duration: required_duration, available_periods: available_periods, buffer: buffer, start_interval: start_interval) }
|
1352
|
+
|
1353
|
+
it_behaves_like 'a Cronofy request'
|
1354
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
1355
|
+
end
|
1356
|
+
|
1286
1357
|
context "member-specific available periods" do
|
1287
1358
|
let(:request_body) do
|
1288
1359
|
{
|
@@ -1509,6 +1580,161 @@ describe Cronofy::Client do
|
|
1509
1580
|
end
|
1510
1581
|
end
|
1511
1582
|
|
1583
|
+
describe 'Sequenced Availability' do
|
1584
|
+
describe '#sequenced_availability' do
|
1585
|
+
let(:method) { :post }
|
1586
|
+
let(:request_url) { 'https://api.cronofy.com/v1/sequenced_availability' }
|
1587
|
+
let(:request_headers) { json_request_headers }
|
1588
|
+
|
1589
|
+
let(:request_body) do
|
1590
|
+
{
|
1591
|
+
"sequence" => [
|
1592
|
+
{
|
1593
|
+
"sequence_id" => 1234,
|
1594
|
+
"ordinal" => 1,
|
1595
|
+
"participants" => [
|
1596
|
+
{
|
1597
|
+
"members" => [
|
1598
|
+
{ "sub" => "acc_567236000909002" },
|
1599
|
+
{ "sub" => "acc_678347111010113" }
|
1600
|
+
],
|
1601
|
+
"required" => "all"
|
1602
|
+
}
|
1603
|
+
],
|
1604
|
+
"required_duration" => { "minutes" => 60 },
|
1605
|
+
"start_interval" => { "minutes" => 60 },
|
1606
|
+
"buffer" => {
|
1607
|
+
"before": {
|
1608
|
+
"minimum": { "minutes" => 30 },
|
1609
|
+
"maximum": { "minutes" => 45 },
|
1610
|
+
},
|
1611
|
+
"after": {
|
1612
|
+
"minimum": { "minutes" => 45 },
|
1613
|
+
"maximum": { "minutes" => 60 },
|
1614
|
+
},
|
1615
|
+
}
|
1616
|
+
},
|
1617
|
+
{
|
1618
|
+
"sequence_id" => 4567,
|
1619
|
+
"ordinal" => 2,
|
1620
|
+
"participants" => [
|
1621
|
+
{
|
1622
|
+
"members" => [
|
1623
|
+
{ "sub" => "acc_567236000909002" },
|
1624
|
+
{ "sub" => "acc_678347111010113" }
|
1625
|
+
],
|
1626
|
+
"required" => "all"
|
1627
|
+
}
|
1628
|
+
],
|
1629
|
+
"required_duration" => { "minutes" => 60 },
|
1630
|
+
}
|
1631
|
+
],
|
1632
|
+
"available_periods" => [
|
1633
|
+
{
|
1634
|
+
"start" => "2017-01-03T09:00:00Z",
|
1635
|
+
"end" => "2017-01-03T18:00:00Z"
|
1636
|
+
},
|
1637
|
+
{
|
1638
|
+
"start" => "2017-01-04T09:00:00Z",
|
1639
|
+
"end" => "2017-01-04T18:00:00Z"
|
1640
|
+
}
|
1641
|
+
]
|
1642
|
+
}
|
1643
|
+
end
|
1644
|
+
|
1645
|
+
let(:correct_response_code) { 200 }
|
1646
|
+
let(:correct_response_body) do
|
1647
|
+
{
|
1648
|
+
"sequences" => [
|
1649
|
+
{
|
1650
|
+
"sequence" => [
|
1651
|
+
{
|
1652
|
+
"sequence_id" => 1234,
|
1653
|
+
"start" => "2017-01-03T09:00:00Z",
|
1654
|
+
"end" => "2017-01-03T11:00:00Z",
|
1655
|
+
"participants" => [
|
1656
|
+
{ "sub" => "acc_567236000909002" },
|
1657
|
+
{ "sub" => "acc_678347111010113" }
|
1658
|
+
]
|
1659
|
+
},
|
1660
|
+
{
|
1661
|
+
"sequence_id" => 4567,
|
1662
|
+
"start" => "2017-01-03T14:00:00Z",
|
1663
|
+
"end" => "2017-01-03T16:00:00Z",
|
1664
|
+
"participants" => [
|
1665
|
+
{ "sub" => "acc_567236000909002" },
|
1666
|
+
{ "sub" => "acc_678347111010113" }
|
1667
|
+
]
|
1668
|
+
},
|
1669
|
+
]
|
1670
|
+
}
|
1671
|
+
]
|
1672
|
+
}
|
1673
|
+
end
|
1674
|
+
|
1675
|
+
let(:correct_mapped_result) do
|
1676
|
+
correct_response_body['sequences'].map { |sequence| Cronofy::Sequence.new(sequence) }
|
1677
|
+
end
|
1678
|
+
|
1679
|
+
let(:args) do
|
1680
|
+
{
|
1681
|
+
sequence: [{
|
1682
|
+
sequence_id: 1234,
|
1683
|
+
ordinal: 1,
|
1684
|
+
participants: participants,
|
1685
|
+
required_duration: required_duration,
|
1686
|
+
start_interval: { minutes: 60 },
|
1687
|
+
buffer: {
|
1688
|
+
before: {
|
1689
|
+
minimum: { minutes: 30 },
|
1690
|
+
maximum: { minutes: 45 },
|
1691
|
+
},
|
1692
|
+
after: {
|
1693
|
+
minimum: { minutes: 45 },
|
1694
|
+
maximum: { minutes: 60 },
|
1695
|
+
},
|
1696
|
+
},
|
1697
|
+
},
|
1698
|
+
{
|
1699
|
+
sequence_id: 4567,
|
1700
|
+
ordinal: 2,
|
1701
|
+
participants: participants,
|
1702
|
+
required_duration: required_duration,
|
1703
|
+
}],
|
1704
|
+
available_periods: available_periods
|
1705
|
+
}
|
1706
|
+
end
|
1707
|
+
|
1708
|
+
subject { client.sequenced_availability(args) }
|
1709
|
+
|
1710
|
+
let(:participants) do
|
1711
|
+
[
|
1712
|
+
{
|
1713
|
+
members: [
|
1714
|
+
{ sub: "acc_567236000909002" },
|
1715
|
+
{ sub: "acc_678347111010113" },
|
1716
|
+
],
|
1717
|
+
required: :all,
|
1718
|
+
}
|
1719
|
+
]
|
1720
|
+
end
|
1721
|
+
|
1722
|
+
let(:required_duration) do
|
1723
|
+
{ minutes: 60 }
|
1724
|
+
end
|
1725
|
+
|
1726
|
+
let(:available_periods) do
|
1727
|
+
[
|
1728
|
+
{ start: Time.parse("2017-01-03T09:00:00Z"), end: Time.parse("2017-01-03T18:00:00Z") },
|
1729
|
+
{ start: Time.parse("2017-01-04T09:00:00Z"), end: Time.parse("2017-01-04T18:00:00Z") },
|
1730
|
+
]
|
1731
|
+
end
|
1732
|
+
|
1733
|
+
it_behaves_like 'a Cronofy request'
|
1734
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
1735
|
+
end
|
1736
|
+
end
|
1737
|
+
|
1512
1738
|
describe "Add to calendar" do
|
1513
1739
|
let(:request_url) { "https://api.cronofy.com/v1/add_to_calendar" }
|
1514
1740
|
let(:url) { URI("https://example.com") }
|
@@ -1686,7 +1912,12 @@ describe Cronofy::Client do
|
|
1686
1912
|
available_periods: [{
|
1687
1913
|
start: Time.utc(2017, 1, 1, 9, 00),
|
1688
1914
|
end: Time.utc(2017, 1, 1, 17, 00),
|
1689
|
-
}]
|
1915
|
+
}],
|
1916
|
+
start_interval: { minutes: 60 },
|
1917
|
+
buffer: {
|
1918
|
+
before: { minutes: 30 },
|
1919
|
+
after: { minutes: 45 },
|
1920
|
+
}
|
1690
1921
|
}
|
1691
1922
|
end
|
1692
1923
|
|
@@ -1702,6 +1933,11 @@ describe Cronofy::Client do
|
|
1702
1933
|
}
|
1703
1934
|
],
|
1704
1935
|
required_duration: { minutes: 60 },
|
1936
|
+
start_interval: { minutes: 60 },
|
1937
|
+
buffer: {
|
1938
|
+
before: { minutes: 30 },
|
1939
|
+
after: { minutes: 45 },
|
1940
|
+
},
|
1705
1941
|
available_periods: [{
|
1706
1942
|
start: "2017-01-01T09:00:00Z",
|
1707
1943
|
end: "2017-01-01T17:00:00Z",
|
@@ -1755,6 +1991,189 @@ describe Cronofy::Client do
|
|
1755
1991
|
|
1756
1992
|
end
|
1757
1993
|
|
1994
|
+
describe "Real time sequencing" do
|
1995
|
+
let(:request_url) { "https://api.cronofy.com/v1/real_time_sequencing" }
|
1996
|
+
let(:url) { URI("https://example.com") }
|
1997
|
+
let(:method) { :post }
|
1998
|
+
let(:request_headers) { json_request_headers }
|
1999
|
+
|
2000
|
+
let(:location) { { :description => "Board room" } }
|
2001
|
+
let(:transparency) { nil }
|
2002
|
+
let(:client_id) { 'example_id' }
|
2003
|
+
let(:client_secret) { 'example_secret' }
|
2004
|
+
let(:scope) { 'read_events delete_events' }
|
2005
|
+
let(:state) { 'example_state' }
|
2006
|
+
let(:redirect_uri) { 'http://example.com/redirect' }
|
2007
|
+
|
2008
|
+
let(:client) do
|
2009
|
+
Cronofy::Client.new(
|
2010
|
+
client_id: client_id,
|
2011
|
+
client_secret: client_secret,
|
2012
|
+
access_token: token,
|
2013
|
+
)
|
2014
|
+
end
|
2015
|
+
|
2016
|
+
let(:event) do
|
2017
|
+
{
|
2018
|
+
:event_id => "qTtZdczOccgaPncGJaCiLg",
|
2019
|
+
:summary => "Board meeting",
|
2020
|
+
:description => "Discuss plans for the next quarter.",
|
2021
|
+
:url => url,
|
2022
|
+
:location => location,
|
2023
|
+
:transparency => transparency,
|
2024
|
+
:reminders => [
|
2025
|
+
{ :minutes => 60 },
|
2026
|
+
{ :minutes => 0 },
|
2027
|
+
{ :minutes => 10 },
|
2028
|
+
],
|
2029
|
+
}
|
2030
|
+
end
|
2031
|
+
|
2032
|
+
let(:oauth_body) do
|
2033
|
+
{
|
2034
|
+
scope: scope,
|
2035
|
+
redirect_uri: redirect_uri,
|
2036
|
+
state: state,
|
2037
|
+
}
|
2038
|
+
end
|
2039
|
+
|
2040
|
+
let(:target_calendars) do
|
2041
|
+
[
|
2042
|
+
{
|
2043
|
+
sub: "acc_567236000909002",
|
2044
|
+
calendar_id: "cal_n23kjnwrw2_jsdfjksn234",
|
2045
|
+
}
|
2046
|
+
]
|
2047
|
+
end
|
2048
|
+
|
2049
|
+
let(:availability) do
|
2050
|
+
{
|
2051
|
+
sequence: [
|
2052
|
+
{
|
2053
|
+
participants: [
|
2054
|
+
{
|
2055
|
+
members: [{
|
2056
|
+
sub: "acc_567236000909002",
|
2057
|
+
calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
|
2058
|
+
}],
|
2059
|
+
required: 'all'
|
2060
|
+
}
|
2061
|
+
],
|
2062
|
+
required_duration: { minutes: 60 },
|
2063
|
+
start_interval: { minutes: 60 },
|
2064
|
+
available_periods: [{
|
2065
|
+
start: Time.utc(2017, 1, 1, 9, 00),
|
2066
|
+
end: Time.utc(2017, 1, 1, 17, 00),
|
2067
|
+
}],
|
2068
|
+
event: event,
|
2069
|
+
buffer: {
|
2070
|
+
before: {
|
2071
|
+
minimum: { minutes: 30 },
|
2072
|
+
maximum: { minutes: 30 },
|
2073
|
+
},
|
2074
|
+
after: {
|
2075
|
+
minimum: { minutes: 30 },
|
2076
|
+
maximum: { minutes: 30 },
|
2077
|
+
}
|
2078
|
+
}
|
2079
|
+
}
|
2080
|
+
],
|
2081
|
+
available_periods: [{
|
2082
|
+
start: Time.utc(2017, 1, 1, 9, 00),
|
2083
|
+
end: Time.utc(2017, 1, 1, 17, 00),
|
2084
|
+
}],
|
2085
|
+
}
|
2086
|
+
end
|
2087
|
+
|
2088
|
+
let(:mapped_availability) do
|
2089
|
+
{
|
2090
|
+
sequence: [
|
2091
|
+
{
|
2092
|
+
participants: [
|
2093
|
+
{
|
2094
|
+
members: [{
|
2095
|
+
sub: "acc_567236000909002",
|
2096
|
+
calendar_ids: ["cal_n23kjnwrw2_jsdfjksn234"]
|
2097
|
+
}],
|
2098
|
+
required: 'all'
|
2099
|
+
}
|
2100
|
+
],
|
2101
|
+
required_duration: { minutes: 60 },
|
2102
|
+
start_interval: { minutes: 60 },
|
2103
|
+
available_periods: [{
|
2104
|
+
start: "2017-01-01T09:00:00Z",
|
2105
|
+
end: "2017-01-01T17:00:00Z",
|
2106
|
+
}],
|
2107
|
+
event: mapped_event,
|
2108
|
+
buffer: {
|
2109
|
+
before: {
|
2110
|
+
minimum: { minutes: 30 },
|
2111
|
+
maximum: { minutes: 30 },
|
2112
|
+
},
|
2113
|
+
after: {
|
2114
|
+
minimum: { minutes: 30 },
|
2115
|
+
maximum: { minutes: 30 },
|
2116
|
+
}
|
2117
|
+
}
|
2118
|
+
}
|
2119
|
+
],
|
2120
|
+
available_periods: [{
|
2121
|
+
start: "2017-01-01T09:00:00Z",
|
2122
|
+
end: "2017-01-01T17:00:00Z",
|
2123
|
+
}]
|
2124
|
+
}
|
2125
|
+
end
|
2126
|
+
|
2127
|
+
let(:mapped_event) do
|
2128
|
+
{
|
2129
|
+
:event_id => "qTtZdczOccgaPncGJaCiLg",
|
2130
|
+
:summary => "Board meeting",
|
2131
|
+
:description => "Discuss plans for the next quarter.",
|
2132
|
+
:url => url.to_s,
|
2133
|
+
:location => location,
|
2134
|
+
:transparency => transparency,
|
2135
|
+
:reminders => [
|
2136
|
+
{ :minutes => 60 },
|
2137
|
+
{ :minutes => 0 },
|
2138
|
+
{ :minutes => 10 },
|
2139
|
+
],
|
2140
|
+
}
|
2141
|
+
end
|
2142
|
+
|
2143
|
+
let(:args) do
|
2144
|
+
{
|
2145
|
+
oauth: oauth_body,
|
2146
|
+
event: event,
|
2147
|
+
target_calendars: target_calendars,
|
2148
|
+
availability: availability,
|
2149
|
+
}
|
2150
|
+
end
|
2151
|
+
|
2152
|
+
let(:request_body) do
|
2153
|
+
{
|
2154
|
+
client_id: client_id,
|
2155
|
+
client_secret: client_secret,
|
2156
|
+
oauth: oauth_body,
|
2157
|
+
event: mapped_event,
|
2158
|
+
target_calendars: target_calendars,
|
2159
|
+
availability: mapped_availability,
|
2160
|
+
}
|
2161
|
+
end
|
2162
|
+
let(:correct_response_code) { 202 }
|
2163
|
+
let(:correct_response_body) do
|
2164
|
+
{
|
2165
|
+
oauth_url: "http://www.example.com/oauth?token=example"
|
2166
|
+
}
|
2167
|
+
end
|
2168
|
+
|
2169
|
+
subject { client.real_time_sequencing(args) }
|
2170
|
+
|
2171
|
+
context 'when start/end are Times' do
|
2172
|
+
it_behaves_like 'a Cronofy request'
|
2173
|
+
end
|
2174
|
+
|
2175
|
+
end
|
2176
|
+
|
1758
2177
|
describe "Specified data centre" do
|
1759
2178
|
let(:data_centre) { :de }
|
1760
2179
|
|
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.30.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: 2018-
|
12
|
+
date: 2018-08-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|