-
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.
Merge pull request #219 from Vonage/v3-release
V3 release
- Loading branch information
Showing
39 changed files
with
860 additions
and
1,969 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,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 2.8.0 | ||
current_version = 3.0.0 | ||
commit = True | ||
tag = False | ||
|
||
|
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
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 |
---|---|---|
|
@@ -3,4 +3,8 @@ pytest==7.1.1 | |
pytest-cov==3.0.0 | ||
responses==0.20.0 | ||
coveralls | ||
glom==22.1.0 | ||
glom==22.1.0 | ||
|
||
bump2version | ||
build | ||
twine |
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,3 +1,3 @@ | ||
from .client import * | ||
|
||
__version__ = "2.8.0" | ||
__version__ = "3.0.0" |
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,59 +1,110 @@ | ||
from .errors import PricingTypeError | ||
|
||
from deprecated import deprecated | ||
class Account: | ||
account_auth_type = 'params' | ||
pricing_auth_type = 'params' | ||
secrets_auth_type = 'header' | ||
|
||
allowed_pricing_types = {'sms', 'sms-transit', 'voice'} | ||
|
||
def __init__(self, client): | ||
self._client = client | ||
|
||
def get_balance(self): | ||
return self._client.get(self._client.host(), "/account/get-balance") | ||
return self._client.get(self._client.host(), "/account/get-balance", auth_type=Account.account_auth_type) | ||
|
||
def topup(self, params=None, **kwargs): | ||
return self._client.post(self._client.host(), "/account/top-up", params or kwargs) | ||
return self._client.post( | ||
self._client.host(), | ||
"/account/top-up", | ||
params or kwargs, | ||
auth_type=Account.account_auth_type, | ||
body_is_json=False, | ||
) | ||
|
||
def get_country_pricing(self, country_code: str, type: str = 'sms'): | ||
self._check_allowed_pricing_type(type) | ||
return self._client.get( | ||
self._client.host(), | ||
f"/account/get-pricing/outbound/{type}", | ||
{"country": country_code}, | ||
auth_type=Account.pricing_auth_type | ||
) | ||
|
||
def get_country_pricing(self, country_code): | ||
def get_all_countries_pricing(self, type: str = 'sms'): | ||
self._check_allowed_pricing_type(type) | ||
return self._client.get( | ||
self._client.host(), "/account/get-pricing/outbound", {"country": country_code} | ||
self._client.host(), f"/account/get-full-pricing/outbound/{type}", auth_type=Account.pricing_auth_type | ||
) | ||
|
||
def get_prefix_pricing(self, prefix): | ||
def get_prefix_pricing(self, prefix: str, type: str = 'sms'): | ||
self._check_allowed_pricing_type(type) | ||
return self._client.get( | ||
self._client.host(), "/account/get-prefix-pricing/outbound", {"prefix": prefix} | ||
self._client.host(), | ||
f"/account/get-prefix-pricing/outbound/{type}", | ||
{"prefix": prefix}, | ||
auth_type=Account.pricing_auth_type, | ||
) | ||
|
||
def get_sms_pricing(self, number): | ||
@deprecated(version='3.0.0', reason='The "account/get-phone-pricing" endpoint is deprecated.') | ||
def get_sms_pricing(self, number: str): | ||
return self._client.get( | ||
self._client.host(), "/account/get-phone-pricing/outbound/sms", {"phone": number} | ||
self._client.host(), | ||
"/account/get-phone-pricing/outbound/sms", | ||
{"phone": number}, | ||
auth_type=Account.pricing_auth_type, | ||
) | ||
|
||
def get_voice_pricing(self, number): | ||
@deprecated(version='3.0.0', reason='The "account/get-phone-pricing" endpoint is deprecated.') | ||
def get_voice_pricing(self, number: str): | ||
return self._client.get( | ||
self._client.host(), "/account/get-phone-pricing/outbound/voice", {"phone": number} | ||
self._client.host(), | ||
"/account/get-phone-pricing/outbound/voice", | ||
{"phone": number}, | ||
auth_type=Account.pricing_auth_type, | ||
) | ||
|
||
def update_default_sms_webhook(self, params=None, **kwargs): | ||
return self._client.post(self._client.host(), "/account/settings", params or kwargs) | ||
return self._client.post( | ||
self._client.host(), | ||
"/account/settings", | ||
params or kwargs, | ||
auth_type=Account.account_auth_type, | ||
body_is_json=False, | ||
) | ||
|
||
def list_secrets(self, api_key): | ||
return self._client.get( | ||
self._client.api_host(), | ||
f"/accounts/{api_key}/secrets", | ||
header_auth=True, | ||
auth_type=Account.secrets_auth_type, | ||
) | ||
|
||
def get_secret(self, api_key, secret_id): | ||
return self._client.get( | ||
self._client.api_host(), | ||
f"/accounts/{api_key}/secrets/{secret_id}", | ||
header_auth=True, | ||
auth_type=Account.secrets_auth_type, | ||
) | ||
|
||
def create_secret(self, api_key, secret): | ||
body = {"secret": secret} | ||
return self._client._post_json( | ||
self._client.api_host(), f"/accounts/{api_key}/secrets", body | ||
return self._client.post( | ||
self._client.api_host(), | ||
f"/accounts/{api_key}/secrets", | ||
body, | ||
auth_type=Account.secrets_auth_type, | ||
body_is_json=False, | ||
) | ||
|
||
def revoke_secret(self, api_key, secret_id): | ||
return self._client.delete( | ||
self._client.api_host(), | ||
f"/accounts/{api_key}/secrets/{secret_id}", | ||
header_auth=True, | ||
auth_type=Account.secrets_auth_type, | ||
) | ||
|
||
def _check_allowed_pricing_type(self, type): | ||
if type not in Account.allowed_pricing_types: | ||
raise PricingTypeError('Invalid pricing type specified.') |
Oops, something went wrong.