Skip to content

Commit

Permalink
feat(modules): added core_user_get_user_preferences function
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Carr committed May 21, 2020
1 parent db49f6d commit d4fb49f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/modules/core/user/get-user-preferences.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { FunctionResponse } from "../../../functions";
import { Preference, Warning } from "../../shared";

export interface GetUserPreferencesResponse extends FunctionResponse {
/**
* The user's preferences.
*/
preferences: Preference[];

warnings?: Warning[];
}
23 changes: 22 additions & 1 deletion src/modules/core/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
CourseUser,
GetCourseUserProfilesResponse,
} from "./get-course-user-profiles";
import { GetPrivateFilesInfoResponse } from "./get-private-files-info";
import { GetUserPreferencesResponse } from "./get-user-preferences";
import { SearchCriteria, GetUsersResponse } from "./get-users";
import { GetUsersByFieldResponse } from "./get-users-by-field";
import { GetPrivateFilesInfoResponse } from "./get-private-files-info";

/**
* Functions for user-related actions.
Expand Down Expand Up @@ -103,6 +104,26 @@ export default class UserModule extends Module {
})) as GetPrivateFilesInfoResponse;
}

/**
* Returns user preferences for a Moodle user.
*
* @param name The name of the preference to
* lookup. If no name is provided, all
* preferences are returned.
* @param user The ID of the user to lookup
* preferences for. If no ID is provided, the
* ID Of the web service user is used.
*/
public async getUserPreferences(
name?: string,
user?: number
): Promise<GetUserPreferencesResponse> {
return (await this.get("core_user_get_user_preferences", {
name,
userid: user === undefined ? 0 : user,
})) as GetUserPreferencesResponse;
}

/**
* Searches for users on the Moodle site that match
* the provided crtieria.
Expand Down

0 comments on commit d4fb49f

Please sign in to comment.