cronofy 0.31.2 → 0.36.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 +30 -0
- data/cronofy.gemspec +1 -1
- data/lib/cronofy/client.rb +247 -1
- data/lib/cronofy/errors.rb +15 -0
- data/lib/cronofy/types.rb +26 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +467 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e085c07872654ff1e239fcdce81beeb212856ce2ff7d9c3168e71c3f2778e6d5
|
4
|
+
data.tar.gz: 0ce2421b8e0aa2b39c76a72eaeeddd4a474573690a6d3ccdf437c1d57dbf0028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8df4506dfe09d4454c8901e312dbda5d03a27d1ec8a0cb28506327f8802a691fa5abf00abd8028ee6f04d9c09eae73f3a0ea417409e7164b2fa1e0e4530bb2a3
|
7
|
+
data.tar.gz: fe07ce98f72073fa8c0254510a089fbf04d37d5da2a12b7c12d1de77e19e1666c394d14aca6d32d96ad2ee7093b1e276ad5571f0ffcfd615a4d269e70031e07b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
## [0.36.0]
|
2
|
+
|
3
|
+
* Add support for Available Periods [#81]
|
4
|
+
|
5
|
+
## [0.35.0]
|
6
|
+
|
7
|
+
* Add specific errors for network issues [#77]
|
8
|
+
|
9
|
+
## [0.34.0]
|
10
|
+
|
11
|
+
* Support removing a participant from a Smart Invite [#75]
|
12
|
+
|
13
|
+
## [0.33.0]
|
14
|
+
|
15
|
+
* Support listing Availability Rules [#74]
|
16
|
+
|
17
|
+
## [0.32.0]
|
18
|
+
|
19
|
+
* Support Availability Rules and Scheduling Conversations [#64]
|
20
|
+
|
1
21
|
## [0.31.2]
|
2
22
|
|
3
23
|
* Support parsing new Availability response formats [#73]
|
@@ -142,6 +162,11 @@
|
|
142
162
|
[0.31.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.0
|
143
163
|
[0.31.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.1
|
144
164
|
[0.31.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.2
|
165
|
+
[0.32.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.32.0
|
166
|
+
[0.33.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.33.0
|
167
|
+
[0.34.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.34.0
|
168
|
+
[0.35.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.35.0
|
169
|
+
[0.36.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.36.0
|
145
170
|
|
146
171
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
147
172
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -174,6 +199,11 @@
|
|
174
199
|
[#59]: https://github.com/cronofy/cronofy-ruby/pull/59
|
175
200
|
[#60]: https://github.com/cronofy/cronofy-ruby/pull/60
|
176
201
|
[#62]: https://github.com/cronofy/cronofy-ruby/pull/62
|
202
|
+
[#64]: https://github.com/cronofy/cronofy-ruby/pull/64
|
177
203
|
[#69]: https://github.com/cronofy/cronofy-ruby/pull/69
|
178
204
|
[#72]: https://github.com/cronofy/cronofy-ruby/pull/72
|
179
205
|
[#73]: https://github.com/cronofy/cronofy-ruby/pull/73
|
206
|
+
[#74]: https://github.com/cronofy/cronofy-ruby/pull/74
|
207
|
+
[#75]: https://github.com/cronofy/cronofy-ruby/pull/75
|
208
|
+
[#77]: https://github.com/cronofy/cronofy-ruby/pull/77
|
209
|
+
[#81]: https://github.com/cronofy/cronofy-ruby/pull/81
|
data/cronofy.gemspec
CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", ">= 1.6", "< 3"
|
24
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.2"
|
26
|
-
spec.add_development_dependency "webmock", "~> 1
|
26
|
+
spec.add_development_dependency "webmock", "~> 3.9.1"
|
27
27
|
end
|
data/lib/cronofy/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'uri'
|
2
|
+
|
1
3
|
module Cronofy
|
2
4
|
# Public: Primary class for interacting with the Cronofy API.
|
3
5
|
class Client
|
@@ -1323,6 +1325,32 @@ module Cronofy
|
|
1323
1325
|
parse_json(SmartInviteResponse, nil, response)
|
1324
1326
|
end
|
1325
1327
|
|
1328
|
+
# Public: Removes an individual recipient from a multiple recipient smart invite
|
1329
|
+
#
|
1330
|
+
# smart_invite_id - A String uniquely identifying the event for your
|
1331
|
+
# application (note: this is NOT an ID generated
|
1332
|
+
# by Cronofy).
|
1333
|
+
#
|
1334
|
+
# recipient - A Hash containing the recipient to be removed
|
1335
|
+
# :email - A String for the email address of
|
1336
|
+
# the recipient to remove.
|
1337
|
+
#
|
1338
|
+
# See https://docs.cronofy.com/developers/api-alpha/smart-invites/multiple-recipients/#remove-invite-recipient
|
1339
|
+
# for reference.
|
1340
|
+
#
|
1341
|
+
# Returns a SmartInviteResponse
|
1342
|
+
#
|
1343
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1344
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1345
|
+
# parameters.
|
1346
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1347
|
+
# limits for the application.
|
1348
|
+
def remove_recipient_smart_invite(body={})
|
1349
|
+
body[:method] = 'remove'
|
1350
|
+
response = wrapped_request { api_key!.post("/v1/smart_invites", json_request_args(body)) }
|
1351
|
+
parse_json(SmartInviteResponse, nil, response)
|
1352
|
+
end
|
1353
|
+
|
1326
1354
|
# Public: Gets the details for a smart invite.
|
1327
1355
|
#
|
1328
1356
|
# smart_invite_id - A String uniquely identifying the event for your
|
@@ -1344,7 +1372,6 @@ module Cronofy
|
|
1344
1372
|
parse_json(SmartInviteResponse, nil, response)
|
1345
1373
|
end
|
1346
1374
|
|
1347
|
-
|
1348
1375
|
# Public: Creates an element_token to pass to a UI Element
|
1349
1376
|
#
|
1350
1377
|
# options - A Hash of options for the token
|
@@ -1371,6 +1398,225 @@ module Cronofy
|
|
1371
1398
|
parse_json(ElementToken, "element_token", response)
|
1372
1399
|
end
|
1373
1400
|
|
1401
|
+
# Public: Creates or updates an AvailabilityRule.
|
1402
|
+
#
|
1403
|
+
# availability_rule_id - A String uniquely identifying the availability rule
|
1404
|
+
# for the authenticated user in your application
|
1405
|
+
# (note: this is NOT an ID generated by Cronofy).
|
1406
|
+
# tzid - The time zone identifier for the rule.
|
1407
|
+
# calendar_ids - An optional array of calendar_ids that should impact the
|
1408
|
+
# user's availability.
|
1409
|
+
# weekly_periods - An array of objects describing a weekly recurring available period
|
1410
|
+
# :day - A String for the week day
|
1411
|
+
# :start_time - A String for 24hr time that period starts eg: 09:30
|
1412
|
+
# :end_time - A String for 24hr time that period ends eg: 17:30
|
1413
|
+
# Examples
|
1414
|
+
#
|
1415
|
+
# client.upsert_availability_rule(
|
1416
|
+
# availability_rule_id: "qTtZdczOccgaPncGJaCiLg",
|
1417
|
+
# tzid: "America/Chicago",
|
1418
|
+
# calendar_ids: [
|
1419
|
+
# "cal_n23kjnwrw2_jsdfjksn234"
|
1420
|
+
# ],
|
1421
|
+
# weekly_periods: [
|
1422
|
+
# {
|
1423
|
+
# day: "monday",
|
1424
|
+
# start_time: "09:30",
|
1425
|
+
# end_time: "12:30",
|
1426
|
+
# },
|
1427
|
+
# {
|
1428
|
+
# day: "tuesday",
|
1429
|
+
# start_time: "09:30",
|
1430
|
+
# end_time: "12:30",
|
1431
|
+
# }
|
1432
|
+
# ]
|
1433
|
+
# )
|
1434
|
+
#
|
1435
|
+
# See http://www.cronofy.com/developers/alpha/api#availability_rules for reference.
|
1436
|
+
#
|
1437
|
+
# Returns an AvailabilityRuleResponse.
|
1438
|
+
#
|
1439
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1440
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1441
|
+
# parameters.
|
1442
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1443
|
+
# limits for the application.
|
1444
|
+
def upsert_availability_rule(body)
|
1445
|
+
response = wrapped_request { post("/v1/availability_rules", body) }
|
1446
|
+
parse_json(AvailabilityRule, 'availability_rule', response)
|
1447
|
+
end
|
1448
|
+
|
1449
|
+
# Public: Gets an AvailabilityRule.
|
1450
|
+
#
|
1451
|
+
# availability_rule_id - A String uniquely identifying the availability rule
|
1452
|
+
# for the authenticated user in your application
|
1453
|
+
#
|
1454
|
+
# Returns an AvailabilityRuleResponse.
|
1455
|
+
#
|
1456
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1457
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1458
|
+
# parameters.
|
1459
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1460
|
+
# limits for the application.
|
1461
|
+
def get_availability_rule(availability_rule_id)
|
1462
|
+
response = wrapped_request { get("/v1/availability_rules/#{availability_rule_id}") }
|
1463
|
+
parse_json(AvailabilityRule, 'availability_rule', response)
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
# Public: Gets all AvailabilityRules for an account.
|
1467
|
+
#
|
1468
|
+
# Returns an array of AvailabilityRules.
|
1469
|
+
#
|
1470
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1471
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1472
|
+
# parameters.
|
1473
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1474
|
+
# limits for the application.
|
1475
|
+
def get_availability_rules
|
1476
|
+
response = wrapped_request { get("/v1/availability_rules") }
|
1477
|
+
parse_collection(AvailabilityRule, 'availability_rules', response)
|
1478
|
+
end
|
1479
|
+
|
1480
|
+
# Public: Deletes an AvailabilityRule.
|
1481
|
+
#
|
1482
|
+
# availability_rule_id - A String uniquely identifying the availability rule
|
1483
|
+
# for the authenticated user in your application
|
1484
|
+
#
|
1485
|
+
# Returns nothing.
|
1486
|
+
#
|
1487
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1488
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1489
|
+
# parameters.
|
1490
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1491
|
+
# limits for the application.
|
1492
|
+
def delete_availability_rule(availability_rule_id)
|
1493
|
+
wrapped_request { delete("/v1/availability_rules/#{availability_rule_id}") }
|
1494
|
+
nil
|
1495
|
+
end
|
1496
|
+
|
1497
|
+
# Public: Creates or updates an AvailablePeriod.
|
1498
|
+
#
|
1499
|
+
# available_period_id - A String uniquely identifying the available period
|
1500
|
+
# for the authenticated user in your application
|
1501
|
+
# (note: this is NOT an ID generated by Cronofy).
|
1502
|
+
# body - A Hash describing the available period with
|
1503
|
+
# symbolized keys:
|
1504
|
+
# :start - A String (ISO-8601 date/time)
|
1505
|
+
# :end - A String (ISO-8601 date/time)
|
1506
|
+
#
|
1507
|
+
# See https://docs.cronofy.com/developers/api/scheduling/available-periods/upsert/
|
1508
|
+
# for reference.
|
1509
|
+
#
|
1510
|
+
# Returns nothing.
|
1511
|
+
#
|
1512
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1513
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1514
|
+
# parameters.
|
1515
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1516
|
+
# limits for the application.
|
1517
|
+
def upsert_available_period(available_period_id, body)
|
1518
|
+
payload = body.merge(available_period_id: available_period_id)
|
1519
|
+
wrapped_request { post("/v1/available_periods", payload) }
|
1520
|
+
nil
|
1521
|
+
end
|
1522
|
+
|
1523
|
+
# Public: Gets all AvailablePeriods for an account.
|
1524
|
+
#
|
1525
|
+
# options - The Hash options used to refine the selection (default: {}):
|
1526
|
+
# :from - The minimum Date from which to return periods
|
1527
|
+
# (optional).
|
1528
|
+
# :to - The Date to return periods up until (optional).
|
1529
|
+
# :tzid - A String representing a known time zone
|
1530
|
+
# identifier from the IANA Time Zone Database
|
1531
|
+
# (default: Etc/UTC).
|
1532
|
+
# :localized_times - A Boolean specifying whether the start and
|
1533
|
+
# end times should be returned with any
|
1534
|
+
# available localization information
|
1535
|
+
# (optional).
|
1536
|
+
#
|
1537
|
+
# Returns an array of AvailablePeriods.
|
1538
|
+
#
|
1539
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1540
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1541
|
+
# parameters.
|
1542
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1543
|
+
# limits for the application.
|
1544
|
+
def get_available_periods(options={})
|
1545
|
+
query = {}
|
1546
|
+
query[:from] = to_iso8601(options[:from]) if options[:from]
|
1547
|
+
query[:to] = to_iso8601(options[:to]) if options[:to]
|
1548
|
+
query[:tzid] = options[:tzid] if options[:tzid]
|
1549
|
+
query[:localized_times] = options[:localized_times] if options[:localized_times]
|
1550
|
+
if query.any?
|
1551
|
+
query_string = "?#{URI.encode_www_form(query)}"
|
1552
|
+
end
|
1553
|
+
|
1554
|
+
response = wrapped_request { get("/v1/available_periods#{query_string}") }
|
1555
|
+
parse_collection(AvailablePeriod, 'available_periods', response)
|
1556
|
+
end
|
1557
|
+
|
1558
|
+
# Public: Deletes an AvailablePeriod.
|
1559
|
+
#
|
1560
|
+
# available_period_id - A String uniquely identifying the available period
|
1561
|
+
# for the authenticated user in your application
|
1562
|
+
#
|
1563
|
+
# Returns nothing.
|
1564
|
+
#
|
1565
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1566
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1567
|
+
# parameters.
|
1568
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1569
|
+
# limits for the application.
|
1570
|
+
def delete_available_period(available_period_id)
|
1571
|
+
wrapped_request { delete("/v1/available_periods", available_period_id: available_period_id) }
|
1572
|
+
nil
|
1573
|
+
end
|
1574
|
+
|
1575
|
+
# Public: Creates a scheduling conversation
|
1576
|
+
#
|
1577
|
+
# pre release end-point documentation to follow
|
1578
|
+
#
|
1579
|
+
def create_scheduling_conversation(body)
|
1580
|
+
response = wrapped_request { post("/v1/scheduling_conversations", body) }
|
1581
|
+
parse_json(SchedulingConversation, 'scheduling_conversation', response)
|
1582
|
+
end
|
1583
|
+
|
1584
|
+
# Public: Creates a scheduling conversation
|
1585
|
+
#
|
1586
|
+
# pre release end-point documentation to follow
|
1587
|
+
#
|
1588
|
+
def get_scheduling_conversation(id)
|
1589
|
+
response = wrapped_request { get("/v1/scheduling_conversations/#{id}") }
|
1590
|
+
parse_json(SchedulingConversation, 'scheduling_conversation', response)
|
1591
|
+
end
|
1592
|
+
|
1593
|
+
# Public: Looks up a scheduling conversation with a token returned by a redirect
|
1594
|
+
#
|
1595
|
+
# pre release end-point documentation to follow
|
1596
|
+
#
|
1597
|
+
def lookup_scheduling_conversation(token)
|
1598
|
+
response = wrapped_request { get("/v1/scheduling_conversations?token=#{token}") }
|
1599
|
+
parse_json(SchedulingConversationResponse, nil, response)
|
1600
|
+
end
|
1601
|
+
|
1602
|
+
# Public: List available slots for a scheduling conversation
|
1603
|
+
#
|
1604
|
+
# pre release end-point documentation to follow
|
1605
|
+
#
|
1606
|
+
def list_scheduling_conversation_participant_slots(url)
|
1607
|
+
response = wrapped_request { get(url) }
|
1608
|
+
parse_collection(SchedulingConversationSlot, "slots", response )
|
1609
|
+
end
|
1610
|
+
|
1611
|
+
# Public: Choose one or more slots for a scheduling conversation
|
1612
|
+
#
|
1613
|
+
# pre release end-point documentation to follow
|
1614
|
+
#
|
1615
|
+
def select_scheduling_conversation_participant_slots(url, args)
|
1616
|
+
response = wrapped_request { post(url, args)}
|
1617
|
+
parse_json(SchedulingConversation, 'scheduling_conversation', response)
|
1618
|
+
end
|
1619
|
+
|
1374
1620
|
private
|
1375
1621
|
|
1376
1622
|
def translate_available_periods(periods)
|
data/lib/cronofy/errors.rb
CHANGED
@@ -68,6 +68,18 @@ module Cronofy
|
|
68
68
|
class PaymentRequiredError < APIError
|
69
69
|
end
|
70
70
|
|
71
|
+
class ServiceUnreachableError < APIError
|
72
|
+
end
|
73
|
+
|
74
|
+
class BadGatewayError < ServiceUnreachableError
|
75
|
+
end
|
76
|
+
|
77
|
+
class ServiceUnavailableError < ServiceUnreachableError
|
78
|
+
end
|
79
|
+
|
80
|
+
class GatewayTimeoutError < ServiceUnreachableError
|
81
|
+
end
|
82
|
+
|
71
83
|
class UnknownError < APIError
|
72
84
|
end
|
73
85
|
|
@@ -83,6 +95,9 @@ module Cronofy
|
|
83
95
|
423 => AccountLockedError,
|
84
96
|
429 => TooManyRequestsError,
|
85
97
|
500 => ServerError,
|
98
|
+
502 => BadGatewayError,
|
99
|
+
503 => ServiceUnavailableError,
|
100
|
+
504 => GatewayTimeoutError,
|
86
101
|
}.freeze
|
87
102
|
|
88
103
|
def self.map_error(error)
|
data/lib/cronofy/types.rb
CHANGED
@@ -387,4 +387,30 @@ module Cronofy
|
|
387
387
|
|
388
388
|
class ElementToken < CronofyMash
|
389
389
|
end
|
390
|
+
|
391
|
+
class SchedulingConversation < CronofyMash
|
392
|
+
end
|
393
|
+
|
394
|
+
class SchedulingConversationResponse < CronofyMash
|
395
|
+
coerce_key :participant, Participant
|
396
|
+
coerce_key :scheduling_conversation, SchedulingConversation
|
397
|
+
end
|
398
|
+
|
399
|
+
class SchedulingConversationSlot < CronofyMash
|
400
|
+
coerce_key :start, EventTime
|
401
|
+
coerce_key :end, EventTime
|
402
|
+
end
|
403
|
+
|
404
|
+
class WeeklyPeriod < CronofyMash
|
405
|
+
end
|
406
|
+
|
407
|
+
module WeeklyPeriodEnumerable
|
408
|
+
def self.coerce(values)
|
409
|
+
values.map { |v| WeeklyPeriod.new(v) }
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
class AvailabilityRule < CronofyMash
|
414
|
+
coerce_key :weekly_periods, WeeklyPeriodEnumerable
|
415
|
+
end
|
390
416
|
end
|
data/lib/cronofy/version.rb
CHANGED
@@ -2630,6 +2630,67 @@ describe Cronofy::Client do
|
|
2630
2630
|
|
2631
2631
|
end
|
2632
2632
|
|
2633
|
+
describe "Remove Recipient Smart Invite", test: true do
|
2634
|
+
let(:request_url) { "https://api.cronofy.com/v1/smart_invites" }
|
2635
|
+
let(:method) { :post }
|
2636
|
+
|
2637
|
+
let(:request_headers) do
|
2638
|
+
{
|
2639
|
+
"Authorization" => "Bearer #{client_secret}",
|
2640
|
+
"User-Agent" => "Cronofy Ruby #{::Cronofy::VERSION}",
|
2641
|
+
"Content-Type" => "application/json; charset=utf-8",
|
2642
|
+
}
|
2643
|
+
end
|
2644
|
+
|
2645
|
+
let(:client_id) { 'example_id' }
|
2646
|
+
let(:client_secret) { 'example_secret' }
|
2647
|
+
|
2648
|
+
let(:client) do
|
2649
|
+
Cronofy::Client.new(
|
2650
|
+
client_id: client_id,
|
2651
|
+
client_secret: client_secret,
|
2652
|
+
)
|
2653
|
+
end
|
2654
|
+
|
2655
|
+
let(:args) do
|
2656
|
+
{
|
2657
|
+
smart_invite_id: "qTtZdczOccgaPncGJaCiLg",
|
2658
|
+
recipient: {
|
2659
|
+
email: "example@example.com"
|
2660
|
+
}
|
2661
|
+
}
|
2662
|
+
end
|
2663
|
+
|
2664
|
+
let(:request_body) do
|
2665
|
+
{
|
2666
|
+
method: 'remove',
|
2667
|
+
smart_invite_id: "qTtZdczOccgaPncGJaCiLg",
|
2668
|
+
recipient: {
|
2669
|
+
email: "example@example.com"
|
2670
|
+
}
|
2671
|
+
}
|
2672
|
+
end
|
2673
|
+
let(:correct_response_code) { 202 }
|
2674
|
+
let(:correct_response_body) do
|
2675
|
+
request_body.merge({
|
2676
|
+
attachments: {
|
2677
|
+
removed: {
|
2678
|
+
email: "example@example.com"
|
2679
|
+
}
|
2680
|
+
}
|
2681
|
+
})
|
2682
|
+
end
|
2683
|
+
|
2684
|
+
let(:correct_mapped_result) do
|
2685
|
+
Cronofy::SmartInviteResponse.new(correct_response_body)
|
2686
|
+
end
|
2687
|
+
|
2688
|
+
subject { client.remove_recipient_smart_invite(request_body) }
|
2689
|
+
|
2690
|
+
it_behaves_like 'a Cronofy request'
|
2691
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2692
|
+
end
|
2693
|
+
|
2633
2694
|
describe "Batch requests" do
|
2634
2695
|
context "upserting an event" do
|
2635
2696
|
let(:calendar_id) { 'calendar_id_123'}
|
@@ -2841,4 +2902,410 @@ describe Cronofy::Client do
|
|
2841
2902
|
end
|
2842
2903
|
end
|
2843
2904
|
end
|
2905
|
+
|
2906
|
+
describe '#create_scheduling_conversation' do
|
2907
|
+
let(:request_url) { 'https://api.cronofy.com/v1/scheduling_conversations' }
|
2908
|
+
let(:method) { :post }
|
2909
|
+
let(:request_body) do
|
2910
|
+
{
|
2911
|
+
"participants" => [
|
2912
|
+
{
|
2913
|
+
"participant_id" => "@grace",
|
2914
|
+
"sub" => "acc_567236000909002",
|
2915
|
+
"slots" => {
|
2916
|
+
"choice_method" => "auto"
|
2917
|
+
}
|
2918
|
+
},
|
2919
|
+
{
|
2920
|
+
"participant_id" => "@karl"
|
2921
|
+
}
|
2922
|
+
],
|
2923
|
+
"required_duration" => { "minutes" => 60 },
|
2924
|
+
"available_periods" => [
|
2925
|
+
{
|
2926
|
+
"start" => "2018-05-01T00:00:00Z",
|
2927
|
+
"end" => "2018-05-08T23:59:59Z"
|
2928
|
+
}
|
2929
|
+
]
|
2930
|
+
}
|
2931
|
+
end
|
2932
|
+
|
2933
|
+
let(:correct_response_code) { 200 }
|
2934
|
+
let(:correct_response_body) do
|
2935
|
+
{
|
2936
|
+
"scheduling_conversation" => {
|
2937
|
+
"scheduling_conversation_id" => "abcd1234"
|
2938
|
+
}
|
2939
|
+
}
|
2940
|
+
end
|
2941
|
+
|
2942
|
+
let(:correct_mapped_result) do
|
2943
|
+
Cronofy::SchedulingConversation.new(scheduling_conversation_id: "abcd1234")
|
2944
|
+
end
|
2945
|
+
|
2946
|
+
subject { client.create_scheduling_conversation(request_body) }
|
2947
|
+
|
2948
|
+
it_behaves_like 'a Cronofy request'
|
2949
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2950
|
+
end
|
2951
|
+
|
2952
|
+
describe '#lookup_scheduling_conversation' do
|
2953
|
+
let(:token) { "hagsdau7g3d" }
|
2954
|
+
let(:request_url) { "https://api.cronofy.com/v1/scheduling_conversations?token=#{token}" }
|
2955
|
+
let(:method) { :get }
|
2956
|
+
|
2957
|
+
let(:correct_response_code) { 200 }
|
2958
|
+
let(:correct_response_body) do
|
2959
|
+
{
|
2960
|
+
"participant" => {
|
2961
|
+
"participant_id" => "83o38hoa"
|
2962
|
+
},
|
2963
|
+
"scheduling_conversation" => {
|
2964
|
+
"scheduling_conversation_id" => "abcd1234"
|
2965
|
+
},
|
2966
|
+
}
|
2967
|
+
end
|
2968
|
+
|
2969
|
+
let(:correct_mapped_result) do
|
2970
|
+
Cronofy::SchedulingConversationResponse.new(
|
2971
|
+
participant: Cronofy::Participant.new(participant_id: "83o38hoa"),
|
2972
|
+
scheduling_conversation: Cronofy::SchedulingConversation.new(scheduling_conversation_id: "abcd1234"),
|
2973
|
+
)
|
2974
|
+
end
|
2975
|
+
|
2976
|
+
subject { client.lookup_scheduling_conversation(token) }
|
2977
|
+
|
2978
|
+
it_behaves_like 'a Cronofy request'
|
2979
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2980
|
+
end
|
2981
|
+
|
2982
|
+
describe '#upsert_availability_rule' do
|
2983
|
+
let(:request_url) { 'https://api.cronofy.com/v1/availability_rules' }
|
2984
|
+
let(:method) { :post }
|
2985
|
+
let(:request_body) do
|
2986
|
+
{
|
2987
|
+
"availability_rule_id" => "default",
|
2988
|
+
"tzid" => "America/Chicago",
|
2989
|
+
"calendar_ids" => [
|
2990
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
2991
|
+
],
|
2992
|
+
"weekly_periods" => [
|
2993
|
+
{
|
2994
|
+
"day" => "monday",
|
2995
|
+
"start_time" => "09:30",
|
2996
|
+
"end_time" => "16:30"
|
2997
|
+
},
|
2998
|
+
{
|
2999
|
+
"day" => "wednesday",
|
3000
|
+
"start_time" => "09:30",
|
3001
|
+
"end_time" => "16:30"
|
3002
|
+
}
|
3003
|
+
]
|
3004
|
+
}
|
3005
|
+
end
|
3006
|
+
|
3007
|
+
let(:correct_response_code) { 200 }
|
3008
|
+
let(:correct_response_body) do
|
3009
|
+
{
|
3010
|
+
"availability_rule" => {
|
3011
|
+
"availability_rule_id" => "default",
|
3012
|
+
"tzid" => "America/Chicago",
|
3013
|
+
"calendar_ids" => [
|
3014
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
3015
|
+
],
|
3016
|
+
"weekly_periods" => [
|
3017
|
+
{
|
3018
|
+
"day" => "monday",
|
3019
|
+
"start_time" => "09:30",
|
3020
|
+
"end_time" => "16:30"
|
3021
|
+
},
|
3022
|
+
{
|
3023
|
+
"day" => "wednesday",
|
3024
|
+
"start_time" => "09:30",
|
3025
|
+
"end_time" => "16:30"
|
3026
|
+
}
|
3027
|
+
]
|
3028
|
+
}
|
3029
|
+
}
|
3030
|
+
end
|
3031
|
+
|
3032
|
+
let(:correct_mapped_result) do
|
3033
|
+
Cronofy::AvailabilityRule.new(
|
3034
|
+
availability_rule_id: request_body['availability_rule_id'],
|
3035
|
+
tzid: request_body['tzid'],
|
3036
|
+
calendar_ids: request_body['calendar_ids'],
|
3037
|
+
weekly_periods: request_body['weekly_periods'].map { |wp| Cronofy::WeeklyPeriod.new(wp) },
|
3038
|
+
)
|
3039
|
+
end
|
3040
|
+
|
3041
|
+
subject { client.upsert_availability_rule(request_body) }
|
3042
|
+
|
3043
|
+
it_behaves_like 'a Cronofy request'
|
3044
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3045
|
+
end
|
3046
|
+
|
3047
|
+
describe "#get_availability_rule" do
|
3048
|
+
let(:availability_rule_id) { 'default'}
|
3049
|
+
let(:request_url) { "https://api.cronofy.com/v1/availability_rules/#{availability_rule_id}" }
|
3050
|
+
let(:method) { :get }
|
3051
|
+
|
3052
|
+
let(:correct_response_code) { 200 }
|
3053
|
+
let(:correct_response_body) do
|
3054
|
+
{
|
3055
|
+
"availability_rule" => {
|
3056
|
+
"availability_rule_id" => "default",
|
3057
|
+
"tzid" => "America/Chicago",
|
3058
|
+
"calendar_ids" => [
|
3059
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
3060
|
+
],
|
3061
|
+
"weekly_periods" => [
|
3062
|
+
{
|
3063
|
+
"day" => "monday",
|
3064
|
+
"start_time" => "09:30",
|
3065
|
+
"end_time" => "16:30"
|
3066
|
+
},
|
3067
|
+
{
|
3068
|
+
"day" => "wednesday",
|
3069
|
+
"start_time" => "09:30",
|
3070
|
+
"end_time" => "16:30"
|
3071
|
+
}
|
3072
|
+
]
|
3073
|
+
}
|
3074
|
+
}
|
3075
|
+
end
|
3076
|
+
|
3077
|
+
let(:correct_mapped_result) do
|
3078
|
+
rule = correct_response_body['availability_rule']
|
3079
|
+
Cronofy::AvailabilityRule.new(
|
3080
|
+
availability_rule_id: rule['availability_rule_id'],
|
3081
|
+
tzid: rule['tzid'],
|
3082
|
+
calendar_ids: rule['calendar_ids'],
|
3083
|
+
weekly_periods: rule['weekly_periods'].map { |wp| Cronofy::WeeklyPeriod.new(wp) },
|
3084
|
+
)
|
3085
|
+
end
|
3086
|
+
|
3087
|
+
subject { client.get_availability_rule(availability_rule_id) }
|
3088
|
+
|
3089
|
+
it_behaves_like 'a Cronofy request'
|
3090
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3091
|
+
end
|
3092
|
+
|
3093
|
+
describe "#get_availability_rules" do
|
3094
|
+
let(:request_url) { "https://api.cronofy.com/v1/availability_rules" }
|
3095
|
+
let(:method) { :get }
|
3096
|
+
|
3097
|
+
let(:correct_response_code) { 200 }
|
3098
|
+
let(:correct_response_body) do
|
3099
|
+
{
|
3100
|
+
"availability_rules" => [
|
3101
|
+
{
|
3102
|
+
"availability_rule_id" => "default",
|
3103
|
+
"tzid" => "America/Chicago",
|
3104
|
+
"calendar_ids" => [
|
3105
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
3106
|
+
],
|
3107
|
+
"weekly_periods" => [
|
3108
|
+
{
|
3109
|
+
"day" => "monday",
|
3110
|
+
"start_time" => "09:30",
|
3111
|
+
"end_time" => "16:30"
|
3112
|
+
},
|
3113
|
+
{
|
3114
|
+
"day" => "wednesday",
|
3115
|
+
"start_time" => "09:30",
|
3116
|
+
"end_time" => "16:30"
|
3117
|
+
}
|
3118
|
+
]
|
3119
|
+
}
|
3120
|
+
]
|
3121
|
+
}
|
3122
|
+
end
|
3123
|
+
|
3124
|
+
let(:correct_mapped_result) do
|
3125
|
+
rule = correct_response_body['availability_rules'][0]
|
3126
|
+
|
3127
|
+
[
|
3128
|
+
Cronofy::AvailabilityRule.new(
|
3129
|
+
availability_rule_id: rule['availability_rule_id'],
|
3130
|
+
tzid: rule['tzid'],
|
3131
|
+
calendar_ids: rule['calendar_ids'],
|
3132
|
+
weekly_periods: rule['weekly_periods'].map { |wp| Cronofy::WeeklyPeriod.new(wp) },
|
3133
|
+
)
|
3134
|
+
]
|
3135
|
+
end
|
3136
|
+
|
3137
|
+
subject { client.get_availability_rules }
|
3138
|
+
|
3139
|
+
it_behaves_like 'a Cronofy request'
|
3140
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3141
|
+
end
|
3142
|
+
|
3143
|
+
describe '#delete_availability_rule' do
|
3144
|
+
let(:availability_rule_id) { 'default'}
|
3145
|
+
let(:request_url) { "https://api.cronofy.com/v1/availability_rules/#{availability_rule_id}" }
|
3146
|
+
let(:method) { :delete }
|
3147
|
+
let(:request_body) { nil }
|
3148
|
+
let(:correct_response_code) { 202 }
|
3149
|
+
let(:correct_response_body) { nil }
|
3150
|
+
|
3151
|
+
subject { client.delete_availability_rule(availability_rule_id) }
|
3152
|
+
|
3153
|
+
it_behaves_like 'a Cronofy request'
|
3154
|
+
end
|
3155
|
+
|
3156
|
+
describe "#upsert_available_period" do
|
3157
|
+
let(:request_url) { 'https://api.cronofy.com/v1/available_periods' }
|
3158
|
+
let(:method) { :post }
|
3159
|
+
let(:available_period_id) { "test" }
|
3160
|
+
let(:request_body) do
|
3161
|
+
{
|
3162
|
+
available_period_id: available_period_id,
|
3163
|
+
start: "2020-07-26T15:30:00Z",
|
3164
|
+
end: "2020-07-26T17:00:00Z"
|
3165
|
+
}
|
3166
|
+
end
|
3167
|
+
|
3168
|
+
let(:correct_response_code) { 202 }
|
3169
|
+
let(:correct_response_body) { "" }
|
3170
|
+
let(:correct_mapped_result) { nil }
|
3171
|
+
|
3172
|
+
subject {
|
3173
|
+
client.upsert_available_period(available_period_id,
|
3174
|
+
start: request_body[:start],
|
3175
|
+
end: request_body[:end]
|
3176
|
+
)
|
3177
|
+
}
|
3178
|
+
|
3179
|
+
it_behaves_like 'a Cronofy request'
|
3180
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3181
|
+
end
|
3182
|
+
|
3183
|
+
describe "#get_available_periods" do
|
3184
|
+
context "unfiltered" do
|
3185
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods" }
|
3186
|
+
let(:method) { :get }
|
3187
|
+
|
3188
|
+
let(:correct_response_code) { 200 }
|
3189
|
+
let(:correct_response_body) do
|
3190
|
+
{
|
3191
|
+
"available_periods" => [
|
3192
|
+
{
|
3193
|
+
"available_period_id" => "qTtZdczOccgaPncGJaCiLg",
|
3194
|
+
"start" => "2020-07-26T15:30:00Z",
|
3195
|
+
"end" => "2020-07-26T17:00:00Z"
|
3196
|
+
}
|
3197
|
+
]
|
3198
|
+
}
|
3199
|
+
end
|
3200
|
+
|
3201
|
+
let(:correct_mapped_result) do
|
3202
|
+
period = correct_response_body['available_periods'][0]
|
3203
|
+
|
3204
|
+
[
|
3205
|
+
Cronofy::AvailablePeriod.new(
|
3206
|
+
available_period_id: period['available_period_id'],
|
3207
|
+
start: period['start'],
|
3208
|
+
end: period['end']
|
3209
|
+
)
|
3210
|
+
]
|
3211
|
+
end
|
3212
|
+
|
3213
|
+
subject { client.get_available_periods }
|
3214
|
+
|
3215
|
+
it_behaves_like 'a Cronofy request'
|
3216
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3217
|
+
end
|
3218
|
+
|
3219
|
+
context "filterd by date range" do
|
3220
|
+
let(:tzid) { "America/New_York" }
|
3221
|
+
let(:from) { "2020-07-01" }
|
3222
|
+
let(:to) { "2020-07-31" }
|
3223
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods?from=#{from}&to=#{to}&tzid=#{tzid}" }
|
3224
|
+
let(:method) { :get }
|
3225
|
+
|
3226
|
+
let(:correct_response_code) { 200 }
|
3227
|
+
let(:correct_response_body) do
|
3228
|
+
{
|
3229
|
+
"available_periods" => [
|
3230
|
+
{
|
3231
|
+
"available_period_id" => "qTtZdczOccgaPncGJaCiLg",
|
3232
|
+
"start" => "2020-07-26T15:30:00Z",
|
3233
|
+
"end" => "2020-07-26T17:00:00Z"
|
3234
|
+
}
|
3235
|
+
]
|
3236
|
+
}
|
3237
|
+
end
|
3238
|
+
|
3239
|
+
let(:correct_mapped_result) do
|
3240
|
+
period = correct_response_body['available_periods'][0]
|
3241
|
+
|
3242
|
+
[
|
3243
|
+
Cronofy::AvailablePeriod.new(
|
3244
|
+
available_period_id: period['available_period_id'],
|
3245
|
+
start: period['start'],
|
3246
|
+
end: period['end']
|
3247
|
+
)
|
3248
|
+
]
|
3249
|
+
end
|
3250
|
+
|
3251
|
+
subject { client.get_available_periods(from: from, to: to, tzid: tzid) }
|
3252
|
+
|
3253
|
+
it_behaves_like 'a Cronofy request'
|
3254
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3255
|
+
end
|
3256
|
+
|
3257
|
+
context "requesting localized times" do
|
3258
|
+
let(:tzid) { "America/New_York" }
|
3259
|
+
let(:localized_times) { true }
|
3260
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods?tzid=#{tzid}&localized_times=true" }
|
3261
|
+
let(:method) { :get }
|
3262
|
+
|
3263
|
+
let(:correct_response_code) { 200 }
|
3264
|
+
let(:correct_response_body) do
|
3265
|
+
{
|
3266
|
+
"available_periods" => [
|
3267
|
+
{
|
3268
|
+
"available_period_id" => "qTtZdczOccgaPncGJaCiLg",
|
3269
|
+
"start" => "2020-07-26T15:30:00Z",
|
3270
|
+
"end" => "2020-07-26T17:00:00Z"
|
3271
|
+
}
|
3272
|
+
]
|
3273
|
+
}
|
3274
|
+
end
|
3275
|
+
|
3276
|
+
let(:correct_mapped_result) do
|
3277
|
+
period = correct_response_body['available_periods'][0]
|
3278
|
+
|
3279
|
+
[
|
3280
|
+
Cronofy::AvailablePeriod.new(
|
3281
|
+
available_period_id: period['available_period_id'],
|
3282
|
+
start: period['start'],
|
3283
|
+
end: period['end']
|
3284
|
+
)
|
3285
|
+
]
|
3286
|
+
end
|
3287
|
+
|
3288
|
+
subject { client.get_available_periods(tzid: tzid, localized_times: true) }
|
3289
|
+
|
3290
|
+
it_behaves_like 'a Cronofy request'
|
3291
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3292
|
+
end
|
3293
|
+
end
|
3294
|
+
|
3295
|
+
describe '#delete_available_period' do
|
3296
|
+
let(:available_period_id) { 'default'}
|
3297
|
+
let(:request_url) { "https://api.cronofy.com/v1/available_periods" }
|
3298
|
+
let(:method) { :delete }
|
3299
|
+
let(:request_body) {
|
3300
|
+
{ available_period_id: available_period_id}
|
3301
|
+
}
|
3302
|
+
let(:correct_response_code) { 202 }
|
3303
|
+
let(:correct_response_body) { "" }
|
3304
|
+
let(:correct_mapped_result) { nil }
|
3305
|
+
|
3306
|
+
subject { client.delete_available_period(available_period_id) }
|
3307
|
+
|
3308
|
+
it_behaves_like 'a Cronofy request'
|
3309
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3310
|
+
end
|
2844
3311
|
end
|
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.
|
4
|
+
version: 0.36.0
|
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: 2020-09-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|
@@ -99,14 +99,14 @@ dependencies:
|
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 3.9.1
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - "~>"
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
109
|
+
version: 3.9.1
|
110
110
|
description: Ruby wrapper for Cronofy's unified calendar API
|
111
111
|
email:
|
112
112
|
- parizhskiy@gmail.com
|
@@ -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.1.2
|
160
|
+
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Cronofy - one API for all the calendars
|
163
163
|
test_files:
|