Skip to content

Commit 03f6d52

Browse files
authored
Merge pull request #45 from Frameio/DEVREL-327-presentation-links
Add create_presentation_link()
2 parents 9e61625 + 5639dd5 commit 03f6d52

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

frameioclient/client.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import re
12
import sys
23
import requests
34
import warnings
45
from requests.adapters import HTTPAdapter
56
from requests.packages.urllib3.util.retry import Retry
67
from .download import FrameioDownloader
8+
from .exceptions import PresentationException
79

810
if sys.version_info.major >= 3:
911
from .py3_uploader import FrameioUploader
@@ -75,6 +77,9 @@ def _api_call(self, method, endpoint, payload={}):
7577
)
7678

7779
return r.json()
80+
81+
if r.status_code == 422 and "presentation" in endpoint:
82+
raise PresentationException
7883

7984
return r.raise_for_status()
8085

@@ -411,6 +416,26 @@ def get_review_links(self, project_id):
411416
endpoint = '/projects/{}/review_links'.format(project_id)
412417
return self._api_call('get', endpoint)
413418

419+
def create_presentation_link(self, asset_id, **kwargs):
420+
"""
421+
Create a presentation link.
422+
423+
:Args:
424+
asset_id (string): The asset id.
425+
:Kwargs:
426+
kwargs: additional request parameters.
427+
428+
Example::
429+
430+
client.create_presentation_link(
431+
asset_id="9cee7966-4066-b326-7db1-f9e6f5e929e4",
432+
title="My fresh presentation",
433+
password="abc123"
434+
)
435+
"""
436+
endpoint = '/assets/{}/presentations'.format(asset_id)
437+
return self._api_call('post', endpoint, payload=kwargs)
438+
414439
def create_review_link(self, project_id, **kwargs):
415440
"""
416441
Create a review link.

frameioclient/exceptions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
class PresentationException(Exception):
3+
"""Exception raised when you try to create a Presentation Link for an asset
4+
that already has one.
5+
"""
6+
7+
def __init__(
8+
self,
9+
message="Your asset already has a presentation link associated with it."
10+
):
11+
self.message = message
12+
super().__init__(self.message)

0 commit comments

Comments
 (0)