A factory for preparing requests to the WaniKani API, with methods that return a WKRequest that can be used in any HTTP API/Library to make the request.

Constructors

Accessors

Methods

  • Add additional custom headers to be used in all requests generated by the factory.

    Parameters

    • headers: Record<string, string>

      An object containing HTTP headers and their values.

    Returns this

    The factory, with the added custom headers.

  • Sets a new WaniKani API Revision to use in requests returned by the factory.

    Parameters

    • revision: "20170710"

      The WaniKani API Revision to use.

    Returns this

    The factory, with the newly set WaniKani API Revision.

  • Sets a new WaniKani API Token to use in requests returned by the factory.

    Parameters

    • token: string

      The new WaniKani API Token to use.

    Returns this

    The factory, with the newly set WaniKani API Token.

  • Sets the custom headers for all requests gerated by the factory to those passed to this function, removing any previously set custom headers, and keeping API Revision and Token settings.

    Parameters

    • headers: Record<string, string>

      An object containing HTTP headers and their values.

    Returns this

    The factory, with the only custom headers being those passed to this function.

  • Validates custom-set headers to make sure type checking isn't circumvented.

    Parameters

    • key: string

      The header key, e.g. Accpet or X-Forwarded-For

    • value: string

      The header value, e.g. application/json or 192.168.1.1

    Returns void

    A TypeError if there is an attempt to improperly set type-checked headers.