@sodiumlabs/plume-url
Version:
The official Plume URL wrapper
67 lines (62 loc) • 2.09 kB
TypeScript
interface PlumeURLRESTOptions {
apiKey?: string;
userAgent?: string;
}
declare class PlumeURLREST {
readonly options: PlumeURLRESTOptions;
static readonly baseURL = "https://url.sodiumlabs.xyz/api";
static readonly defaultUserAgent: string;
constructor(options?: PlumeURLRESTOptions);
request(method: string, path: string, body?: object): Promise<Response>;
get<T = unknown>(path: string): Promise<T>;
post<T = unknown>(path: string, body?: object): Promise<T>;
}
interface CreateURLOptions {
url: string;
expiresAt?: number | null;
description?: string | null;
customId?: string | null;
}
type EditURLOptions = Partial<CreateURLOptions>;
interface SearchURLOptions {
customId?: string | null;
limit?: number;
page?: number;
expired?: boolean;
}
interface SearchURLResults {
urls: URLData[];
}
interface URLData {
userId: string;
createdAt: number;
destination: string;
shortenId: string;
shorten: string;
infoPage: string;
customId: string | null;
description: string | null;
expiresAt: number | null;
expired: boolean;
views: number;
disabled: boolean;
}
interface PlumeURLOptions extends PlumeURLRESTOptions {
}
/**
* The client to interact with Plume URL
*/
declare class PlumeURL {
readonly rest: PlumeURLREST;
constructor(options?: PlumeURLOptions);
createURL(options: CreateURLOptions): Promise<URLData>;
search({ customId, limit, page, expired }: SearchURLOptions): Promise<SearchURLResults>;
getURL(id: string): Promise<URLData>;
editURL(id: string, options: EditURLOptions): Promise<void>;
deleteURL(id: string): Promise<void>;
}
declare class PlumeURLError extends Error {
res?: (Response | null) | undefined;
constructor(message: string, options?: ErrorOptions | undefined, res?: (Response | null) | undefined);
}
export { type CreateURLOptions, type EditURLOptions, PlumeURL, PlumeURLError, type PlumeURLOptions, PlumeURLREST, type PlumeURLRESTOptions, type SearchURLOptions, type SearchURLResults, type URLData };