UserService#
- class UserService[source]#
Methods
Update the attributes of a user.
Get all the coupons used for the specified user.
Get all transactions for the specified user.
Get the info of the currently logged in user.
Login using your username and password.
Create a new user.
Revoke a given token.
Revoke a given token.
Search for a user by name and username.
- patch(json_body, *, user_id)[source]#
Update the attributes of a user.
- Parameters:
json_body (
PatchUserData
) – The body of the request. SeePatchUserData
for information about the possible fields. You can provide this data as aPatchUserData
or as a dictionary.user_id (
int
) – The id of the user you want to change. Currently this can only be your own user id.self (UserService[AuthenticatedClient]) –
- Returns:
The updated user.
- Return type:
- get_coupon_usages(*, user_id, page_size=20)[source]#
Get all the coupons used for the specified user.
- Parameters:
user_id (
int
) – The user to get the coupons used for.page_size (
int
) – The size of a single page, maximum is 50.self (UserService[AuthenticatedClient]) –
- 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:
user_id (
int
) – The user to get the transactions for.page_size (
int
) – The size of a single page, maximum is 50.self (UserService[AuthenticatedClient]) –
- 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:
- login(json_body)[source]#
Login using your username and password.
- Parameters:
json_body (
Union
[LoginData
,ImpersonateData
]) – The body of the request. SeeLoginUserData
for information about the possible fields. You can provide this data as aLoginUserData
or as a dictionary.- Returns:
A response containing the JSON serialized user
- Return type:
- register(json_body)[source]#
Create a new user.
- Parameters:
json_body (
RegisterUserData
) – The body of the request. SeeRegisterUserData
for information about the possible fields. You can provide this data as aRegisterUserData
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:
- restrict(json_body)[source]#
Revoke a given token.
- Parameters:
json_body (
SessionRestrictionData
) – The body of the request. SeeSessionRestrictionData
for information about the possible fields. You can provide this data as aSessionRestrictionData
or as a dictionary.self (UserService[AuthenticatedClient]) –
- Returns:
An new token that has the given restrictions added.
- Return type:
- logout(multipart_data)[source]#
Revoke a given token.
- Parameters:
multipart_data (
LogoutUserData
) – The data that should form the body of the request. SeeLogoutUserData
for information about the possible fields.- Returns:
An empty 200 response.
- Return type:
- 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]