UserService#

class UserService[source]#

Methods

patch

Update the attributes of a user.

get_coupon_usages

Get all the coupons used for the specified user.

get_transactions

Get all transactions for the specified user.

get

Get the info of the currently logged in user.

login

Login using your username and password.

register

Create a new user.

restrict

Revoke a given token.

logout

Revoke a given token.

search

Search for a user by name and username.

patch(json_body, *, user_id)[source]#

Update the attributes of a user.

Parameters:
Returns:

The updated user.

Return type:

ExtendedUser

get_coupon_usages(*, user_id, page_size=20)[source]#

Get all the coupons used for the specified user.

Parameters:
Returns:

All coupons used for the given user.

Return type:

Response[TenantCouponUsage | CourseCouponUsage]

get_transactions(*, user_id, page_size=20)[source]#

Get all transactions for the specified user.

Parameters:
Returns:

All transactions for the given user.

Return type:

Response[Transaction]

get()[source]#

Get the info of the currently logged in user.

Returns:

A response containing the JSON serialized user

Parameters:

self (UserService[AuthenticatedClient]) –

Return type:

ExtendedUser

login(json_body)[source]#

Login using your username and password.

Parameters:

json_body (Union[LoginData, ImpersonateData]) – The body of the request. See LoginUserData for information about the possible fields. You can provide this data as a LoginUserData or as a dictionary.

Returns:

A response containing the JSON serialized user

Return type:

UserLoginResponse

register(json_body)[source]#

Create a new user.

Parameters:

json_body (RegisterUserData) – The body of the request. See RegisterUserData for information about the possible fields. You can provide this data as a RegisterUserData or as a dictionary.

Returns:

The registered user and an access_token that can be used to perform requests as this new user.

Return type:

UserLoginResponse

restrict(json_body)[source]#

Revoke a given token.

Parameters:
Returns:

An new token that has the given restrictions added.

Return type:

UserLoginResponse

logout(multipart_data)[source]#

Revoke a given token.

Parameters:

multipart_data (LogoutUserData) – The data that should form the body of the request. See LogoutUserData for information about the possible fields.

Returns:

An empty 200 response.

Return type:

LogoutResponse

search(*, q, exclude_course=Nothing, page_size=20)[source]#

Search for a user by name and username.

Parameters:
  • q (str) – The string to search for, all SQL wildcard are escaped and spaces are replaced by wildcards.

  • exclude_course (Union[Just[int], _Nothing[int]]) – Exclude all users that are in the given course from the search results. You need the permission can_list_course_users on this course to use this parameter.

  • page_size (int) – The size of a single page, maximum is 50.

  • self (UserService[AuthenticatedClient]) –

Returns:

The users that match the given query string.

Return type:

Response[NormalUser | GroupUser]