mollie-api-python
mollie-api-python copied to clipboard
Enable `testmode` for OAuth clients globally
In OAuth requests, you can specify testmode=true
to perform API requests in your development phase. Currently this needs to be done on a per-request basis:
from mollie.api.client import Client
mollie_client = Client()
mollie_client.set_access_token("access_blah")
data = {
"name": "Customer A",
"email": "[email protected]",
}
customer = mollie_client.customers.create(data, testmode="true")
Of course this is hard when your API requests are all over you application, and you need to adjust all of your code to enable/disable testmode for each call. We want to support enabling this on the client level, e.g:
from mollie.api.client import Client
mollie_client = Client()
mollie_client.set_access_token("access_blah")
mollie.client.set_testmode(True) # or False
data = {
"name": "Customer A",
"email": "[email protected]",
}
customer = mollie_client.customers.create(data) # Now this will send the API request with testmode enabled