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

Get smart invite without recipient #84

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions pycronofy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,18 @@ def upsert_smart_invite(self, smart_invite_id, recipient, event, callback_url=No

return self.request_handler.post('smart_invites', data=body, use_api_key=True).json()

def get_smart_invite(self, smart_invite_id, recipient_email):
def get_smart_invite(self, smart_invite_id, recipient_email=None):
"""Gets the details for a smart invite.

:param string smart_invite_id: - A String uniquely identifying the event for your
application (note: this is NOT an ID generated by Cronofy).
:param string recipient_email: - The email address for the recipient to get details for.
:param string recipient_email: - The email address for the recipient to get details for (optional).
"""
params = {
'smart_invite_id': smart_invite_id,
'recipient_email': recipient_email
}
if recipient_email:
params['recipient_email'] = recipient_email

return self.request_handler.get('smart_invites', params=params, use_api_key=True).json()

Expand Down
11 changes: 9 additions & 2 deletions pycronofy/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,10 @@ def test_get_smart_invite(client):
recipient = "[email protected]"

def request_callback(request):
assert request.url == 'https://api.cronofy.com/v1/smart_invites?smart_invite_id=qTtZdczOccgaPncGJaCiLg&recipient_email=example%40example.com'
if "recipient_email" in request.url:
assert request.url == 'https://api.cronofy.com/v1/smart_invites?smart_invite_id=qTtZdczOccgaPncGJaCiLg&recipient_email=example%40example.com'
else:
assert request.url == 'https://api.cronofy.com/v1/smart_invites?smart_invite_id=qTtZdczOccgaPncGJaCiLg'

response = {
"recipient": {
Expand All @@ -586,7 +589,7 @@ def request_callback(request):
}
}

return (202, {}, json.dumps(response))
return (200, {}, json.dumps(response))

responses.add_callback(
responses.GET,
Expand All @@ -599,6 +602,10 @@ def request_callback(request):

assert result['attachments']['icalendar'] == "BEGIN:VCALENDAR\nVERSION:2.0..."

result = client.get_smart_invite(smart_invite_id)

assert result['attachments']['icalendar'] == "BEGIN:VCALENDAR\nVERSION:2.0..."


@responses.activate
def test_cancel_smart_invite(client):
Expand Down