Interface¶
General interfaces for HTTP communication – HTTP client, HTTP response and exceptions related to the whole process.
-
class
interface.
HttpResponse
¶ Object representing basic HTTP response that is passed across this SDK. Offers only basic methods, but the original response has to be always accessible via the
orig_response()
property.-
property
path
¶
-
property
orig_response
¶
-
property
text
¶
-
json
(**kwargs)¶ - Return type
Dict[str, Any]
-
property
-
exception
interface.
HttpError
(status_code, response)¶ General HTTP error occurring while communicating with the DSW API. Contains HTTP status code, error message and error response from the server.
- Parameters
status_code (int) –
response (HttpResponse) –
-
exception
interface.
BadRequestError
(response)¶ HTTP error with status code 400 Bad request. Client sent some invalid request to the server.
- Parameters
response (HttpResponse) –
-
exception
interface.
ForbiddenError
(response)¶ HTTP error with status code 403 Forbidden. Client is not authorized to perform such request.
- Parameters
response (HttpResponse) –
-
exception
interface.
NotFoundError
(response)¶ HTTP error with status code 404 Not found. Client requested a resource that was not found on the server.
- Parameters
response (HttpResponse) –
-
exception
interface.
UnexpectedAuthError
¶ Something unexpected happened when performing the authentication. There may be something wrong with the DSW API or it could be just some temporary malfunction.
-
class
interface.
HttpClient
(*args, **kwargs)¶ General interface for any HTTP client responsible for communication with the DSW API.
It does not make any assumptions on how the implementation should work or which libraries it should leverage. So if you want implement some client that is not shipped with this SDK (e.g. for asynchronous communication) or you want to use different libraries for HTTP stuff, feel free to subclass this interface and pass an instance of your client to the SDK when the initialization goes on.
-
head
(path, **kwargs)¶ Sends a HEAD HTTP request.
- Parameters
path (str) – path for the request
kwargs – Optional arguments that the request takes
- Raises
HttpError
on HTTP status codes between 400 and 599 while authenticating or doing the request itself- Raises
UnexpectedAuthError
on unexpected errors while authenticating- Returns
a response from the server contained in the
HttpResponse
object.- Return type
-
options
(path, **kwargs)¶ Sends a OPTIONS HTTP request.
- Parameters
path (str) – path for the request
kwargs – Optional arguments that the request takes
- Raises
HttpError
on HTTP status codes between 400 and 599 while authenticating or doing the request itself- Raises
UnexpectedAuthError
on unexpected errors while authenticating- Returns
a response from the server contained in the
HttpResponse
object.- Return type
-
get
(path, **kwargs)¶ Sends a GET HTTP request.
- Parameters
path (str) – path for the request
kwargs – Optional arguments that the request takes
- Raises
HttpError
on HTTP status codes between 400 and 599 while authenticating or doing the request itself- Raises
UnexpectedAuthError
on unexpected errors while authenticating- Returns
a response from the server contained in the
HttpResponse
object.- Return type
-
post
(path, body=None, **kwargs)¶ Sends a POST HTTP request.
- Parameters
path (str) – path for the request
body (Optional[Dict[str, Any]]) – body of the request
kwargs – Optional arguments that the request takes
- Raises
HttpError
on HTTP status codes between 400 and 599 while authenticating or doing the request itself- Raises
UnexpectedAuthError
on unexpected errors while authenticating- Returns
a response from the server contained in the
HttpResponse
object.- Return type
-
put
(path, body=None, **kwargs)¶ Sends a PUT HTTP request.
- Parameters
path (str) – path for the request
body (Optional[Dict[str, Any]]) – body of the request
kwargs – Optional arguments that the request takes
- Raises
HttpError
on HTTP status codes between 400 and 599 while authenticating or doing the request itself- Raises
UnexpectedAuthError
on unexpected errors while authenticating- Returns
a response from the server contained in the
HttpResponse
object.- Return type
-
delete
(path, **kwargs)¶ Sends a DELETE HTTP request.
- Parameters
path (str) – path for the request
kwargs – Optional arguments that the request takes
- Raises
HttpError
on HTTP status codes between 400 and 599 while authenticating or doing the request itself- Raises
UnexpectedAuthError
on unexpected errors while authenticating- Returns
a response from the server contained in the
HttpResponse
object.- Return type
-