Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for the max_results parameter to the availability endpoint #105

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [2.0.5]
* Added support for the `max_results` parameter to the `availability` query API [#105]

## [2.0.4]
* Added support for the `query_slots` parameter to the `availability` query API [#104]

Expand Down Expand Up @@ -29,6 +32,7 @@
## [1.9.3]
* Add support for Element Token generation [#70]

[2.0.5]: https://github.com/cronofy/pycronofy/releases/tag/2.0.5
[2.0.4]: https://github.com/cronofy/pycronofy/releases/tag/2.0.4
[2.0.3]: https://github.com/cronofy/pycronofy/releases/tag/2.0.3
[2.0.2]: https://github.com/cronofy/pycronofy/releases/tag/2.0.2
Expand All @@ -39,6 +43,7 @@
[1.9.4]: https://github.com/cronofy/pycronofy/releases/tag/1.9.4
[1.9.3]: https://github.com/cronofy/pycronofy/releases/tag/1.9.3

[#105]: https://github.com/cronofy/pycronofy/pull/105
[#104]: https://github.com/cronofy/pycronofy/pull/104
[#102]: https://github.com/cronofy/pycronofy/pull/102
[#101]: https://github.com/cronofy/pycronofy/pull/101
Expand Down
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: pycronofy
Version: 2.0.4
Version: 2.0.5
Summary: Python wrapper for Cronofy
Home-page: https://github.com/cronofy/pycronofy
Author: VenueBook
Expand Down
2 changes: 1 addition & 1 deletion pycronofy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pycronofy.client import Client # noqa: F401
from pycronofy import settings
__version__ = '2.0.4'
__version__ = '2.0.5'
__name__ = 'PyCronofy'

"""
Expand Down
9 changes: 7 additions & 2 deletions pycronofy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,16 +450,18 @@ def availability(
start_interval=None,
buffer=(),
response_format=None,
query_slots=None
query_slots=None,
max_results=None
):
""" Performs an availability query.
:param list participants: An Array of participant groups or a dict for a single participant group.
:param dict or int required_duration - An Integer representing the minimum number of minutes of availability required.
:param list available_periods - An Array of available time periods dicts, each must specify a start and end Time.
:param dict or int start_interval - An Interger representing the start interval minutes for the event.
:param dict or int start_interval - An Integer representing the start interval minutes for the event.
:param dict buffer - An Dict representing the buffer to apply to the request.
:param string response_format - periods, slots or overlapping_slots (Optional, default periods)
:param list query_slots - An Array of query slots, each much specify a start Time.
:param int max_results - An Integer describing the maximum number of available periods or slots to return from the query.
:rtype: ``list``
"""
Expand Down Expand Up @@ -488,6 +490,9 @@ def availability(
if response_format in ['slots', 'overlapping_slots']:
response_element = 'available_slots'

if max_results:
options['max_results'] = max_results

return self.request_handler.post(endpoint='availability', data=options).json()[response_element]

def sequenced_availability(self, sequence=(), available_periods=()):
Expand Down
10 changes: 9 additions & 1 deletion pycronofy/tests/test_availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ def request_callback(request):
]
}
]
assert payload['max_results'] == 42

return (200, {}, json.dumps(TEST_AVAILABLITY_RESPONSE))

responses.add_callback(
Expand Down Expand Up @@ -307,7 +309,13 @@ def request_callback(request):
}
}

result = client.availability(required_duration={'minutes': 30}, available_periods=periods, participants=example_participants, buffer=example_buffer)
result = client.availability(
required_duration={'minutes': 30},
available_periods=periods,
participants=example_participants,
buffer=example_buffer,
max_results=42
)
assert len(result) == 1


Expand Down
Loading