diff --git a/pycronofy/client.py b/pycronofy/client.py index 99a944c..872d742 100644 --- a/pycronofy/client.py +++ b/pycronofy/client.py @@ -608,7 +608,16 @@ def authorize_multiple_accounts_via_service_account(self, service_account_author endpoint="service_account_authorizations", data=params) None - def real_time_scheduling(self, availability, oauth, event, target_calendars=(), minimum_notice=None, callback_url=None, callback_urls=None, redirect_urls=None): + def real_time_scheduling(self, + availability, + oauth, + event, + target_calendars=(), + minimum_notice=None, + callback_url=None, + callback_urls=None, + redirect_urls=None, + event_creation=None): """Generates an real time scheduling link to start the OAuth process with an event to be automatically upserted @@ -643,6 +652,10 @@ def real_time_scheduling(self, availability, oauth, event, target_calendars=(), :param dict redirect_urls: - A dict containing redirect URLs for the end-user's journey :completed_url - A String representing the URL the end-user will be redirected to after choosing a slot + :param string event_creation: - A string to determine behaviour of event creation. + The value of 'single' will create the resulting event in a single + calendar. 'default' if omitted, creates an event in each calendar + listed in target_calendars. See docs for more details. (Optional) See https://docs.cronofy.com/developers/api/scheduling/real-time-scheduling/ for reference. """ @@ -674,6 +687,9 @@ def real_time_scheduling(self, availability, oauth, event, target_calendars=(), if redirect_urls: args['redirect_urls'] = redirect_urls + if event_creation: + args['event_creation'] = event_creation + return self.request_handler.post(endpoint='real_time_scheduling', data=args, use_api_key=True).json() def get_real_time_scheduling_status(self, token=None, real_time_scheduling_id=None): diff --git a/pycronofy/tests/test_real_time_scheduling.py b/pycronofy/tests/test_real_time_scheduling.py index 698959e..801c742 100644 --- a/pycronofy/tests/test_real_time_scheduling.py +++ b/pycronofy/tests/test_real_time_scheduling.py @@ -67,6 +67,8 @@ def request_callback(request): assert payload['callback_url'] == 'http://www.example.com/callback' assert payload['redirect_urls']['completed_url'] == 'http://www.example.com/completed' + assert payload['event_creation'] == "single" + assert request.headers['Authorization'] == "Bearer %s" % client.auth.client_secret return (200, {}, json.dumps(REAL_TIME_SCHEDULING_RESPONSE)) @@ -116,7 +118,9 @@ def request_callback(request): 'completed_url': 'http://www.example.com/completed' } - result = client.real_time_scheduling(availability, oauth, TEST_EVENT, [], minimum_notice, callback_url=callback_url, redirect_urls=redirect_urls) + event_creation = "single" + + result = client.real_time_scheduling(availability, oauth, TEST_EVENT, [], minimum_notice, callback_url=callback_url, redirect_urls=redirect_urls, event_creation=event_creation) assert result == REAL_TIME_SCHEDULING_RESPONSE