Skip to main content

Vonage Subaccounts API package

Project description

Vonage Subaccount Package

This package contains the code to use Vonage's Subaccount API in Python.

It includes methods for creating and modifying Vonage subaccounts and transferring credit, balances and numbers between subaccounts.

Usage

It is recommended to use this as part of the main vonage package. The examples below assume you've created an instance of the vonage.Vonage class called vonage_client.

List Subaccounts

response = vonage_client.subaccounts.list_subaccounts()
print(response.model_dump)

Create Subaccount

from vonage_subaccounts import SubaccountOptions

response = vonage_client.subaccounts.create_subaccount(
    SubaccountOptions(
        name='test_subaccount', secret='1234asdfA', use_primary_account_balance=False
    )
)
print(response)

Modify a Subaccount

from vonage_subaccounts import ModifySubaccountOptions

response = vonage_client.subaccounts.modify_subaccount(
    'test_subaccount',
    ModifySubaccountOptions(
        suspended=True,
        name='modified_test_subaccount',
    ),
)
print(response)

List Balance Transfers

from vonage_subaccounts import ListTransfersFilter

filter = {'start_date': '2023-08-07T10:50:44Z'}
response = vonage_client.subaccounts.list_balance_transfers(ListTransfersFilter(**filter))
for item in response:
    print(item.model_dump())

Transfer Balance Between Subaccounts

from vonage_subaccounts import TransferRequest

request = TransferRequest(
    from_='test_api_key', to='test_subaccount', amount=0.02, reference='A reference'
)
response = vonage_client.subaccounts.transfer_balance(request)
print(response)

List Credit Transfers

from vonage_subaccounts import ListTransfersFilter

filter = {'start_date': '2023-08-07T10:50:44Z'}
response = vonage_client.subaccounts.list_credit_transfers(ListTransfersFilter(**filter))
for item in response:
    print(item.model_dump())

Transfer Credit Between Subaccounts

from vonage_subaccounts import TransferRequest

request = TransferRequest(
    from_='test_api_key', to='test_subaccount', amount=0.02, reference='A reference'
)
response = vonage_client.subaccounts.transfer_balance(request)
print(response)

Transfer a Phone Number Between Subaccounts

from vonage_subaccounts import TransferNumberRequest

request = TransferNumberRequest(
    from_='test_api_key', to='test_subaccount', number='447700900000', country='GB'
)
response = vonage_client.subaccounts.transfer_number(request)
print(response)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vonage_subaccounts-1.0.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

vonage_subaccounts-1.0.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file vonage_subaccounts-1.0.0.tar.gz.

File metadata

  • Download URL: vonage_subaccounts-1.0.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for vonage_subaccounts-1.0.0.tar.gz
Algorithm Hash digest
SHA256 1fd8484f5c45cfcf7e1e97f909a98106be0c16cb2c1bc0bbdb8bbe8194d4d2b2
MD5 02a7767f1741b9fe7a93d39e6dc46bc4
BLAKE2b-256 06ce17740cb6ca32c44d6b413d9c750dac2c02f4d0faa08f14e0578aa6e82d5e

See more details on using hashes here.

File details

Details for the file vonage_subaccounts-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vonage_subaccounts-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a91a5bb779d526e5bd82d33ba8300e135d13e6edc1875d2ffce65bc21ba881b0
MD5 baa2aa22755ef9b829ef8f8a7a742424
BLAKE2b-256 ae3ea2c38b61856fc57211cfc660aa32a2eaff93d591dbd88d3693bcb6bb22e8

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