cronofy 0.31.2 → 0.32.0
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 +127 -1
- data/lib/cronofy/types.rb +26 -0
- data/lib/cronofy/version.rb +1 -1
- data/spec/lib/cronofy/client_spec.rb +200 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f29c174e71afa774e39cc40e852e3c95b60135bf076596adebfa302d0b1457d
|
4
|
+
data.tar.gz: e41e9a034f53aea943c74e9cff922713beda7edc9fb3d765ee2a31481ce6d236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8263c12831f387bdbc43bdb754f2546bcdefba7021a834d556c07620f0c7f67a85dddf37ac7b70f052750bba8ef247680b0ac5843a3c00025283112d38bd205
|
7
|
+
data.tar.gz: 4648a9b821c575337165a2d395d85b359a5d882184dc17bff41ae9e792a37d62b048e2b610d185b06d80ccd20abe8ba15e8f0e3b27187b11ff25ca7518cf6879
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [0.32.0]
|
2
|
+
|
3
|
+
* Support Availability Rules and Scheduling Conversations [#64]
|
4
|
+
|
1
5
|
## [0.31.2]
|
2
6
|
|
3
7
|
* Support parsing new Availability response formats [#73]
|
@@ -142,6 +146,7 @@
|
|
142
146
|
[0.31.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.0
|
143
147
|
[0.31.1]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.1
|
144
148
|
[0.31.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.31.2
|
149
|
+
[0.32.0]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.32.0
|
145
150
|
|
146
151
|
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
|
147
152
|
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
|
@@ -174,6 +179,7 @@
|
|
174
179
|
[#59]: https://github.com/cronofy/cronofy-ruby/pull/59
|
175
180
|
[#60]: https://github.com/cronofy/cronofy-ruby/pull/60
|
176
181
|
[#62]: https://github.com/cronofy/cronofy-ruby/pull/62
|
182
|
+
[#64]: https://github.com/cronofy/cronofy-ruby/pull/64
|
177
183
|
[#69]: https://github.com/cronofy/cronofy-ruby/pull/69
|
178
184
|
[#72]: https://github.com/cronofy/cronofy-ruby/pull/72
|
179
185
|
[#73]: https://github.com/cronofy/cronofy-ruby/pull/73
|
data/lib/cronofy/client.rb
CHANGED
@@ -1344,7 +1344,6 @@ module Cronofy
|
|
1344
1344
|
parse_json(SmartInviteResponse, nil, response)
|
1345
1345
|
end
|
1346
1346
|
|
1347
|
-
|
1348
1347
|
# Public: Creates an element_token to pass to a UI Element
|
1349
1348
|
#
|
1350
1349
|
# options - A Hash of options for the token
|
@@ -1371,6 +1370,133 @@ module Cronofy
|
|
1371
1370
|
parse_json(ElementToken, "element_token", response)
|
1372
1371
|
end
|
1373
1372
|
|
1373
|
+
# Public: Creates or updates an AvailabilityRule.
|
1374
|
+
#
|
1375
|
+
# availability_rule_id - A String uniquely identifying the availability rule
|
1376
|
+
# for the authenticated user in your application
|
1377
|
+
# (note: this is NOT an ID generated by Cronofy).
|
1378
|
+
# tzid - The time zone identifier for the rule.
|
1379
|
+
# calendar_ids - An optional array of calendar_ids that should impact the
|
1380
|
+
# user's availability.
|
1381
|
+
# weekly_periods - An array of objects describing a weekly recurring available period
|
1382
|
+
# :day - A String for the week day
|
1383
|
+
# :start_time - A String for 24hr time that period starts eg: 09:30
|
1384
|
+
# :end_time - A String for 24hr time that period ends eg: 17:30
|
1385
|
+
# Examples
|
1386
|
+
#
|
1387
|
+
# client.upsert_availability_rule(
|
1388
|
+
# availability_rule_id: "qTtZdczOccgaPncGJaCiLg",
|
1389
|
+
# tzid: "America/Chicago",
|
1390
|
+
# calendar_ids: [
|
1391
|
+
# "cal_n23kjnwrw2_jsdfjksn234"
|
1392
|
+
# ],
|
1393
|
+
# weekly_periods: [
|
1394
|
+
# {
|
1395
|
+
# day: "monday",
|
1396
|
+
# start_time: "09:30",
|
1397
|
+
# end_time: "12:30",
|
1398
|
+
# },
|
1399
|
+
# {
|
1400
|
+
# day: "tuesday",
|
1401
|
+
# start_time: "09:30",
|
1402
|
+
# end_time: "12:30",
|
1403
|
+
# }
|
1404
|
+
# ]
|
1405
|
+
# )
|
1406
|
+
#
|
1407
|
+
# See http://www.cronofy.com/developers/alpha/api#availability_rules for reference.
|
1408
|
+
#
|
1409
|
+
# Returns an AvailabilityRuleResponse.
|
1410
|
+
#
|
1411
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1412
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1413
|
+
# parameters.
|
1414
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1415
|
+
# limits for the application.
|
1416
|
+
def upsert_availability_rule(body)
|
1417
|
+
response = wrapped_request { post("/v1/availability_rules", body) }
|
1418
|
+
parse_json(AvailabilityRule, 'availability_rule', response)
|
1419
|
+
end
|
1420
|
+
|
1421
|
+
# Public: Gets an AvailabilityRule.
|
1422
|
+
#
|
1423
|
+
# availability_rule_id - A String uniquely identifying the availability rule
|
1424
|
+
# for the authenticated user in your application
|
1425
|
+
#
|
1426
|
+
# Returns an AvailabilityRuleResponse.
|
1427
|
+
#
|
1428
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1429
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1430
|
+
# parameters.
|
1431
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1432
|
+
# limits for the application.
|
1433
|
+
def get_availability_rule(availability_rule_id)
|
1434
|
+
response = wrapped_request { get("/v1/availability_rules/#{availability_rule_id}") }
|
1435
|
+
parse_json(AvailabilityRule, 'availability_rule', response)
|
1436
|
+
end
|
1437
|
+
|
1438
|
+
# Public: Deletes an AvailabilityRule.
|
1439
|
+
#
|
1440
|
+
# availability_rule_id - A String uniquely identifying the availability rule
|
1441
|
+
# for the authenticated user in your application
|
1442
|
+
#
|
1443
|
+
# Returns nothing.
|
1444
|
+
#
|
1445
|
+
# Raises Cronofy::CredentialsMissingError if no credentials available.
|
1446
|
+
# Raises Cronofy::InvalidRequestError if the request contains invalid
|
1447
|
+
# parameters.
|
1448
|
+
# Raises Cronofy::TooManyRequestsError if the request exceeds the rate
|
1449
|
+
# limits for the application.
|
1450
|
+
def delete_availability_rule(availability_rule_id)
|
1451
|
+
wrapped_request { delete("/v1/availability_rules/#{availability_rule_id}") }
|
1452
|
+
nil
|
1453
|
+
end
|
1454
|
+
|
1455
|
+
# Public: Creates a scheduling conversation
|
1456
|
+
#
|
1457
|
+
# pre release end-point documentation to follow
|
1458
|
+
#
|
1459
|
+
def create_scheduling_conversation(body)
|
1460
|
+
response = wrapped_request { post("/v1/scheduling_conversations", body) }
|
1461
|
+
parse_json(SchedulingConversation, 'scheduling_conversation', response)
|
1462
|
+
end
|
1463
|
+
|
1464
|
+
# Public: Creates a scheduling conversation
|
1465
|
+
#
|
1466
|
+
# pre release end-point documentation to follow
|
1467
|
+
#
|
1468
|
+
def get_scheduling_conversation(id)
|
1469
|
+
response = wrapped_request { get("/v1/scheduling_conversations/#{id}") }
|
1470
|
+
parse_json(SchedulingConversation, 'scheduling_conversation', response)
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
# Public: Looks up a scheduling conversation with a token returned by a redirect
|
1474
|
+
#
|
1475
|
+
# pre release end-point documentation to follow
|
1476
|
+
#
|
1477
|
+
def lookup_scheduling_conversation(token)
|
1478
|
+
response = wrapped_request { get("/v1/scheduling_conversations?token=#{token}") }
|
1479
|
+
parse_json(SchedulingConversationResponse, nil, response)
|
1480
|
+
end
|
1481
|
+
|
1482
|
+
# Public: List available slots for a scheduling conversation
|
1483
|
+
#
|
1484
|
+
# pre release end-point documentation to follow
|
1485
|
+
#
|
1486
|
+
def list_scheduling_conversation_participant_slots(url)
|
1487
|
+
response = wrapped_request { get(url) }
|
1488
|
+
parse_collection(SchedulingConversationSlot, "slots", response )
|
1489
|
+
end
|
1490
|
+
|
1491
|
+
# Public: Choose one or more slots for a scheduling conversation
|
1492
|
+
#
|
1493
|
+
# pre release end-point documentation to follow
|
1494
|
+
#
|
1495
|
+
def select_scheduling_conversation_participant_slots(url, args)
|
1496
|
+
response = wrapped_request { post(url, args)}
|
1497
|
+
parse_json(SchedulingConversation, 'scheduling_conversation', response)
|
1498
|
+
end
|
1499
|
+
|
1374
1500
|
private
|
1375
1501
|
|
1376
1502
|
def translate_available_periods(periods)
|
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
@@ -2841,4 +2841,204 @@ describe Cronofy::Client do
|
|
2841
2841
|
end
|
2842
2842
|
end
|
2843
2843
|
end
|
2844
|
+
|
2845
|
+
describe '#create_scheduling_conversation' do
|
2846
|
+
let(:request_url) { 'https://api.cronofy.com/v1/scheduling_conversations' }
|
2847
|
+
let(:method) { :post }
|
2848
|
+
let(:request_body) do
|
2849
|
+
{
|
2850
|
+
"participants" => [
|
2851
|
+
{
|
2852
|
+
"participant_id" => "@grace",
|
2853
|
+
"sub" => "acc_567236000909002",
|
2854
|
+
"slots" => {
|
2855
|
+
"choice_method" => "auto"
|
2856
|
+
}
|
2857
|
+
},
|
2858
|
+
{
|
2859
|
+
"participant_id" => "@karl"
|
2860
|
+
}
|
2861
|
+
],
|
2862
|
+
"required_duration" => { "minutes" => 60 },
|
2863
|
+
"available_periods" => [
|
2864
|
+
{
|
2865
|
+
"start" => "2018-05-01T00:00:00Z",
|
2866
|
+
"end" => "2018-05-08T23:59:59Z"
|
2867
|
+
}
|
2868
|
+
]
|
2869
|
+
}
|
2870
|
+
end
|
2871
|
+
|
2872
|
+
let(:correct_response_code) { 200 }
|
2873
|
+
let(:correct_response_body) do
|
2874
|
+
{
|
2875
|
+
"scheduling_conversation" => {
|
2876
|
+
"scheduling_conversation_id" => "abcd1234"
|
2877
|
+
}
|
2878
|
+
}
|
2879
|
+
end
|
2880
|
+
|
2881
|
+
let(:correct_mapped_result) do
|
2882
|
+
Cronofy::SchedulingConversation.new(scheduling_conversation_id: "abcd1234")
|
2883
|
+
end
|
2884
|
+
|
2885
|
+
subject { client.create_scheduling_conversation(request_body) }
|
2886
|
+
|
2887
|
+
it_behaves_like 'a Cronofy request'
|
2888
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2889
|
+
end
|
2890
|
+
|
2891
|
+
describe '#lookup_scheduling_conversation' do
|
2892
|
+
let(:token) { "hagsdau7g3d" }
|
2893
|
+
let(:request_url) { "https://api.cronofy.com/v1/scheduling_conversations?token=#{token}" }
|
2894
|
+
let(:method) { :get }
|
2895
|
+
|
2896
|
+
let(:correct_response_code) { 200 }
|
2897
|
+
let(:correct_response_body) do
|
2898
|
+
{
|
2899
|
+
"participant" => {
|
2900
|
+
"participant_id" => "83o38hoa"
|
2901
|
+
},
|
2902
|
+
"scheduling_conversation" => {
|
2903
|
+
"scheduling_conversation_id" => "abcd1234"
|
2904
|
+
},
|
2905
|
+
}
|
2906
|
+
end
|
2907
|
+
|
2908
|
+
let(:correct_mapped_result) do
|
2909
|
+
Cronofy::SchedulingConversationResponse.new(
|
2910
|
+
participant: Cronofy::Participant.new(participant_id: "83o38hoa"),
|
2911
|
+
scheduling_conversation: Cronofy::SchedulingConversation.new(scheduling_conversation_id: "abcd1234"),
|
2912
|
+
)
|
2913
|
+
end
|
2914
|
+
|
2915
|
+
subject { client.lookup_scheduling_conversation(token) }
|
2916
|
+
|
2917
|
+
it_behaves_like 'a Cronofy request'
|
2918
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2919
|
+
end
|
2920
|
+
|
2921
|
+
describe '#upsert_availability_rule' do
|
2922
|
+
let(:request_url) { 'https://api.cronofy.com/v1/availability_rules' }
|
2923
|
+
let(:method) { :post }
|
2924
|
+
let(:request_body) do
|
2925
|
+
{
|
2926
|
+
"availability_rule_id" => "default",
|
2927
|
+
"tzid" => "America/Chicago",
|
2928
|
+
"calendar_ids" => [
|
2929
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
2930
|
+
],
|
2931
|
+
"weekly_periods" => [
|
2932
|
+
{
|
2933
|
+
"day" => "monday",
|
2934
|
+
"start_time" => "09:30",
|
2935
|
+
"end_time" => "16:30"
|
2936
|
+
},
|
2937
|
+
{
|
2938
|
+
"day" => "wednesday",
|
2939
|
+
"start_time" => "09:30",
|
2940
|
+
"end_time" => "16:30"
|
2941
|
+
}
|
2942
|
+
]
|
2943
|
+
}
|
2944
|
+
end
|
2945
|
+
|
2946
|
+
let(:correct_response_code) { 200 }
|
2947
|
+
let(:correct_response_body) do
|
2948
|
+
{
|
2949
|
+
"availability_rule" => {
|
2950
|
+
"availability_rule_id" => "default",
|
2951
|
+
"tzid" => "America/Chicago",
|
2952
|
+
"calendar_ids" => [
|
2953
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
2954
|
+
],
|
2955
|
+
"weekly_periods" => [
|
2956
|
+
{
|
2957
|
+
"day" => "monday",
|
2958
|
+
"start_time" => "09:30",
|
2959
|
+
"end_time" => "16:30"
|
2960
|
+
},
|
2961
|
+
{
|
2962
|
+
"day" => "wednesday",
|
2963
|
+
"start_time" => "09:30",
|
2964
|
+
"end_time" => "16:30"
|
2965
|
+
}
|
2966
|
+
]
|
2967
|
+
}
|
2968
|
+
}
|
2969
|
+
end
|
2970
|
+
|
2971
|
+
let(:correct_mapped_result) do
|
2972
|
+
Cronofy::AvailabilityRule.new(
|
2973
|
+
availability_rule_id: request_body['availability_rule_id'],
|
2974
|
+
tzid: request_body['tzid'],
|
2975
|
+
calendar_ids: request_body['calendar_ids'],
|
2976
|
+
weekly_periods: request_body['weekly_periods'].map { |wp| Cronofy::WeeklyPeriod.new(wp) },
|
2977
|
+
)
|
2978
|
+
end
|
2979
|
+
|
2980
|
+
subject { client.upsert_availability_rule(request_body) }
|
2981
|
+
|
2982
|
+
it_behaves_like 'a Cronofy request'
|
2983
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
2984
|
+
end
|
2985
|
+
|
2986
|
+
describe "#get_availability_rule" do
|
2987
|
+
let(:availability_rule_id) { 'default'}
|
2988
|
+
let(:request_url) { "https://api.cronofy.com/v1/availability_rules/#{availability_rule_id}" }
|
2989
|
+
let(:method) { :get }
|
2990
|
+
|
2991
|
+
let(:correct_response_code) { 200 }
|
2992
|
+
let(:correct_response_body) do
|
2993
|
+
{
|
2994
|
+
"availability_rule" => {
|
2995
|
+
"availability_rule_id" => "default",
|
2996
|
+
"tzid" => "America/Chicago",
|
2997
|
+
"calendar_ids" => [
|
2998
|
+
"cal_n23kjnwrw2_jsdfjksn234"
|
2999
|
+
],
|
3000
|
+
"weekly_periods" => [
|
3001
|
+
{
|
3002
|
+
"day" => "monday",
|
3003
|
+
"start_time" => "09:30",
|
3004
|
+
"end_time" => "16:30"
|
3005
|
+
},
|
3006
|
+
{
|
3007
|
+
"day" => "wednesday",
|
3008
|
+
"start_time" => "09:30",
|
3009
|
+
"end_time" => "16:30"
|
3010
|
+
}
|
3011
|
+
]
|
3012
|
+
}
|
3013
|
+
}
|
3014
|
+
end
|
3015
|
+
|
3016
|
+
let(:correct_mapped_result) do
|
3017
|
+
rule = correct_response_body['availability_rule']
|
3018
|
+
Cronofy::AvailabilityRule.new(
|
3019
|
+
availability_rule_id: rule['availability_rule_id'],
|
3020
|
+
tzid: rule['tzid'],
|
3021
|
+
calendar_ids: rule['calendar_ids'],
|
3022
|
+
weekly_periods: rule['weekly_periods'].map { |wp| Cronofy::WeeklyPeriod.new(wp) },
|
3023
|
+
)
|
3024
|
+
end
|
3025
|
+
|
3026
|
+
subject { client.get_availability_rule(availability_rule_id) }
|
3027
|
+
|
3028
|
+
it_behaves_like 'a Cronofy request'
|
3029
|
+
it_behaves_like 'a Cronofy request with mapped return value'
|
3030
|
+
end
|
3031
|
+
|
3032
|
+
describe '#delete_availability_rule' do
|
3033
|
+
let(:availability_rule_id) { 'default'}
|
3034
|
+
let(:request_url) { "https://api.cronofy.com/v1/availability_rules/#{availability_rule_id}" }
|
3035
|
+
let(:method) { :delete }
|
3036
|
+
let(:request_body) { nil }
|
3037
|
+
let(:correct_response_code) { 202 }
|
3038
|
+
let(:correct_response_body) { nil }
|
3039
|
+
|
3040
|
+
subject { client.delete_availability_rule(availability_rule_id) }
|
3041
|
+
|
3042
|
+
it_behaves_like 'a Cronofy request'
|
3043
|
+
end
|
2844
3044
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.32.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: 2019-06-
|
12
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oauth2
|