Cuenca API Client
Project description
Cuenca – Python client library
Installation
pip install cuenca
Authentication
The preferred way to configure the credentials for the client is to set the
CUENCA_API_KEY
and CUENCA_API_SECRET
environment variables. The client
library will automatically configure based on the values of those variables.
To configure manually:
import cuenca
cuenca.configure(api_key='PKxxxx', api_secret='yyyyyy')
Transfers
Create transfer
import cuenca
cuenca.configure(sandbox=True) # if using sandbox
local_transfer_id = '078efdc20bab456285437309c4b75673'
transfer = cuenca.Transfer.create(
recipient_name='Benito Juárez',
account_number='646180157042875763', # CLABE or card number
amount=12345, # Mx$123.45
descriptor='sending money', # As it'll appear for the customer
idempotency_key=local_transfer_id
)
# To get updated status
transfer.refresh()
Retrieve by id
import cuenca
transfer = cuenca.Transfer.retrieve('tr_123')
Query by idempotency_key
, account_number
and status
Results are always returned in descending order of created_at
The methods that can be used:
one()
- returns a single result. RaisesNoResultFound
if there are no results andMultipleResultsFound
if there are more than onefirst()
- returns the first result orNone
if there aren't anyall()
- returns a generator of all matching results. Pagination is handled automatically as you iterate over the responsecount()
- returns an integer with the count of the matching results
import cuenca
from cuenca.types import Status
# find the unique transfer using the idempotency key
local_transfer_id = '078efdc20bab456285437309c4b75673'
transfer = cuenca.Transfer.one(idempotency_key=local_transfer_id)
# returns a generator of all succeeded transfers to the specific account
transfers = cuenca.Transfer.all(
account_number='646180157000000004',
status=Status.succeeded
)
# the total number of succeeded transfers
count = cuenca.Transfer.count(status=Status.succeeded)
Api Keys
Create new ApiKey
and deactivate old
import cuenca
# Create new ApiKey
new = cuenca.ApiKey.create()
# Have to use the new key to deactivate the old key
old_id = cuenca.session.auth[0]
cuenca.session.configure(new.id, new.secret)
cuenca.ApiKey.deactivate(old_id, 60) # revoke prior API key in an hour
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cuenca-0.2.1.tar.gz
(11.8 kB
view details)
Built Distribution
cuenca-0.2.1-py3-none-any.whl
(16.8 kB
view details)
File details
Details for the file cuenca-0.2.1.tar.gz
.
File metadata
- Download URL: cuenca-0.2.1.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7116e4a1d8bb6e593eabaaf18286297cc8ef0e21f3c76c0602dde18337cec3d1 |
|
MD5 | 75be0329fa1bb3aaff3505a7ba17186c |
|
BLAKE2b-256 | d59f4f21d02ef82c7d00ecc976fe185ceb9cab16af194e2a7f35272f5778e9ff |
File details
Details for the file cuenca-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: cuenca-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e222879e481d14e53adfbff9e58ced61887dd141507ba38c4ff5795fd14d8530 |
|
MD5 | 32d9fd625e8103a8694e073644babea1 |
|
BLAKE2b-256 | c730318d14560cb97267f8d9fe4e38f55c9b8609495f727702fd0ccac383dfc8 |