How to use the jwplatform.__version__ function in jwplatform

To help you get started, we’ve selected a few jwplatform examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jwplayer / jwplatform-py / tests / test_init.py View on Github external
KEY = 'api_key'
    SECRET = 'api_secret'

    jwp_client = jwplatform.Client(KEY, SECRET)

    assert jwp_client._Client__key == KEY
    assert jwp_client._Client__secret == SECRET
    assert jwp_client._scheme == 'https'
    assert jwp_client._host == 'api.jwplatform.com'
    assert jwp_client._port == 80
    assert jwp_client._api_version == 'v1'
    assert jwp_client._agent is None
    assert 'User-Agent' in jwp_client._connection.headers
    assert jwp_client._connection.headers['User-Agent'] == \
        'python-jwplatform/{}'.format(jwplatform.__version__)
github jwplayer / jwplatform-py / tests / test_build_request.py View on Github external
assert 'api_nonce' in params
    assert len(params['api_nonce']) == 9
    assert 0 <= int(params['api_nonce']) <= 999999999

    assert 'api_timestamp' in params
    assert params['api_timestamp'] <= int(time.time())

    assert 'api_key' in params
    assert params['api_key'] == KEY

    assert 'api_format' in params
    assert params['api_format'] == 'json'

    assert 'api_kit' in params
    assert params['api_kit'] == 'py-{}'.format(jwplatform.__version__)

    assert 'api_signature' in params
github jwplayer / jwplatform-py / tests / test_init.py View on Github external
scheme=SCHEME,
        host=HOST,
        port=PORT,
        version=API_VERSION,
        agent=AGENT)

    assert jwp_client._Client__key == KEY
    assert jwp_client._Client__secret == SECRET
    assert jwp_client._scheme == SCHEME
    assert jwp_client._host == HOST
    assert jwp_client._port == PORT
    assert jwp_client._api_version == API_VERSION
    assert jwp_client._agent == AGENT
    assert 'User-Agent' in jwp_client._connection.headers
    assert jwp_client._connection.headers['User-Agent'] == \
        'python-jwplatform/{}-{}'.format(jwplatform.__version__, AGENT)
github jwplayer / jwplatform-py / jwplatform / client.py View on Github external
def __init__(self, key, secret, *args, **kwargs):
        self.__key = key
        self.__secret = secret

        self._scheme = kwargs.get('scheme') or 'https'
        self._host = kwargs.get('host') or 'api.jwplatform.com'
        self._port = int(kwargs['port']) if kwargs.get('port') else 443
        self._api_version = kwargs.get('version') or 'v1'
        self._agent = kwargs.get('agent')

        self._connection = requests.Session()
        self._connection.mount(self._scheme, RetryAdapter())

        self._connection.headers['User-Agent'] = 'python-jwplatform/{}{}'.format(
            __version__, '-{}'.format(self._agent) if self._agent else '')
github jwplayer / jwplatform-py / jwplatform / client.py View on Github external
port=':{}'.format(self._port) if self._port != 80 else '',
            version=self._api_version,
            path=path)

        if params is not None:
            _params = params.copy()
        else:
            _params = dict()

        # Add required API parameters
        _params['api_nonce'] = str(random.randint(0, 999999999)).zfill(9)
        _params['api_timestamp'] = int(time.time())
        _params['api_key'] = self.__key
        _params['api_format'] = 'json'
        _params['api_kit'] = 'py-{}{}'.format(
            __version__, '-{}'.format(self._agent) if self._agent else '')

        # Construct Signature Base String
        sbs = '&'.join(['{}={}'.format(
            quote((unicode(key).encode('utf-8')), safe='~'),
            quote((unicode(value).encode('utf-8')), safe='~')
        ) for key, value in sorted(_params.items())])

        # Add signature to the _params dict
        _params['api_signature'] = hashlib.sha1(
            '{}{}'.format(sbs, self.__secret).encode('utf-8')).hexdigest()

        return _url, _params