A 3rd party developer friendly client package for thepeer
Project description
thepeer
A 3rd party developer friendly python client package for thepeer
installation
pip install thepeer
usage
Future versions of this package will provide a much better documentation. This version was published to claim the package namespace. however, the package is quite functional as is. First of, you want to import the client
from thepeer import ThePeerClient, ChargeEvent, PaymentChannel
client = ThePeerClient(secret_key="<secret_key>") # you can omit the secret key param if
# the environmental variable THEPEER_SECRET_KEY is set.
response = client.users.all() # Fetch all indexed users.
print(response)
response = client.transactions.get("<transaction_id>") # Fetch a transaction.
print(response)
response = client.links.get_user_links("<user_reference>") # Fetch all linked accounts of a user.
print(response)
response = client.authorize_charge("<charge_reference>",
event=ChargeEvent.INSUFFICIENT_FUNDS) # Process a charge authorization request.
print(response)
response = client.generate_checkout(amount=10000, email="johndoe@example.com") # Generate a checkout.
print(response)
response = client.get_businesses(
channel=PaymentChannel.DIRECT_CHARGE) # Fetch businesses based on the API they integrated.
print(response)
ThePeerClient has three attributes bound to it users for user related operations,
transactions for transaction related operations and links for link related operations.
It also provides additional methods authorize_charge, generate_checkout and get_businessses.
All methods on the client returns a Response with is a dataclass containing the status_code
and data returned from thepeer. This package also provides an async client which mirrors this
client and can come in handy in async context
# note the following code should be tested in an async context to work
# e.g. `python -m asynio`
from thepeer import AsyncThePeerClient
client = AsyncThePeerClient(secret_key="<secret_key>") # you can omit the secret key param if
# the environmental variable THEPEER_SECRET_KEY is set.
response = await client.users.all() # Notice that the `all` method is identical to that
# on the `ThePeerClient` except that we had to await it here.
print(response)
All methods are type annotated and also provide docstrings for a smooth developer experience. I hope you find this package useful.
source code
license
- MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thepeer-0.1.0.tar.gz.
File metadata
- Download URL: thepeer-0.1.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.9.15 Linux/5.15.131-1-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2da251d8a81ae1021514e562cb12189e465948cdb038851cd36a96e421b40043
|
|
| MD5 |
b3fa15287a7b0fcd9b8a4bd57d03a174
|
|
| BLAKE2b-256 |
4698e4b73b801b86e165c14fd9cec69ca1192a9280096610864b9ec18bd053b7
|
File details
Details for the file thepeer-0.1.0-py3-none-any.whl.
File metadata
- Download URL: thepeer-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.9.15 Linux/5.15.131-1-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8d949f2097e9049eea97feb3240d5c471d5a9c485e0a1a1b1aeebdd2d82d334
|
|
| MD5 |
60ca5e4d1c4ff0fcb6e612a7347e2e66
|
|
| BLAKE2b-256 |
848a3b0dc3b99655b99dedbf306ffd1795a8ca6e493073ee08bf778915a9c20a
|