Skip to main content

Utils package containing objects for use with Vonage APIs

Project description

Vonage Utils Package

This package contains utility code that is used by the Vonage Python SDK and other related packages.

The utils module provides two utility functions: format_phone_number and remove_none_values. It also exposes the VonageError type that other exceptions related to Vonage SDK inherit from. This can also be accessed via the main SDK module with vonage.VonageError.

Usage

from utils import format_phone_number, remove_none_values

# Use format_phone_number
try:
    formatted_number = format_phone_number('123-456-7890')
    print(formatted_number)
except (InvalidPhoneNumberError, InvalidPhoneNumberTypeError) as e:
    print(e)

# Use remove_none_values to remove null values from a Vonage API response when converting to a dictionary with the `asdict` method
from dataclasses import asdict

vonage_api_response = vonage.api.method()
cleaned_dict = asdict(my_dataclass, dict_factory=remove_none_values)
print(cleaned_dict)

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_utils-1.1.1.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

vonage_utils-1.1.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

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