trello-for-wolves
Version:
Node.js wrapper for Trello API...for wolves.
54 lines (53 loc) • 2.46 kB
TypeScript
import { AnyParams, TrelloConfig, TypedFetch } from "../typeDefs";
interface BaseResourceOptions {
identifier?: string;
}
/**
* Base class for resources. All other resources extend this class.
* @class
*/
export declare class BaseResource {
protected config: TrelloConfig;
protected parentElements: string[];
protected groupName: string;
protected identifier: string;
protected pathElements: string[];
/**
* @param config TrelloConfig object containing Trello API key, token and rate limiting options.
* @param parentElements Parent path elements.
* @param groupName Group name associated with the resource.
* @param [options] Additional options for the resource.
* @constructor
*/
constructor(config: TrelloConfig, parentElements: string[], groupName: string, options?: BaseResourceOptions);
/**
* Returns true if the path elements of this resource instance contains the
* contents of the specified group name/names argument.
* @example
* const resource = trello.boards("74836e2c91e31d1746008921").actions().getActions();
* // From the `actions` instance:
* console.log(this.isChildOf("board")); // true
* console.log(this.isChildOf("action")); // false
*
* @example
* const resource = trello.boards("74836e2c91e31d1746008921").actions().getActions();
* // From the `actions` instance:
* console.log(this.isChildOf(["board", "enterprise"])); // true
* console.log(this.isChildOf(["action", "organization"])); // false
*/
protected isChildOf(groupNameOrNames: string | string[]): boolean;
protected apiGet<T>(endpoint: string, paramsByName?: AnyParams, body?: unknown): TypedFetch<T>;
protected apiPut<T>(endpoint: string, paramsByName?: AnyParams, body?: unknown): TypedFetch<T>;
protected apiPost<T>(endpoint: string, paramsByName?: AnyParams, body?: unknown): TypedFetch<T>;
protected apiDelete<T>(endpoint: string, paramsByName?: AnyParams, body?: unknown): TypedFetch<T>;
/**
* Performs the request to the Trello API and returns response or returns the
* URL string associated with the endpoint.
* @param endpoint API endpoint for making request.
* @param method Method to perform (GET, DELETE, POST, PUT).
* @param paramsByName Params to build the full URL.
* @param body Body of the fetch call.
*/
private onApiFetch;
}
export {};