export type ApiLabelAssignRequest = {label: string, expiration_seconds?: number | undefined}; export type CreateApiApiV3LabelsAddressArgs = {address: string, body: ApiLabelAssignRequest}; export type CreateApiApiV3LabelsAddressOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Assign a label to a jetton * * POST /api/v3/labels/{address} */ export const createApiApiV3LabelsAddress = async (args: CreateApiApiV3LabelsAddressArgs, options?: CreateApiApiV3LabelsAddressOptions) => { const {baseUrl = "https://tokens.swap.coffee", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKey !== undefined) headers.set("X-Api-Key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/labels/${encodeURIComponent(String(args.address))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };