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

Support for callback_urls param for Real Time Scheduling #101

Merged
merged 1 commit into from
Dec 27, 2023
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
17 changes: 11 additions & 6 deletions pycronofy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ 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, 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):
"""Generates an real time scheduling link to start the OAuth process with
an event to be automatically upserted

Expand All @@ -633,11 +633,13 @@ def real_time_scheduling(self, availability, oauth, event, target_calendars=(),
:param dict :minimum_notice - A dict describing the minimum notice for a booking (Optional)
(DEPRECATED) :param string :callback_url - A String representing the URL Cronofy will notify
once a slot has been selected.
:param dict callback_url: - 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
:no_times_suitable_url - A String representing the URL the end-user
will be redirected if there is no available slots
:param dict callback_urls: - A dict containing the callback URLs Cronofy will notify for each event
:completed_url - A String representing the URL to call when a slot
has been chosen and the full event details are known
:no_times_suitable_url - A String representing the URL to call when the user
indicates that none of the available times are suitable for them
:no_times_displayed_url - A String representing the URL to call when the user
was shown a page with no available times
: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
Expand Down Expand Up @@ -666,6 +668,9 @@ def real_time_scheduling(self, availability, oauth, event, target_calendars=(),
if callback_url:
args['callback_url'] = callback_url

if callback_urls:
args['callback_urls'] = callback_urls

if redirect_urls:
args['redirect_urls'] = redirect_urls

Expand Down
16 changes: 9 additions & 7 deletions pycronofy/tests/test_real_time_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def request_callback(request):


@responses.activate
def test_real_time_scheduling_when_callback_url_is_dictionary(client):
def test_real_time_scheduling_when_callback_urls_is_dictionary(client):
"""Test Client.availability().

:param Client client: Client instance with test data.
Expand Down Expand Up @@ -153,8 +153,9 @@ def request_callback(request):
assert payload['oauth'] == oauth
assert payload['minimum_notice'] == {'hours': 4}

assert payload['callback_url']['completed_url'] == 'http://www.example.com/callback'
assert payload['callback_url']['completed_url'] == 'http://www.example.com/callback'
assert payload['callback_urls']['completed_url'] == 'http://www.example.com/completed_callback'
assert payload['callback_urls']['no_times_suitable_url'] == 'http://www.example.com/no_times_suitable_url_callback'
assert payload['callback_urls']['no_times_displayed_url'] == 'http://www.example.com/no_times_displayed_url_callback'

assert payload['redirect_urls']['completed_url'] == 'http://www.example.com/completed'

Expand Down Expand Up @@ -201,16 +202,17 @@ def request_callback(request):
'hours': 4
}

callback_url = {
'completed_url': 'http://www.example.com/callback',
'no_times_suitable_url': 'http://www.example.com/callback'
callback_urls = {
'completed_url': 'http://www.example.com/completed_callback',
'no_times_suitable_url': 'http://www.example.com/no_times_suitable_url_callback',
'no_times_displayed_url': 'http://www.example.com/no_times_displayed_url_callback'
}

redirect_urls = {
'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)
result = client.real_time_scheduling(availability, oauth, TEST_EVENT, [], minimum_notice, callback_urls=callback_urls, redirect_urls=redirect_urls)
assert result == REAL_TIME_SCHEDULING_RESPONSE


Expand Down