diff --git a/README.md b/README.md index 5a1022bf..be28ad61 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,11 @@ It's recommended to create a new virtual environment to install the SDK. You can # Create the virtual environment python3 -m venv venv -# Activate the virtual environment +# Activate the virtual environment in Mac/Linux . ./venv/bin/activate + +# Or on Windows Command Prompt +venv\Scripts\activate ``` To install the Python SDK package using pip: @@ -62,13 +65,7 @@ To upgrade your installed client library using pip: pip install vonage --upgrade ``` -Alternatively, you can clone the repository via the command line: - -```bash -git clone git@github.com:Vonage/vonage-python-sdk.git -``` - -or by opening it on GitHub desktop. +Alternatively, you can clone the repository via the command line, or by opening it on GitHub desktop. ## Migration Guides @@ -99,6 +96,8 @@ print(response.model_dump(exclude_unset=True)) ## Usage +Many of the use cases require you to buy a Vonage Number, which you can [do in the Vonage Developer Dashboard](https://dashboard.nexmo.com/). + ```python from vonage import Vonage, Auth, HttpClientOptions @@ -129,6 +128,17 @@ You can also access the underlying `HttpClient` instance through the `http_clien user_agent = vonage.http_client.user_agent ``` +### Convert a Pydantic Model to Dict or Json + +Most responses to API calls in the SDK are Pydantic models. To convert a Pydantic model to a dict, use `model.model_dump`. To convert to a JSON string, use `model.model_dump_json` + +```python +response = vonage.api_package.api_call(...) + +response_dict = response.model_dump() +response_json = response.model_dump_json() +``` + ## Account API ### Get Account Balance diff --git a/V3_TO_V4_SDK_MIGRATION_GUIDE.md b/V3_TO_V4_SDK_MIGRATION_GUIDE.md index aa2de146..639d3743 100644 --- a/V3_TO_V4_SDK_MIGRATION_GUIDE.md +++ b/V3_TO_V4_SDK_MIGRATION_GUIDE.md @@ -142,7 +142,7 @@ vonage_client.messages.send(message) In v3 of the SDK, the APIs returned Python dictionaries. In v4, almost all responses are now deserialized from the returned JSON into Pydantic models. Response data models are accessed in the same way as the other data models above and are also fully documented with useful docstrings. -If you want to convert the Pydantic responses into dictionaries, just use the `model_dump` method on the response. For example: +If you want to convert the Pydantic responses into dictionaries, just use the `model_dump` method on the response. You can also use the `model_dump_json` method. For example: ```python from vonage_account import SettingsResponse @@ -153,6 +153,7 @@ settings: SettingsResponse = vonage_client.account.update_default_sms_webhook( ) print(settings.model_dump()) +print(settings.model_dump_json()) ``` Response fields are also converted into snake_case where applicable, so as to be more pythonic. This means they won't necessarily match the API one-to-one. diff --git a/verify/CHANGES.md b/verify/CHANGES.md index f8bf361b..769d8e2b 100644 --- a/verify/CHANGES.md +++ b/verify/CHANGES.md @@ -1,5 +1,5 @@ # 2.0.0 -- Rename `vonage-verify-v2` package -> `vonage-verify`, `VerifyV2` -> `Verify`, etc. +- Rename `vonage-verify-v2` package -> `vonage-verify`, `VerifyV2` -> `Verify`, etc. This package now contains code for the Verify v2 API - Update dependency versions # 1.1.4 diff --git a/verify_legacy/CHANGES.md b/verify_legacy/CHANGES.md index c6e06449..9a43ef2c 100644 --- a/verify_legacy/CHANGES.md +++ b/verify_legacy/CHANGES.md @@ -1,21 +1,2 @@ -# 2.0.0 -- Rename to "Verify Legacy", rename `vonage-verify` -> `vonage-verify-legacy`, `Verify` -> `VerifyLegacy`, etc. -- Update dependency versions - -# 1.1.3 -- Support for Python 3.13, drop support for 3.8 - -# 1.1.2 -- Add docstrings to data models - -# 1.1.1 -- Update minimum dependency version - -# 1.1.0 -- Add `http_client` property - -# 1.0.1 -- Internal refactoring - # 1.0.0 -- Initial upload +- Initial upload as `legacy` package diff --git a/verify_legacy/src/vonage_verify_legacy/_version.py b/verify_legacy/src/vonage_verify_legacy/_version.py index afced147..1f356cc5 100644 --- a/verify_legacy/src/vonage_verify_legacy/_version.py +++ b/verify_legacy/src/vonage_verify_legacy/_version.py @@ -1 +1 @@ -__version__ = '2.0.0' +__version__ = '1.0.0' diff --git a/vonage/pyproject.toml b/vonage/pyproject.toml index bbabbf14..5ed9810c 100644 --- a/vonage/pyproject.toml +++ b/vonage/pyproject.toml @@ -7,7 +7,7 @@ requires-python = ">=3.9" dependencies = [ "vonage-utils>=1.1.4", "vonage-http-client>=1.4.3", - "vonage-account>=1.0.3", + "vonage-account>=1.1.0", "vonage-application>=2.0.0", "vonage-messages>=1.2.3", "vonage-network-auth>=1.0.1", @@ -19,7 +19,7 @@ dependencies = [ "vonage-subaccounts>=1.0.4", "vonage-users>=1.2.0", "vonage-verify>=2.0.0", - "vonage-verify-legacy>=2.0.0", + "vonage-verify-legacy>=1.0.0", "vonage-video>=1.0.2", "vonage-voice>=1.0.6", ]