Class MoodleClient

Represents a client for making requests to the Moodle API.

Hierarchy

  • MoodleClient

Constructors

Methods

Constructors

  • Creates a new instance of the Client class.

    Parameters

    • base_url: string | URL

      The base URL for the Moodle API.

    • token: string

      The token to use for authentication.

    Returns MoodleClient

Properties

base: URL
token: string

Methods

  • Calls a Moodle web service function with the given parameters.

    Type Parameters

    Parameters

    • func: F

      The name of the Moodle web service function to call.

    • Rest ...params: F extends keyof FunctionDefinition
          ? Record<never, never> extends FunctionDefinition[F][0]
              ? []
              : [FunctionDefinition[F][0]]
          : [Record<string, unknown>]

      The parameters to pass to the Moodle web service function. (if any)

    Returns Promise<F extends keyof FunctionDefinition
        ? FunctionDefinition[F][1]
        : unknown>

    A Promise that resolves to the result of the Moodle web service function call.

    Throws

    An error if the HTTP response status is not ok or if the Moodle web service function call returns an exception.

Generated using TypeDoc