ulaval_notify.api package

Submodules

ulaval_notify.api.constants module

This module contains the constants related to monPortail API.

copyright:
  1. 2018 by Antoine Gagné.
license:

MIT, see LICENSE for more details.

ulaval_notify.api.constants.API_URL = 'https://api.ulaval.ca/ul/auth/oauth/v2'

The URL of monPortail API

ulaval_notify.api.constants.AUTHENTICATION_PAGE_URL = 'https://authentification.ulaval.ca'

The authentication page URL

ulaval_notify.api.constants.BASE_URL = 'https://monportail.ulaval.ca'

The URL of the base website

ulaval_notify.api.constants.COOKIE_REGEX = 'serviceSecureStorage.setItem\\((?P<cookie_name>"mpo.securite.contexteUtilisateur"),(?P<cookie_content>.+)\\);'

The regex that corresponds to the content of the cookie in the returned HTML page

ulaval_notify.api.constants.LOCATION_URL = 'https://monportail.ulaval.ca/auth/deleguer/?urlretour=https://monportail.ulaval.ca/'

The URL to set the needed cookies to log in

ulaval_notify.api.login module

This module handles the login to monPortail API.

copyright:
  1. 2018 by Antoine Gagné.
license:

MIT, see LICENSE for more details.

class ulaval_notify.api.login.User(username, password)

Bases: tuple

Immutable type to hold the user’s IDUL and the password

password

Alias for field number 1

username

Alias for field number 0

ulaval_notify.api.login.login(session, user)[source]

Login to monPortail API as the specified user.

Parameters:
  • session – The HTTP session to use for the requests
  • user – The user’s credentials (IDUL and password)
Returns:

A session manager that handles refreshing the token and can make authenticated requests to the API

ulaval_notify.api.notifications module

class ulaval_notify.api.notifications.NotificationManager(session_manager, callback, create_request)[source]

Bases: object

check_notifications()[source]
notification_route = 'https://monportail.ulaval.ca/communication/v1/messagesimportants'
ulaval_notify.api.notifications.create_request(session_manager)[source]
ulaval_notify.api.notifications.find_appropriate_notification_callback(platform_name)[source]
ulaval_notify.api.notifications.send_linux_notification(notification)[source]

ulaval_notify.api.session module

This module contains the code related to the session handling.

copyright:
  1. 2018 by Antoine Gagné.
license:

MIT, see LICENSE for more details.

class ulaval_notify.api.session.SessionManager(session, cookie_name, cookie_content)[source]

Bases: object

The session manager handles requests to the API related to the session.

Parameters:
  • session – The API session
  • cookie_name – The named of the cookie to set in the session
  • cookie_content – The content of the cookie to set in the session
refresh()[source]

Refresh the session.

refresh_session_route = 'https://api.ulaval.ca/ul/auth/oauth/v2/refreshsession'

The route used to refresh the session details

refresh_token_route = 'https://monportail.ulaval.ca/auth/rafraichirtoken'

The route used to refresh the session token

send(request)[source]

Send the given request with the current session.

Parameters:request – The request to send to the API
Returns:The response of the API
token_details = None

The details of the API session token

user_details = None

The details of the current user of the API

class ulaval_notify.api.session.Token(client_id, token, token_type, expiration_date)

Bases: tuple

Immutable type that contains information about the session token

client_id

Alias for field number 0

expiration_date

Alias for field number 3

token

Alias for field number 1

token_type

Alias for field number 2

class ulaval_notify.api.session.UserDetails(user_id, email, identification_number, first_name, last_name, username, change_number)

Bases: tuple

Immutable type that contains information about the current user of the API

change_number

Alias for field number 6

email

Alias for field number 1

first_name

Alias for field number 3

identification_number

Alias for field number 2

last_name

Alias for field number 4

user_id

Alias for field number 0

username

Alias for field number 5

ulaval_notify.api.session.create_token(token_details)[source]

Create a token based on the API response.

Parameters:token_details – The API response containing the token details
Returns:The token details
ulaval_notify.api.session.create_user_details(user_details)[source]

Create a type holding the user’s details based on the API response.

Parameters:user_details – The API response containing the user’s details
Returns:The user details
ulaval_notify.api.session.refresh_periodically(interval, session_manager)[source]

Refresh the session held by the session manager every given interval.

Parameters:
  • interval – The number of time before refreshing the session
  • session_manager – The session manager that will refresh the session

Module contents