import json
import requests
from api_auth import APICredentials, APIParams
  
class PublishingTarget:
    def __init__(self):
        self.host = "https://services.uplynk.com"

    def run(self):
        self._update_publishing_target()
  
    def _update_publishing_target(self):
        publishing_target_id = '587be125932f4428b83e4435e41503b7'
        url = "{}{}{}".format(self.host, "/api/v4/syndication-target/", publishing_target_id)
 
        payload = {
            'target_stream': 'rtmp://platform.example.com/live/3u40-9rqs-502b-7zeq',
            'platform': 'Facebook',
            'description': 'Facebook publishing',
            'target_protocol': 'rtmp',
        }
  
        headers = {'Content-Type': 'application/json'}
  
        response = requests.patch(
            url, params=APIParams(APICredentials()).get_params({}), data=json.dumps(payload), headers=headers
        )
  
        print(response.json())
  
PublishingTarget().run()