# Client

# Classes

Client

A client that can send HTTP requests to a Moodle site's Web Services API.

# Functions

handleResponse(body)

Attempts to handle a JSON body returned by a call to Moodle's Web Services API. If the body contains an exception property, then the response is assumed to be erroneous, and a rejected Promise is returned.

# Client

A client that can send HTTP requests to a Moodle site's Web Services API.

Kind: global abstract class
Since: 0.1.0

# new Client([options], [httpOptions])

Initializes the client as well as the client's got instance so HTTP requests can be made.

Param Type Description
[options] ClientOptions The client's configuration options.
[httpOptions] HttpOptions HTTP configuration options to pass along to got.

# client.invoke(wsfunction, [searchParams])

Invokes a Moodle Web Services API function.

Kind: instance method of Client
Since: 1.0.0

Param Type Description
wsfunction string The name of the Moodle Web Services API function to invoke.
[searchParams] any Any additional GET parameters to include in the request.

# handleResponse(body)

Attempts to handle a JSON body returned by a call to Moodle's Web Services API. If the body contains an exception property, then the response is assumed to be erroneous, and a rejected Promise is returned.

Kind: global function
Since: 1.0.0

Param Description
body A JSON body returned by a Moodle API call.