-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds typing support in the core library
- Loading branch information
1 parent
4ca19de
commit 417e3f2
Showing
92 changed files
with
4,316 additions
and
4,856 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 |
---|---|---|
|
@@ -7,7 +7,6 @@ | |
'decorators', | ||
'http', | ||
'utilities', | ||
'factories', | ||
'types', | ||
'logger', | ||
'exceptions', | ||
|
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,17 +1,33 @@ | ||
from apimatic_core_interfaces.types.authentication import Authentication | ||
from abc import abstractmethod | ||
|
||
from apimatic_core_interfaces.authentication.authentication import Authentication | ||
from typing import Dict, Optional | ||
|
||
from apimatic_core_interfaces.http.http_request import HttpRequest | ||
from pydantic import validate_call | ||
|
||
from apimatic_core.utilities.auth_helper import AuthHelper | ||
|
||
|
||
class HeaderAuth(Authentication): | ||
|
||
def __init__(self, auth_params): | ||
@property | ||
@abstractmethod | ||
def error_message(self) -> str: | ||
... | ||
|
||
def with_auth_managers(self, auth_managers: Dict[str, 'Authentication']): | ||
pass | ||
|
||
@validate_call | ||
def __init__(self, auth_params: Dict[str, str]): | ||
self._auth_params = auth_params | ||
self._error_message = None | ||
self._error_message: Optional[str] = None | ||
|
||
def is_valid(self): | ||
def is_valid(self) -> bool: | ||
return AuthHelper.is_valid_auth(self._auth_params) | ||
|
||
def apply(self, http_request): | ||
@validate_call | ||
def apply(self, http_request: HttpRequest) -> None: | ||
AuthHelper.apply(self._auth_params, http_request.add_header) | ||
|
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,40 @@ | ||
from apimatic_core_interfaces.types.authentication import Authentication | ||
from abc import abstractmethod | ||
|
||
from apimatic_core_interfaces.authentication.authentication import Authentication | ||
from apimatic_core_interfaces.http.http_request import HttpRequest | ||
from pydantic import validate_call | ||
from typing import Dict | ||
|
||
from apimatic_core.utilities.api_helper import ApiHelper | ||
from apimatic_core.utilities.auth_helper import AuthHelper | ||
|
||
|
||
class QueryAuth(Authentication): | ||
|
||
def __init__(self, auth_params): | ||
@property | ||
@abstractmethod | ||
def error_message(self) -> str: | ||
... | ||
|
||
def with_auth_managers(self, auth_managers: Dict[str, 'Authentication']): | ||
pass | ||
|
||
@validate_call | ||
def __init__(self, auth_params: Dict[str, str]): | ||
self._auth_params = auth_params | ||
|
||
def is_valid(self): | ||
def is_valid(self) -> bool: | ||
return AuthHelper.is_valid_auth(self._auth_params) | ||
|
||
def apply(self, http_request): | ||
return AuthHelper.apply(self._auth_params, http_request.add_query_parameter) | ||
@validate_call | ||
def apply(self, http_request: HttpRequest): | ||
for key, value in self._auth_params.items(): | ||
self._add_query_parameter(key, value, http_request) | ||
|
||
@validate_call | ||
def _add_query_parameter(self, key: str, value: str, http_request: HttpRequest): | ||
query_url = ApiHelper.append_url_with_query_parameters( | ||
http_request.query_url, | ||
{key: value} | ||
) | ||
http_request.query_url = ApiHelper.clean_url(query_url) |
Oops, something went wrong.