// This file is auto-generated by @hey-api/openapi-ts

import type { Client, Options as ClientOptions, TDataShape } from "./client";
import { client as _heyApiClient } from "./client.gen";
import type {
    GetBoardsData,
    GetBoardsErrors,
    GetBoardsResponses,
    GetDealsData,
    GetDealsErrors,
    GetDealsResponses,
    GetProjectsData,
    GetProjectsResponses,
    GetStatusesData,
    GetStatusesErrors,
    GetStatusesResponses,
    UpdateBoardData,
    UpdateBoardErrors,
    UpdateBoardResponses,
    UpdateDealData,
    UpdateDealErrors,
    UpdateDealResponses,
    UpdateStatusData,
    UpdateStatusErrors,
    UpdateStatusResponses,
} from "./types.gen";

export type Options<
    TData extends TDataShape = TDataShape,
    ThrowOnError extends boolean = boolean,
> = ClientOptions<TData, ThrowOnError> & {
    /**
     * You can provide a client instance returned by `createClient()` instead of
     * individual options. This might be also useful if you want to implement a
     * custom client.
     */
    client?: Client;
    /**
     * You can pass arbitrary values through the `meta` object. This can be
     * used to access values that aren't defined as part of the SDK function.
     */
    meta?: Record<string, unknown>;
};

/**
 * Get Projects
 */
export const getProjects = <ThrowOnError extends boolean = false>(
    options?: Options<GetProjectsData, ThrowOnError>
) => {
    return (options?.client ?? _heyApiClient).get<
        GetProjectsResponses,
        unknown,
        ThrowOnError
    >({
        responseType: "json",
        url: "/project/",
        ...options,
    });
};

/**
 * Get Boards
 */
export const getBoards = <ThrowOnError extends boolean = false>(
    options: Options<GetBoardsData, ThrowOnError>
) => {
    return (options.client ?? _heyApiClient).get<
        GetBoardsResponses,
        GetBoardsErrors,
        ThrowOnError
    >({
        responseType: "json",
        url: "/board/{projectId}",
        ...options,
    });
};

/**
 * Update Board
 */
export const updateBoard = <ThrowOnError extends boolean = false>(
    options: Options<UpdateBoardData, ThrowOnError>
) => {
    return (options.client ?? _heyApiClient).patch<
        UpdateBoardResponses,
        UpdateBoardErrors,
        ThrowOnError
    >({
        responseType: "json",
        url: "/board/{boardId}",
        ...options,
        headers: {
            "Content-Type": "application/json",
            ...options.headers,
        },
    });
};

/**
 * Get Statuses
 */
export const getStatuses = <ThrowOnError extends boolean = false>(
    options: Options<GetStatusesData, ThrowOnError>
) => {
    return (options.client ?? _heyApiClient).get<
        GetStatusesResponses,
        GetStatusesErrors,
        ThrowOnError
    >({
        responseType: "json",
        url: "/status/{boardId}",
        ...options,
    });
};

/**
 * Update Status
 */
export const updateStatus = <ThrowOnError extends boolean = false>(
    options: Options<UpdateStatusData, ThrowOnError>
) => {
    return (options.client ?? _heyApiClient).patch<
        UpdateStatusResponses,
        UpdateStatusErrors,
        ThrowOnError
    >({
        responseType: "json",
        url: "/status/{statusId}",
        ...options,
        headers: {
            "Content-Type": "application/json",
            ...options.headers,
        },
    });
};

/**
 * Get Deals
 */
export const getDeals = <ThrowOnError extends boolean = false>(
    options: Options<GetDealsData, ThrowOnError>
) => {
    return (options.client ?? _heyApiClient).get<
        GetDealsResponses,
        GetDealsErrors,
        ThrowOnError
    >({
        responseType: "json",
        url: "/deal/{boardId}",
        ...options,
    });
};

/**
 * Update Deal
 */
export const updateDeal = <ThrowOnError extends boolean = false>(
    options: Options<UpdateDealData, ThrowOnError>
) => {
    return (options.client ?? _heyApiClient).patch<
        UpdateDealResponses,
        UpdateDealErrors,
        ThrowOnError
    >({
        responseType: "json",
        url: "/deal/{dealId}",
        ...options,
        headers: {
            "Content-Type": "application/json",
            ...options.headers,
        },
    });
};
