/* Types for kwikl.mjs (KWIK L API v1). The answers are the API's JSON; the shapes are documented at
   https://kwikl.com/developers. */

export declare const VERSION: string;

export declare class KwiklError extends Error {
  status: number;
  code: string;
  detail: string;
  constructor(status: number, code: string, detail: string);
}

export interface KwiklOptions {
  base?: string;
  fetch?: typeof fetch;
}

export interface DayItem {
  kind: string;
  title: string;
  why: string;
  href: string;
}

export interface YesCard {
  id: string;
  kind: string;
  what: string;
  title: string;
  summary: string;
  payload: Record<string, unknown>;
  spend: number;
  currency: string;
  state: "waiting" | "done" | "failed" | "declined";
  ref_id: string;
  result: { link?: string; error?: string; said?: string; provider_id?: string };
  made_at: string;
  decided_at: string;
}

export declare class Kwikl {
  constructor(key: string, options?: KwiklOptions);
  call<T = unknown>(method: string, path: string, body?: unknown, query?: Record<string, unknown>): Promise<T>;
  me(): Promise<Record<string, unknown>>;
  businesses(q?: { min_fit?: number; limit?: number }): Promise<unknown[]>;
  saveBusinesses(rows: Record<string, unknown>[]): Promise<unknown>;
  messages(status?: string): Promise<unknown[]>;
  draft(q?: { prospect_ids?: string[] | null; min_fit?: number; limit?: number }): Promise<unknown>;
  send(message_ids?: string[] | null): Promise<unknown>;
  approvals(status?: string): Promise<unknown[]>;
  approve(id: string, note?: string): Promise<unknown>;
  decline(id: string, note?: string): Promise<unknown>;
  outcomes(): Promise<unknown>;
  meetings(): Promise<unknown>;
  bookMeeting(m: { starts_at: string; with_name: string; with_email: string; title?: string; notes?: string }): Promise<unknown>;
  proposals(): Promise<unknown>;
  strategy(): Promise<unknown>;
  opportunities(): Promise<unknown>;
  country(code: string): Promise<unknown>;
  consent(subject: string): Promise<unknown>;
  recordConsent(c: { subject: string; action: string; channel?: string; country?: string; note?: string }): Promise<unknown>;
  invoices(): Promise<unknown>;
  day(): Promise<{ date: string; ten: DayItem[]; meetings: unknown[]; deadlines: unknown[]; waiting_cards: number }>;
  dayCards(): Promise<{ cards: YesCard[] }>;
  yes(cardId: string): Promise<YesCard>;
  no(cardId: string): Promise<YesCard>;
  dealDesk(): Promise<unknown>;
  customers(): Promise<unknown>;
  numbers(): Promise<unknown>;
}
