import json
import requests
from api_auth import APICredentials, APIParams

class CreateDraftClip:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        """
        Create a draft of a video clip.
        """
        self._create_draft()

    def _create_draft(self):
        url = "{}{}".format(self.host, "/api/v4/clipping_draft")

        start_milliseconds = 55000 # how far into the asset should the clip start
        stop_seconds = 10 # how long after the start point should the clip stop
        payload = {
            'beam':'0123456789abcdefghijklmnopqrstuv',
            'title':'My Clip',
            'start': start_milliseconds,
            'duration': stop_seconds,
        }

        headers = {'Content-Type': 'application/json'}

        response = requests.post(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers 
        )

        print(response.json())

CreateDraftClip().run()