Skip to main content

Cuenca API Client

Project description

Cuenca – Python client library

test codecov PyPI

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',
    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. Raises NoResultFound if there are no results and MultipleResultsFound if there are more than one
  • first() - returns the first result or None if there aren't any
  • all() - returns a generator of all matching results. Pagination is handled automatically as you iterate over the response
  • count() - 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.1.4.dev0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

cuenca-0.1.4.dev0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file cuenca-0.1.4.dev0.tar.gz.

File metadata

  • Download URL: cuenca-0.1.4.dev0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.7

File hashes

Hashes for cuenca-0.1.4.dev0.tar.gz
Algorithm Hash digest
SHA256 047a9d6f1a744c4914038709ec90f42d29d20706657c61b7a152ec690574bfb0
MD5 bc467ad04bcf745f10acb079e28c7292
BLAKE2b-256 d4d21b6889f337791ce97cb5c77bbfc86bb23f989f7c7130be443d2acaf8e76a

See more details on using hashes here.

File details

Details for the file cuenca-0.1.4.dev0-py3-none-any.whl.

File metadata

  • Download URL: cuenca-0.1.4.dev0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.7

File hashes

Hashes for cuenca-0.1.4.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 38190061334cb3a28f8f072960c4ce46d7c7779e4f25460e986d714107982219
MD5 a11be203ccb6c43f6720b8c306111a13
BLAKE2b-256 c247218f334426d23fb599b146614dfccd19749bbcd5f2edadc4ba60b1ed0e8d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page