Skip to content

Commit b176787

Browse files
committed
start working on verify api
1 parent 2173273 commit b176787

File tree

24 files changed

+452
-10
lines changed

24 files changed

+452
-10
lines changed

http_client/src/vonage_http_client/http_client.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def post(
106106
host: str,
107107
request_path: str = '',
108108
params: dict = None,
109-
auth_type: Literal['jwt', 'basic', 'signature'] = 'jwt',
109+
auth_type: Literal['jwt', 'basic', 'body', 'signature'] = 'jwt',
110110
sent_data_type: Literal['json', 'data'] = 'json',
111111
) -> Union[dict, None]:
112112
return self.make_request(
@@ -118,7 +118,7 @@ def get(
118118
host: str,
119119
request_path: str = '',
120120
params: dict = None,
121-
auth_type: Literal['jwt', 'basic', 'signature'] = 'jwt',
121+
auth_type: Literal['jwt', 'basic', 'body', 'signature'] = 'jwt',
122122
sent_data_type: Literal['json', 'form', 'query_params'] = 'json',
123123
) -> Union[dict, None]:
124124
return self.make_request(
@@ -130,7 +130,7 @@ def patch(
130130
host: str,
131131
request_path: str = '',
132132
params: dict = None,
133-
auth_type: Literal['jwt', 'basic', 'signature'] = 'jwt',
133+
auth_type: Literal['jwt', 'basic', 'body', 'signature'] = 'jwt',
134134
sent_data_type: Literal['json', 'form', 'query_params'] = 'json',
135135
) -> Union[dict, None]:
136136
return self.make_request(
@@ -142,7 +142,7 @@ def delete(
142142
host: str,
143143
request_path: str = '',
144144
params: dict = None,
145-
auth_type: Literal['jwt', 'basic', 'signature'] = 'jwt',
145+
auth_type: Literal['jwt', 'basic', 'body', 'signature'] = 'jwt',
146146
sent_data_type: Literal['json', 'form', 'query_params'] = 'json',
147147
) -> Union[dict, None]:
148148
return self.make_request(
@@ -156,7 +156,7 @@ def make_request(
156156
host: str,
157157
request_path: str = '',
158158
params: Optional[dict] = None,
159-
auth_type: Literal['jwt', 'basic', 'signature'] = 'jwt',
159+
auth_type: Literal['jwt', 'basic', 'body', 'signature'] = 'jwt',
160160
sent_data_type: Literal['json', 'form', 'query_params'] = 'json',
161161
):
162162
url = f'https://{host}{request_path}'
@@ -167,6 +167,9 @@ def make_request(
167167
self._headers['Authorization'] = self._auth.create_jwt_auth_string()
168168
elif auth_type == 'basic':
169169
self._headers['Authorization'] = self._auth.create_basic_auth_string()
170+
elif auth_type == 'body':
171+
params['api_key'] = self._auth.api_key
172+
params['api_secret'] = self._auth.api_secret
170173
elif auth_type == 'signature':
171174
params['api_key'] = self._auth.api_key
172175
params['sig'] = self._auth.sign_params(params)

pants.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ filter = [
3737
'users/src',
3838
'utils/src',
3939
'testutils',
40+
'verify/src',
4041
]
4142

4243
[black]

users/src/vonage_users/common.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from typing import List, Optional
22

33
from pydantic import BaseModel, Field, model_validator
4-
from typing_extensions import Annotated
5-
6-
PhoneNumber = Annotated[str, Field(pattern=r'^[1-9]\d{6,14}$')]
4+
from vonage_utils.types.phone_number import PhoneNumber
75

86

97
class Link(BaseModel):

users/src/vonage_users/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class ListUsersRequest(BaseModel):
77
"""Request object for listing users."""
88

9-
page_size: Optional[int] = Field(2, ge=1, le=100)
9+
page_size: Optional[int] = Field(100, ge=1, le=100)
1010
order: Optional[Literal['asc', 'desc', 'ASC', 'DESC']] = None
1111
cursor: Optional[str] = Field(
1212
None,

verify/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
resource(name='pyproject', source='pyproject.toml')
2+
file(name='readme', source='README.md')
3+
4+
files(sources=['tests/data/*'])
5+
6+
python_distribution(
7+
name='vonage-verify',
8+
dependencies=[
9+
':pyproject',
10+
':readme',
11+
'verify/src/vonage_verify',
12+
],
13+
provides=python_artifact(),
14+
generate_setup=False,
15+
repositories=['@pypi'],
16+
)

verify/CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# 1.0.0
2+
- Initial upload

verify/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Vonage Verify Package
2+
3+
This package contains the code to use Vonage's Verify API in Python. There is a more current package to user Vonage's Verify v2 API which is recommended to use for most use cases. The v2 API lets you send messages via multiple channels, including Email, SMS, MMS, WhatsApp, Messenger and others. You can also make Silent Authentication requests with Verify v2 to give an end user a more seamless experience.
4+
5+
This package includes methods for sending 2-factor authentication (2FA) messages and returns...
6+
7+
8+
asdf
9+
asdf
10+
11+
12+
## Usage
13+
14+
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`.
15+
16+
### Make a Verify Request
17+
18+
<!-- Create an `SmsMessage` object, then pass into the `Sms.send` method.
19+
20+
```python
21+
from vonage_sms import SmsMessage, SmsResponse
22+
23+
message = SmsMessage(to='1234567890', from_='Acme Inc.', text='Hello, World!')
24+
response: SmsResponse = vonage_client.sms.send(message)
25+
26+
print(response.model_dump(exclude_unset=True))
27+
``` -->

verify/pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[project]
2+
name = 'vonage-verify'
3+
version = '1.0.0'
4+
description = 'Vonage verify package'
5+
readme = "README.md"
6+
authors = [{ name = "Vonage", email = "[email protected]" }]
7+
requires-python = ">=3.8"
8+
dependencies = [
9+
"vonage-http-client>=1.1.1",
10+
"vonage-utils>=1.0.0",
11+
"pydantic>=2.6.1",
12+
]
13+
classifiers = [
14+
"Programming Language :: Python",
15+
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3.8",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"License :: OSI Approved :: Apache Software License",
22+
]
23+
24+
[project.urls]
25+
homepage = "https://github.com/Vonage/vonage-python-sdk"
26+
27+
[build-system]
28+
requires = ["setuptools>=61.0", "wheel"]
29+
build-backend = "setuptools.build_meta"

verify/src/vonage_verify/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python_sources()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# from .errors import PartialFailureError, SmsError
2+
from .requests import Psd2Request, VerifyRequest
3+
4+
# from .responses import MessageResponse, SmsResponse
5+
from .verify import Verify
6+
7+
__all__ = [
8+
'Verify',
9+
'VerifyRequest',
10+
'Psd2Request',
11+
]

0 commit comments

Comments
 (0)