How to use the mangopaysdk.tools.authenticationHelper.AuthenticationHelper function in mangopaysdk

To help you get started, we’ve selected a few mangopaysdk 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 Mangopay / mangopay2-python-sdk / mangopaysdk / tools / resttool.py View on Github external
def _generateRequestIdempotent(self, idempotencyKey, urlMethod, pagination, additionalUrlParams):
        """Generate the request object
        that will be used in the `_runRequest`
        """
        urlToolObj = UrlTool(self._root.Config)
        restUrl = urlToolObj.GetRestUrl(urlMethod, self._authRequired, pagination, additionalUrlParams)
        fullUrl = urlToolObj.GetFullUrl(restUrl)

        authObj = AuthenticationHelper(self._root).GetRequestAuthObject(self._authRequired)

        headers = {"Content-Type" : "application/x-www-form-urlencoded"}

        if (idempotencyKey != None):
            headersJson = {"Content-Type" : "application/json", "Idempotency-Key" : idempotencyKey}
        else:
            headersJson = {"Content-Type" : "application/json"}

        if (self._debugMode): logging.getLogger(__name__).debug('REQUEST: {0} {1}\n  DATA: {2}'.format(self._requestType, fullUrl, self._requestData))

        if self._requestType == "POST":
            request = requests.Request('POST', fullUrl, data=json.dumps(self._requestData), auth=authObj, headers=headersJson)
        elif self._requestType == "GET":
            request = requests.Request('GET', fullUrl, auth=authObj)
        elif self._requestType == "PUT":
            request = requests.Request('PUT', fullUrl, data=json.dumps(self._requestData), auth=authObj, headers=headersJson)