-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
244 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
resource(name='pyproject', source='pyproject.toml') | ||
file(name='readme', source='README.md') | ||
|
||
files(sources=['tests/data/*']) | ||
|
||
python_distribution( | ||
name='vonage-http-client', | ||
dependencies=[':pyproject', 'http_client/src/http_client', 'utils/src/utils'], | ||
dependencies=[ | ||
':pyproject', | ||
':readme', | ||
'http_client/src/vonage_http_client:http_client', | ||
], | ||
provides=python_artifact(), | ||
generate_setup=False, | ||
repositories=['https://test.pypi.org/legacy/'], | ||
repositories=['@pypi'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,60 @@ | ||
# Need to redo this to be about the client! | ||
# Vonage HTTP Client Package | ||
|
||
Vonage Authentication Package | ||
This Python package provides a synchronous HTTP client for sending authenticated requests to Vonage APIs. | ||
|
||
`vonage-auth` provides a convenient way to handle authentication related to Vonage APIs in your Python projects. This package includes an `Auth` class that allows you to manage API key- and secret-based authentication as well as JSON Web Token (JWT) authentication. | ||
This package (`vonage-http-client`) is used by the `vonage` Python package and SDK so doesn't require manual installation or config unless you're using this package independently of a SDK. | ||
|
||
This package (`vonage-auth`) is used by the `vonage` Python package so doesn't require manual installation unless you're not using that. | ||
The `HttpClient` class is initialized with an instance of the `Auth` class for credentials, an optional class of HTTP client options, and an optional SDK version (this is provided automatically when using this module via an SDK). | ||
|
||
The `HttpClientOptions` class defines the options for the HTTP client, including the API and REST hosts, timeout, pool connections, pool max size, and max retries. | ||
|
||
This package also includes an `Auth` class that allows you to manage API key- and secret-based authentication as well as JSON Web Token (JWT) authentication. | ||
|
||
For full API documentation refer to the [Vonage Developer documentation](https://developer.vonage.com). | ||
|
||
## Installation | ||
## Installation (if not using via an SDK) | ||
|
||
You can install the package using pip: | ||
|
||
```bash | ||
pip install vonage-auth | ||
pip install vonage-http-client | ||
``` | ||
|
||
## Usage | ||
|
||
```python | ||
from vonage_http_client import HttpClient, HttpClientOptions | ||
from vonage_http_client.auth import Auth | ||
|
||
# Create an Auth instance | ||
auth = Auth(api_key='your_api_key', api_secret='your_api_secret') | ||
|
||
# Create HttpClientOptions instance | ||
options = HttpClientOptions(api_host='api.nexmo.com', timeout=30) | ||
|
||
# Create a HttpClient instance | ||
client = HttpClient(auth=auth, http_client_options=options) | ||
|
||
# Make a GET request | ||
response = client.get(host='api.nexmo.com', request_path='/v1/messages') | ||
|
||
# Make a POST request | ||
response = client.post(host='api.nexmo.com', request_path='/v1/messages', params={'key': 'value'}) | ||
``` | ||
|
||
### Appending to the User-Agent Header | ||
|
||
The HttpClient class also supports appending additional information to the User-Agent header via the append_to_user_agent method: | ||
|
||
```python | ||
client.append_to_user_agent('additional_info') | ||
``` | ||
|
||
### Changing the Authentication Method Used | ||
|
||
The `HttpClient` class automatically handles JWT and basic authentication based on the Auth instance provided. It uses JWT authentication by default, but you can specify the authentication type when making a request: | ||
|
||
```python | ||
# Use basic authentication for this request | ||
response = client.get(host='api.nexmo.com', request_path='/v1/messages', auth_type='basic') | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
http_client/src/http_client/errors.py → http_client/src/vonage_http_client/errors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
resource(name='pyproject', source='pyproject.toml') | ||
file(name='readme', source='README.md') | ||
|
||
files(sources=['tests/data/*']) | ||
|
||
python_distribution( | ||
name='vonage-number-insight-v2', | ||
dependencies=[ | ||
':pyproject', | ||
'number_insight_v2/src/number_insight_v2', | ||
'utils/src/utils', | ||
':readme', | ||
'number_insight_v2/src/vonage_number_insight_v2', | ||
], | ||
provides=python_artifact(), | ||
generate_setup=False, | ||
repositories=['https://test.pypi.org/legacy/'], | ||
repositories=['@pypi'], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,23 @@ | ||
# Vonage Number Insight Python SDK package | ||
|
||
This package contains the code to use Vonage's Number Insight API in Python. | ||
This package contains the code to use v2 of Vonage's Number Insight API (currently in beta) in Python. | ||
|
||
It includes classes for making fraud check requests and handling the responses. | ||
|
||
## Usage | ||
First, import the necessary classes and create an instance of the `NumberInsightV2` class: | ||
|
||
```python | ||
from vonage_http_client.http_client import HttpClient | ||
from number_insight_v2 import NumberInsightV2, FraudCheckRequest | ||
|
||
http_client = HttpClient(api_host='your_api_host', api_key='your_api_key', api_secret='your_api_secret') | ||
number_insight = NumberInsightV2(http_client) | ||
``` | ||
|
||
You can then create a `FraudCheckRequest` object and use the `fraud_check` method to initiate a fraud check request: | ||
|
||
```python | ||
request = FraudCheckRequest(phone='1234567890') | ||
response = number_insight.fraud_check(request) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .number_insight_v2 import FraudCheckRequest, FraudCheckResponse, NumberInsightV2 | ||
|
||
__all__ = [ | ||
'NumberInsightV2', | ||
'FraudCheckRequest', | ||
'FraudCheckResponse', | ||
] |
2 changes: 1 addition & 1 deletion
2
...nsight_v2/src/number_insight_v2/errors.py → ...v2/src/vonage_number_insight_v2/errors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
python_tests(dependencies=['number_insight_v2']) | ||
python_tests(dependencies=['number_insight_v2', 'testutils']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python_sources() |
Oops, something went wrong.