buycoins_sdk.commons package

Submodules

buycoins_sdk.commons.enums module

This module contains various constants(mostly in the form of enums) that act as native python versions of similar constants in the GraphQL API

class BankAccountTypes(value)

Bases: enum.Enum

The BankAccountTypes enum represents the BankAccountTypes enum in the GraphQL API

DEPOSIT = 'deposit'
WITHDRAWAL = 'withdrawal'
class BuycoinsPriceStatus(value)

Bases: enum.Enum

The BuycoinsPriceStatus enum represents the BuycoinsPriceStatus enum in the GraphQL API

ACTIVE = 'active'
EXPIRED = 'expired'
class BuycoinsType(value)

Bases: enum.Enum

This contains enums for all the types in the Buycoins GraphQL API

ACCOUNT = 'Account'
ADDRESS = 'Address'
BANK_ACCOUNT = 'BankAccount'
BUYCOINS_PRICE = 'BuycoinsPrice'
DEPOSIT_ACCOUNT = 'DepositAccount'
ONCHAIN_TRANSFER_REQUEST = 'OnchainTransferRequest'
ORDER = 'Order'
PAYMENT = 'Payment'
POST_ORDER = 'PostOrder'
TRANSACTION = 'Transaction'
class Cryptocurrency(value)

Bases: enum.Enum

The Cryptocurrency enum represents the Cryptocurrency enum in the GraphQL API

BITCOIN = 'bitcoin'
ETHEREUM = 'ethereum'
LITECOIN = 'litecoin'
NAIRA_TOKEN = 'naira_token'
USD_COIN = 'usd_coin'
USD_TETHER = 'usd_tether'
class EventType(value)

Bases: enum.Enum

The EventType enum represents the types of events that can be fired by Buycoins

BANK_DEPOSIT_INCOMING = 'bank_deposit.incoming'
COINS_INCOMING = 'coins.incoming'
ORDER_FAILED = 'order.failed'
ORDER_SUCCEEDED = 'order.succeeded'
class GetOrdersStatus(value)

Bases: enum.Enum

The GetOrdersStatus enum represents the GetOrdersStatus enum in the GraphQL API

COMPLETED = 'completed'
OPEN = 'open'
class OnchainTransferRequestStatus(value)

Bases: enum.Enum

The OnchainTransferRequestStatus enum represents the OnchainTransferRequestStatus enum in the GraphQL API

CONFIRMED = 'confirmed'
EXPIRED = 'expired'
FAILED = 'failed'
FLAGGED = 'flagged'
PROCESSED = 'processed'
PROCESSING = 'processing'
READY_FOR_PROCESSING = 'ready_for_processing'
UNCONFIRMED = 'unconfirmed'
class OrderSide(value)

Bases: enum.Enum

The OrderSide enum represents the OrderSide enum in the GraphQL API

BUY = 'buy'
SELL = 'sell'
class OrderStatus(value)

Bases: enum.Enum

The OrderStatus enum represents the OrderStatus enum in the GraphQL API

CANCELED = 'canceled'
DONE = 'done'
FAILED = 'failed'
PENDING = 'pending'
class PaymentStatus(value)

Bases: enum.Enum

The PaymentStatus enum represents the PaymentStatus enum in the GraphQL API

CANCELED = 'canceled'
FAILED = 'failed'
FLAGGED = 'flagged'
INITIATED = 'initiated'
PENDING = 'pending'
READY_FOR_PROCESSING = 'ready_for_processing'
RETRIED = 'retried'
RETURNED = 'returned'
SUCCESS = 'success'
class PaymentTypes(value)

Bases: enum.Enum

The PaymentTypes enum represents the PaymentTypes enum in the GraphQL API

DEPOSIT = 'deposit'
WITHDRAWAL = 'withdrawal'
class PostOrderStatus(value)

Bases: enum.Enum

The PostOrderStatus enum represents the PostOrderStatus enum in the GraphQL API

ACTIVE = 'active'
CANCELLED = 'cancelled'
COMPLETED = 'completed'
DONE = 'done'
EXPIRED = 'expired'
INACTIVE = 'inactive'
OPEN = 'open'
PAYMENT_PENDING = 'payment_pending'
PAYMENT_PROCESSING = 'payment_processing'
PENDING_DEACTIVATION = 'pending_deactivation'
class PriceType(value)

Bases: enum.Enum

The PriceType enum represents the PriceType enum in the GraphQL API

DYNAMIC = 'dynamic'
STATIC = 'static'

buycoins_sdk.commons.errors module

This module contains errors that can be raised during the use of the SDK

exception BuycoinsException(error_message: str)

Bases: Exception

BuycoinsException is a generic exception which all represents all exceptions thrown by the Graphql API. All other exceptions must inherit from this

error_message

This is a string containing the error message thrown by buycoins

exception BuycoinsHTTPException(response: requests.models.Response, message: str)

Bases: buycoins_sdk.commons.errors.BuycoinsException

BuycoinsHTTPException is raised when a call to the BuyCoins API raises an HTTPError

status_code [int]

an integer representing the status code of the HTTPError

response [requests.Response]

the HTTP Response from the HTTPError

error_message

the error message from the HTTPError

exception InsufficientAmountToSellException(cryptocurrency: str, amount_to_sell: str)

Bases: buycoins_sdk.commons.errors.BuycoinsException

InsufficientAmountToSellException is raised when a user tries to sell more cryptocurrency than they have

cryptocurrency

a string representing the cryptocurrency the user tried to sell

amount_to_sell

a string representing the amount of coins the user tried to sell

exception InsufficientBalanceToBuyException(amount_to_buy: str, cryptocurrency: str)

Bases: buycoins_sdk.commons.errors.BuycoinsException

InsufficientBalanceToBuyException is raised when a user tries to buy cryptocurrency with insufficient balance

amount_to_buy

a string representing the amount of coins the user tried to buy

cryptocurrency

a string representing the type of the cryptocurrency the user tried to buy

exception InsufficientBalanceToWithdrawException(amount_to_withdraw)

Bases: buycoins_sdk.commons.errors.BuycoinsException

InsufficientBalanceToWithdrawException is raised when a user tries to withdraw more than they have

amount_to_withdraw

a string representing amount of naira the user tried to withdraw

exception InvalidGraphQLNodeIDException(node_id: Optional[str] = None, gql_type: Optional[buycoins_sdk.commons.enums.BuycoinsType] = None, message: str = 'The ID or GraphQL type you passed in was invalid or wrong')

Bases: buycoins_sdk.commons.errors.BuycoinsException

InvalidGraphQLNodeIDException is raised when a user tries to get a node with an invalid Global Object ID(one that points to no node) or with a wrong GraphQL type

node_id

a string representing the Global Object ID that passed by the user

gql_type: a BuycoinsType enum representing the GraphQL type passed by the user

exception MissingFieldException(missing_field: str)

Bases: buycoins_sdk.commons.errors.BuycoinsException

MissingFieldException is raised when a native Python object representation of a GraphQL type is being created with the from_dict method but there are missing fields in the dict passed

exception WithdrawalCannotBeCanceledException

Bases: buycoins_sdk.commons.errors.BuycoinsException

WithdrawalCannotBeCanceledException is raised when a user tries to cancel an already processed withdrawal

buycoins_sdk.commons.gql_fields module

This module contains a single dictionary which maps GraphQL types from the BuyCoins API to a multi-line string containing the fields of that type

buycoins_sdk.commons.utils module

This module will contain some util functions that can be used by users

is_valid_webhook_request(webhook_token: str, request_body: str, webhook_signature_header: str) → bool

This method verifies that requests to your Webhook URL are genuine and from Buycoins.

Parameters
  • webhook_token – your webhook token

  • request_body – the body of the request

  • webhook_signature_header – the X-Webhook-Signature header from BuyCoins

Returns

a Boolean stating whether the request is valid or not

Module contents