@mozaic-io/mozaic-sdk-node
Version:
The Mozaic Node SDK enables you to pay your creators easily via the Mozaic API.
29 lines • 1.45 kB
TypeScript
import { AxiosResponse } from "axios";
/**
* All classes in the resource folder should implement this interface so that they
* can be instantiated in the main barrel.
*/
export declare abstract class BaseResource {
protected getValueOrDefault<T>(value: T | null | undefined, defaultValue: T): T;
/**
* A helper function that will either return the variable's value or throw an exception
* if the value is null or undefined. Unit testing is simplified by avoiding ??
* @param name The name of the variable being checked
* @param value The value of the variable being checked
* @returns The value of the variable if it is available, otherwise an exception is thrown.
*/
protected throwIfNullOrUndefined<T>(name: string, value: T | null | undefined): T;
/**
* A helper function to validate limit and paging parameters.
* @param limit Must be between 1 and 100 inclusive.
* @param page Must be greater than 0
*/
protected throwIfLimitOrPageAreInvalid(limit: number, page: number): void;
/**
* A helper function to ensure that API calls are successful and return a valid status code.
* @param call The API call to guard for exceptions and bad return codes.
* @returns A promise of the type returned by Axios in the data field.
*/
protected execute<T>(call: () => Promise<AxiosResponse<T, any>>): Promise<T>;
}
//# sourceMappingURL=BaseResource.d.ts.map