diff --git a/CHANGELOG.md b/CHANGELOG.md index d030142..3ef0ce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] @@ -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 @@ -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 diff --git a/PKG-INFO b/PKG-INFO index f3b6422..3f66ec5 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -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 diff --git a/pycronofy/__init__.py b/pycronofy/__init__.py index 5e8032e..becf497 100644 --- a/pycronofy/__init__.py +++ b/pycronofy/__init__.py @@ -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' """ diff --git a/pycronofy/client.py b/pycronofy/client.py index 55c43b3..b3b7b8b 100644 --- a/pycronofy/client.py +++ b/pycronofy/client.py @@ -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`` """ @@ -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=()): diff --git a/pycronofy/tests/test_availability.py b/pycronofy/tests/test_availability.py index 437162c..a46ea5d 100644 --- a/pycronofy/tests/test_availability.py +++ b/pycronofy/tests/test_availability.py @@ -277,6 +277,8 @@ def request_callback(request): ] } ] + assert payload['max_results'] == 42 + return (200, {}, json.dumps(TEST_AVAILABLITY_RESPONSE)) responses.add_callback( @@ -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