Using the SDK

Making calls

Create a client for the imported API with a required tenant_id and an environment

# Import SDK and specify which  api
from ping.payments_api import PaymentsApi

# Create client
payments_api = PaymentsApi(
	tenant_id="55555555-5555-5555-5555555555",
  environment="sandbox"
	)

# Use client to make calls.
response = payments_api.merchant.list()


Handel responses

Response object

The response object contains valuable information and functionality that makes the response handling simple.

response.status_code 
response.body
response.errors
response.is_success()
response.is_error()

Check if the call is successful

Use if/else statment

if response.is_success():
    print("call is successful");
    print(response.body)

elif response.is_error():
    print("call failed")
    print(response.status_code)
    print(response.errors)



Successful responses

200 OK

Example value

{
  "url": "string"
}

204 No Content

Example value

{}


Error responses

403 API Error

Example value

{
  "errors": [
    {
      "description": "This operation cannot be completed under certain conditions",
      "error": "operation_forbidden"
    }
  ]
}

404 Not Found

Example value

[
  {
    'additional_information': None, 
  	'description': 'Requested object not found in our system', 
    'error': 'not_found'
  }
]

422 Validation Error

Example value

{
  "errors": [
    {
      "description": "null value where string expected",
      "error": "null_value",
      "property": "open_banking.success_url"
    }
  ]
}