Skip to content

Commit

Permalink
finish voice api, updating for release
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkahan committed Apr 22, 2024
1 parent c8e2f69 commit 2efdfaa
Show file tree
Hide file tree
Showing 48 changed files with 480 additions and 91 deletions.
3 changes: 3 additions & 0 deletions http_client/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.3.0
- Add new PUT method

# 1.2.1
- Expose classes and errors at the package level

Expand Down
6 changes: 3 additions & 3 deletions http_client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[project]
name = "vonage-http-client"
version = "1.2.1"
version = "1.3.0"
description = "An HTTP client for making requests to Vonage APIs."
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-utils>=1.0.1",
"vonage-utils>=1.1.0",
"vonage-jwt>=1.1.0",
"requests>=2.27.0",
"typing-extensions>=4.9.0",
"pydantic>=2.6.1",
"typing_extensions>=4.9.0",
]
classifiers = [
"Programming Language :: Python",
Expand Down
3 changes: 3 additions & 0 deletions messages/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# 1.1.0
- Add `http_client` property

# 1.0.0
- Initial upload
6 changes: 3 additions & 3 deletions messages/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = 'vonage-messages'
version = '1.0.0'
version = '1.1.0'
description = 'Vonage messages package'
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-http-client>=1.2.1",
"vonage-utils>=1.0.1",
"vonage-http-client>=1.3.0",
"vonage-utils>=1.1.0",
"pydantic>=2.6.1",
]
classifiers = [
Expand Down
9 changes: 9 additions & 0 deletions messages/src/vonage_messages/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class Messages:
def __init__(self, http_client: HttpClient) -> None:
self._http_client = http_client

@property
def http_client(self) -> HttpClient:
"""The HTTP client used to make requests to the Messages API.
Returns:
HttpClient: The HTTP client used to make requests to the Messages API.
"""
return self._http_client

@validate_call
def send(self, message: BaseMessage) -> SendMessageResponse:
"""Send a message using Vonage's Messages API.
Expand Down
6 changes: 6 additions & 0 deletions messages/tests/test_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ def test_send_message_invalid_error():

assert e.value.response.status_code == 422
assert e.value.response.json()['title'] == 'Invalid params'


def test_http_client_property():
http_client = HttpClient(get_mock_jwt_auth())
messages = Messages(http_client)
assert messages.http_client == http_client
2 changes: 2 additions & 0 deletions number_insight_v2/CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 0.1.0b0
- Beta release
6 changes: 3 additions & 3 deletions number_insight_v2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = 'vonage-number-insight-v2'
version = '0.1.0'
version = '0.1.0b0'
description = 'Vonage Number Insight v2 package'
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-http-client>=1.0.0",
"vonage-utils>=1.0.0",
"vonage-http-client>=1.3.0",
"vonage-utils>=1.1.0",
"pydantic>=2.6.1",
]
classifiers = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ def __init__(self, http_client: HttpClient) -> None:
self._http_client = deepcopy(http_client)
self._auth_type = 'basic'

@property
def http_client(self) -> HttpClient:
"""The HTTP client used to make requests to the Number Insight V2 API.
Returns:
HttpClient: The HTTP client used to make requests to the Number Insight V2 API.
"""
return self._http_client

@validate_call
def fraud_check(self, request: FraudCheckRequest) -> FraudCheckResponse:
"""Initiate a fraud check request."""
Expand Down
4 changes: 4 additions & 0 deletions number_insight_v2/tests/test_number_insight_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,7 @@ def test_ni2_sim_swap_only():
assert 'fraud_score' not in clear_response
assert 'sim_swap' in clear_response
assert 'reason' not in clear_response['sim_swap']


def test_number_insight_v2_http_client():
assert type(ni2.http_client) == HttpClient
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ pytest>=8.0.0
requests>=2.31.0
responses>=0.24.1
pydantic>=2.6.1
typing_extensions>=4.9.0
typing-extensions>=4.9.0
vonage-jwt>=1.1.0
3 changes: 3 additions & 0 deletions sms/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.1.0
- Add `http_client` property

# 1.0.2
- Internal refactoring

Expand Down
6 changes: 3 additions & 3 deletions sms/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = 'vonage-sms'
version = '1.0.2'
version = '1.1.0'
description = 'Vonage SMS package'
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-http-client>=1.1.1",
"vonage-utils>=1.0.0",
"vonage-http-client>=1.3.0",
"vonage-utils>=1.1.0",
"pydantic>=2.6.1",
]
classifiers = [
Expand Down
9 changes: 9 additions & 0 deletions sms/src/vonage_sms/sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ def __init__(self, http_client: HttpClient) -> None:
else:
self._auth_type = 'basic'

@property
def http_client(self) -> HttpClient:
"""The HTTP client used to make requests to the SMS API.
Returns:
HttpClient: The HTTP client used to make requests to the SMS API.
"""
return self._http_client

@validate_call
def send(self, message: SmsMessage) -> SmsResponse:
"""Send an SMS message."""
Expand Down
5 changes: 5 additions & 0 deletions sms/tests/test_sms.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,8 @@ def test_submit_sms_conversion_402():
sms.submit_sms_conversion('3295d748-4e14-4681-af78-166dca3c5aab')
except HttpRequestError as err:
assert err.message == '402 response from https://api.nexmo.com/conversions/sms.'


def test_http_client_property():
sms = Sms(HttpClient(Auth(api_key='qwerasdf', api_secret='1234qwerasdfzxcv')))
assert isinstance(sms.http_client, HttpClient)
5 changes: 5 additions & 0 deletions users/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.1.0
- Add `http_client` property
- Rename `ListUsersRequest` -> `ListUsersFilter`
- Internal refactoring

# 1.0.1
- Internal refactoring

Expand Down
6 changes: 3 additions & 3 deletions users/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = 'vonage-users'
version = '1.0.1'
version = '1.1.0'
description = 'Vonage Users package'
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-http-client>=1.2.0",
"vonage-utils>=1.0.1",
"vonage-http-client>=1.3.0",
"vonage-utils>=1.1.0",
"pydantic>=2.6.1",
]
classifiers = [
Expand Down
9 changes: 9 additions & 0 deletions users/src/vonage_users/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def __init__(self, http_client: HttpClient) -> None:
self._http_client = http_client
self._auth_type = 'jwt'

@property
def http_client(self) -> HttpClient:
"""The HTTP client used to make requests to the Users API.
Returns:
HttpClient: The HTTP client used to make requests to the Users API.
"""
return self._http_client

@validate_call
def list_users(
self, filter: ListUsersFilter = ListUsersFilter()
Expand Down
5 changes: 5 additions & 0 deletions users/tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,8 @@ def test_delete_user():
status=204,
)
assert users.delete_user('USR-87e3e6b0-cd7b-45ef-a0a7-bcd5566a672b') is None


def test_http_client_property():
http_client = users.http_client
assert isinstance(http_client, HttpClient)
3 changes: 3 additions & 0 deletions verify/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.1.0
- Add `http_client` property

# 1.0.1
- Internal refactoring

Expand Down
6 changes: 3 additions & 3 deletions verify/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = 'vonage-verify'
version = '1.0.1'
version = '1.1.0'
description = 'Vonage verify package'
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-http-client>=1.2.1",
"vonage-utils>=1.0.1",
"vonage-http-client>=1.3.0",
"vonage-utils>=1.1.0",
"pydantic>=2.6.1",
]
classifiers = [
Expand Down
9 changes: 9 additions & 0 deletions verify/src/vonage_verify/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ def __init__(self, http_client: HttpClient) -> None:
self._sent_data_type = 'form'
self._auth_type = 'body'

@property
def http_client(self) -> HttpClient:
"""The HTTP client used to make requests to the Verify API.
Returns:
HttpClient: The HTTP client used to make requests to the Verify API.
"""
return self._http_client

@validate_call
def start_verification(
self, verify_request: VerifyRequest
Expand Down
5 changes: 5 additions & 0 deletions verify/tests/test_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,8 @@ def test_request_network_unblock_error():
== 'The network you provided does not have an active block.'
)
assert e.response.json()['title'] == 'Not Found'


def test_http_client_property():
verify = Verify(HttpClient(get_mock_api_key_auth()))
assert isinstance(verify.http_client, HttpClient)
3 changes: 3 additions & 0 deletions verify_v2/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# 1.1.0
- Add `http_client` property

# 1.0.0
- Initial upload
6 changes: 3 additions & 3 deletions verify_v2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = 'vonage-verify-v2'
version = '1.0.0'
version = '1.1.0'
description = 'Vonage verify v2 package'
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-http-client>=1.2.1",
"vonage-utils>=1.0.1",
"vonage-http-client>=1.3.0",
"vonage-utils>=1.1.0",
"pydantic>=2.6.1",
]
classifiers = [
Expand Down
9 changes: 9 additions & 0 deletions verify_v2/src/vonage_verify_v2/verify_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ class VerifyV2:
def __init__(self, http_client: HttpClient) -> None:
self._http_client = http_client

@property
def http_client(self) -> HttpClient:
"""The HTTP client used to make requests to the Verify V2 API.
Returns:
HttpClient: The HTTP client used to make requests to the Verify V2 API.
"""
return self._http_client

@validate_call
def start_verification(
self, verify_request: VerifyRequest
Expand Down
5 changes: 5 additions & 0 deletions verify_v2/tests/test_verify_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,8 @@ def test_trigger_next_event_error():
assert (
e.value.response.json()['detail'] == 'There are no more events left to trigger.'
)


def test_http_client_property():
http_client = verify.http_client
assert isinstance(http_client, HttpClient)
20 changes: 0 additions & 20 deletions voice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,3 @@

This package contains the code to use [Vonage's Voice API](https://developer.vonage.com/en/voice/voice-api/overview) in Python. This package includes methods for working with the Voice API. It also contains an NCCO (Call Control Object) builder to help you to control call flow.

## 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`.

### Create a Call


### Note on URLs

The Voice API requires most URLs to be passed in a list with only one element. When creating models, simply pass the url and the model will marshal it into the correct structure for you.

e.g.

```python
# Don't do this


# Do this

```
6 changes: 3 additions & 3 deletions voice/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = 'vonage-voice'
version = '1.0.0'
version = '1.0.1'
description = 'Vonage voice package'
readme = "README.md"
authors = [{ name = "Vonage", email = "[email protected]" }]
requires-python = ">=3.8"
dependencies = [
"vonage-http-client>=1.2.1",
"vonage-utils>=1.0.1",
"vonage-http-client>=1.3.0",
"vonage-utils>=1.1.0",
"pydantic>=2.6.1",
]
classifiers = [
Expand Down
3 changes: 2 additions & 1 deletion voice/src/vonage_voice/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import errors, models
from .voice import Voice

__all__ = ['Voice']
__all__ = ['Voice', 'errors', 'models']
Loading

0 comments on commit 2efdfaa

Please sign in to comment.