psnawp_api.utils package#

Submodules#

psnawp_api.utils.endpoints module#

psnawp_api.utils.misc module#

create_logger(module_name: str) Logger[source]#

Creates logger and returns an instance of logging object.

Parameters:

module_name (str) – Logger name that will appear in text.

Returns:

Logging Object.

Return type:

logging.Logger

iso_format_to_datetime(iso_format: str | None) datetime | None[source]#
play_duration_to_timedelta(play_duration: str | None) timedelta[source]#

Provides a timedelta object for the play duration PSN sends

Parameters:

play_duration (Optional[str]) – String from API

Returns:

String parsed into a timedelta object

Return type:

timedelta

Note

PSN API returns the duration in this format: PT243H18M48S. The maximum time Unit is Hours, it does not extend to Days or Months.

psnawp_api.utils.request_builder module#

response_checker(response: Response) None[source]#

Checks the HTTP(S) response and re-raises them as PSNAWP Exceptions

Parameters:

response (requests.Response) – Response object

Returns:

None

class RequestBuilder(authenticator: Authenticator, accept_language: str, country: str)[source]#

Bases: object

Handles all the HTTP Requests and provides a gateway to interacting with PSN API.

__init__(authenticator: Authenticator, accept_language: str, country: str)[source]#

Initialized Request Handler and saves the instance of authenticator for future use.

Parameters:
  • authenticator (Authenticator) – The instance of :class: Authenticator. Represents single authentication to PSN API.

  • accept_language (str) – The preferred language(s) for content negotiation in HTTP headers.

  • country (str) – The client’s country for HTTP headers.

get(**kwargs: Any) Response[source]#

Handles the GET requests and returns the requests.Response object.

Parameters:

kwargs – The query parameters to add to the request.

Returns:

The Request Response Object.

Return type:

requests.Response

patch(**kwargs: Any) Response[source]#

Handles the POST requests and returns the requests.Response object.

Parameters:

kwargs – The query parameters to add to the request.

Returns:

The Request Response Object.

Return type:

requests.Response

post(**kwargs: Any) Response[source]#

Handles the POST requests and returns the requests.Response object.

Parameters:

kwargs – The query parameters to add to the request.

Returns:

The Request Response Object.

Return type:

requests.Response

multipart_post(**kwargs: Any) Response[source]#

Handles the Multipart POST requests and returns the requests.Response object.

Parameters:

kwargs – The query parameters to add to the request.

Returns:

The Request Response Object.

Return type:

requests.Response

delete(**kwargs: Any) Response[source]#

Handles the DELETE requests and returns the requests.Response object.

Parameters:

kwargs – The query parameters to add to the request.

Returns:

The Request Response Object.

Return type:

requests.Response

Module contents#