Skip to content

Commit 68a391d

Browse files
authored
Merge pull request #99 from cronofy/query-periods
Support query periods for Real-Time Scheduling and Real-Time Sequencing
2 parents 1a8baf1 + 81e8772 commit 68a391d

File tree

6 files changed

+51
-16
lines changed

6 files changed

+51
-16
lines changed

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby 2.7.5

CHANGELOG.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1+
## [0.37.5]
2+
3+
* Support `query_periods` as well as the original `available_periods` for Real-Time Scheduling and Real-Time Sequencing [#99]
4+
15
## [0.37.4]
26

3-
* Support client_secret only clients being able to authorize `#availability` calls. [#97]
7+
* Support client_secret only clients being able to authorize `#availability` calls. [#97]
48

59
## [0.37.3]
610

7-
* Support `hmac_valid` as well as the original `hmac_match` for Client to verify a HMAC from a push notification using the client's secret.[#95]
11+
* Support `hmac_valid` as well as the original `hmac_match` for Client to verify a HMAC from a push notification using the client's secret.[#95]
812

913
## [0.37.2]
1014

11-
* Support `query_periods` as well as the original `available_periods` for Availability Query and Sequenced Availability [#91]
15+
* Support `query_periods` as well as the original `available_periods` for Availability Query and Sequenced Availability [#91]
1216

1317
## [0.37.1]
1418

15-
* Rename `data_centre` to `data_centre` (with aliases for backwards compatibility) [#90]
19+
* Rename `data_centre` to `data_centre` (with aliases for backwards compatibility) [#90]
1620

1721
## [0.37.0]
1822

19-
* Add `revoke_by_token` and `revoke_by_sub` to the Client [#86]
23+
* Add `revoke_by_token` and `revoke_by_sub` to the Client [#86]
2024

2125
## [0.36.1]
2226

@@ -197,6 +201,7 @@
197201
[0.37.2]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.2
198202
[0.37.3]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.3
199203
[0.37.4]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.4
204+
[0.37.5]: https://github.com/cronofy/cronofy-ruby/releases/tag/v0.37.5
200205

201206
[#13]: https://github.com/cronofy/cronofy-ruby/pull/13
202207
[#16]: https://github.com/cronofy/cronofy-ruby/pull/16
@@ -243,3 +248,4 @@
243248
[#91]: https://github.com/cronofy/cronofy-ruby/pull/91
244249
[#95]: https://github.com/cronofy/cronofy-ruby/pull/95
245250
[#97]: https://github.com/cronofy/cronofy-ruby/pull/97
251+
[#99]: https://github.com/cronofy/cronofy-ruby/pull/99

lib/cronofy/client.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,7 +1033,7 @@ def add_to_calendar(args = {})
10331033
# call
10341034
# :required_duration - A hash stating the length of time the event will
10351035
# last for
1036-
# :available_periods - A hash stating the available periods for the event
1036+
# :query_periods - A hash stating the available periods for the event
10371037
# :start_interval - An Integer representing the start interval
10381038
# of minutes for the availability query.
10391039
# :buffer - An Hash containing the buffer to apply to
@@ -1069,7 +1069,7 @@ def add_to_calendar(args = {})
10691069
# }
10701070
# ],
10711071
# required_duration: { minutes: 60 },
1072-
# available_periods: [{
1072+
# query_periods: [{
10731073
# start: Time.utc(2017, 1, 1, 9, 00),
10741074
# end: Time.utc(2017, 1, 1, 17, 00),
10751075
# }]
@@ -1110,7 +1110,7 @@ def real_time_scheduling(args = {})
11101110
end
11111111
end
11121112

1113-
translate_available_periods(availability[:available_periods])
1113+
translate_available_periods(availability[:query_periods] || availability[:available_periods])
11141114
body[:availability] = availability
11151115

11161116
response = raw_post("/v1/real_time_scheduling", body)
@@ -1176,7 +1176,7 @@ def real_time_scheduling(args = {})
11761176
# an array of invitees to invite to or reject from
11771177
# the event. Invitees are represented by a hash of
11781178
# :email and :display_name (optional).
1179-
# :available_periods - A hash stating the available periods for the event
1179+
# :query_periods - A hash stating the query periods for the event
11801180
# target_calendars - An array of hashes stating into which calendars to insert the created
11811181
# event
11821182
# Raises Cronofy::CredentialsMissingError if no credentials available.
@@ -1194,7 +1194,8 @@ def real_time_sequencing(args)
11941194

11951195
if availability = args[:availability]
11961196
availability[:sequence] = map_availability_sequence(availability[:sequence])
1197-
translate_available_periods(availability[:available_periods]) if availability[:available_periods]
1197+
periods = availability[:query_periods] || availability[:available_periods]
1198+
translate_available_periods(periods) if periods
11981199
end
11991200

12001201
body[:availability] = availability
@@ -1748,8 +1749,10 @@ def map_availability_sequence(sequence)
17481749
hash[:required_duration] = map_availability_required_duration(value)
17491750
end
17501751

1751-
if sequence_item[:available_periods]
1752-
translate_available_periods(sequence_item[:available_periods])
1752+
periods = sequence_item[:query_periods] || sequence_item[:available_periods]
1753+
1754+
if periods
1755+
translate_available_periods(periods)
17531756
end
17541757

17551758
if value = sequence_item[:start_interval]

lib/cronofy/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Cronofy
2-
VERSION = "0.37.4".freeze
2+
VERSION = "0.37.5".freeze
33
end

script/ci

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ run_all() {
5454

5555
for gemfile in $gemfiles; do
5656
echo
57-
pretty_echo "Testing with $gemfile"
58-
pretty_run bundle install --gemfile $gemfile --path $bundle_path --binstubs $bin_path
57+
BUNDLE_GEMFILE=$gemfile
58+
pretty_echo "Testing with $BUNDLE_GEMFILE"
59+
pretty_run bundle install --path $bundle_path --binstubs $bin_path
5960
pretty_run bundle exec rake spec
6061
done
6162

6263
echo
64+
unset BUNDLE_GEMFILE
6365
pretty_echo "Testing with default Gemfile"
64-
pretty_run bundle install --gemfile Gemfile --path $bundle_path --binstubs $bin_path
66+
pretty_run bundle install --path $bundle_path --binstubs $bin_path
6567
pretty_run bundle exec rake spec
6668
}
6769

spec/lib/cronofy/client_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,6 +2341,14 @@
23412341
it_behaves_like 'a Cronofy request'
23422342
end
23432343

2344+
context 'when passing query periods' do
2345+
it_behaves_like 'a Cronofy request'
2346+
2347+
before do
2348+
availability[:query_periods] = availability.delete(:available_periods)
2349+
mapped_availability[:query_periods] = mapped_availability.delete(:available_periods)
2350+
end
2351+
end
23442352
end
23452353

23462354
describe "Real time sequencing" do
@@ -2529,6 +2537,21 @@
25292537
it_behaves_like 'a Cronofy request'
25302538
end
25312539

2540+
context 'when passing query periods' do
2541+
it_behaves_like 'a Cronofy request'
2542+
2543+
before do
2544+
availability[:query_periods] = availability.delete(:available_periods)
2545+
availability[:sequence].each do |sequence|
2546+
sequence[:query_periods] = sequence.delete(:available_periods)
2547+
end
2548+
2549+
mapped_availability[:query_periods] = mapped_availability.delete(:available_periods)
2550+
mapped_availability[:sequence].each do |sequence|
2551+
sequence[:query_periods] = sequence.delete(:available_periods)
2552+
end
2553+
end
2554+
end
25322555
end
25332556

25342557
describe "specifying data_centre" do

0 commit comments

Comments
 (0)