Interface DonationAlertsApiCallOptions

Options for configuring a single Donation Alerts API call.

interface DonationAlertsApiCallOptions {
    auth?: boolean;
    formBody?: object;
    jsonBody?: object;
    method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
    query?: Record<
        string,
        undefined
        | null
        | string
        | number
        | string[]
        | number[],
    >;
    scope?: string;
    type?: DonationAlertsCallType;
    url: string;
}

Properties

auth?: boolean

Indicates whether OAuth credentials should be generated and appended to the request.

true

formBody?: object

The form URL encoded body to send with the API call.

This is similar to jsonBody, but the body is URL-encoded instead of JSON. It's used for application/x-www-form-urlencoded content type.

jsonBody?: object

The JSON body to send with the API call.

This is only used when the HTTP method allows a body (e.g., POST, PUT). The body will be serialized into JSON before being sent.

method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"

The HTTP method to use for the API call.

GET

query?: Record<string, undefined | null | string | number | string[] | number[]>

The query parameters to include with the API call.

This should be supplied as a key-value object, where values can be strings, numbers, arrays, or null/undefined.

scope?: string

The OAuth scope required for this request.

The specified scope determines whether the request has sufficient authorization to access the requested resource.

The type of API call to make: api, auth, or custom.

  • api: The request will use the https://www.donationalerts.com/api/v1 base URL, combining it with the url.
  • auth: The request will use the https://www.donationalerts.com/oauth base URL, combining it with the url.
  • custom: The request will not modify or override the url property. The url must be a fully formed valid URL.

api

url: string

The URL or endpoint for the API call.

  • If type is set to api or auth, this property should specify only the endpoint portion (e.g., alerts/donations for api or oauth/token for auth), excluding the base URL.
  • If type is set to custom, a full and valid URL must be provided (e.g. https://example.com/my-endpoint).

Calling api endpoints:

const options: DonationAlertsApiCallOptions = {
url: "alerts/donations",
type: "api"
};

Calling auth endpoints:

const options: DonationAlertsApiCallOptions = {
url: "oauth/token",
type: "auth",
method: "POST"
};