@parcl-finance/product-sdk
Version:
TypeScript SDK for interacting with Parcl's product APIs
74 lines • 2.36 kB
TypeScript
import { PublicKey } from "@solana/web3.js";
type GetArgs = {
path: string;
params?: Params;
accessToken?: string;
};
type PostArgs<B> = {
path: string;
body?: B;
params?: Params;
accessToken?: string;
};
type AuthPostArgs<B> = {
path: string;
body?: B;
params?: Params;
authority: PublicKey;
};
type PutArgs<B> = {
path: string;
body?: B;
accessToken?: string;
};
type DeleteArgs = {
path: string;
params?: Params;
accessToken?: string;
};
type HttpClientInterface = {
get: <T>(args: GetArgs) => Promise<T>;
post: <B, T>(args: PostArgs<B>) => Promise<T>;
put: <B, T>(args: PutArgs<B>) => Promise<T>;
delete: <T>(args: DeleteArgs) => Promise<T>;
};
type Headers = Record<string, string>;
type Params = Record<string, unknown>;
export declare class HttpClient implements HttpClientInterface {
baseUrl: string;
headers: Headers;
private instance;
constructor(baseUrl: string, headers: Headers);
private handleResponse;
private setAuthorizationHeader;
get: <T>({ path, params, accessToken }: GetArgs) => Promise<T>;
getWithAuth: <T>({ path, params, authority, }: {
path: string;
params?: Params | undefined;
authority: PublicKey;
}) => Promise<T>;
post: <B, T>({ path, body, params, accessToken }: PostArgs<B>) => Promise<T>;
postWithAuth: <B, T>({ path, body, params, authority }: AuthPostArgs<B>) => Promise<T>;
private refreshTokens;
put: <B, T>({ path, body, accessToken }: PutArgs<B>) => Promise<T>;
delete: <T>({ path, params, accessToken }: DeleteArgs) => Promise<T>;
}
export declare function getRefreshToken({ publicKey }: {
publicKey: PublicKey | null;
}): string | undefined;
export declare function setRefreshToken({ publicKey, token, }: {
publicKey: PublicKey | null;
token: string;
}): void;
export declare function getAccessToken({ publicKey }: {
publicKey: PublicKey | null;
}): string | undefined;
export declare function setAccessToken({ publicKey, token, }: {
publicKey: PublicKey | null;
token: string;
}): void;
export declare function getItem<T>(key: string): T | undefined;
export declare function removeItem(key: string): void;
export declare function setItem<_K, V>(key: string, value: V): void;
export {};
//# sourceMappingURL=httpClient.d.ts.map