How to use the mangopaysdk.tools.urltool.UrlTool 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)