import { AxiosInstance } from 'axios';

export type Token = {
    accessToken: string;
    refreshToken: string;
};

export type Store = {
    getToken: () => Promise<Token | undefined>;
    setToken: (token: Token) => Promise<void>;
};

export type ClientOptions = {
    fleetId: string;
    name?: string;
    fleetMaster?: string;
    baseUrl: string;
    clientId: string;
    clientSecret: string;
    apiKey: string;
    secure?: boolean;
    logCurl?: boolean;
    logResponse?: boolean;
    store?: Store;
    onLog?: (...args: any[]) => void;
};

export type ClientError = {
    formattedError: {
        status?: number;
        data?: any;
        message?: string;
    };
    originalError: any;
};

export type Client = AxiosInstance & {
    signInWithPassword: (username: string, password: string) => Promise<Token>;
    clientOptions: ClientOptions;
};
