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

import type { Client, Options as Options2, TDataShape } from './client';
import { client } from './client.gen';
import type { BullXWebApiSpecServiceDescData, BullXWebApiSpecServiceDescResponses, CheckChannelConnectivityData, CheckChannelConnectivityErrors, CheckChannelConnectivityResponses, CreateChannelData, CreateChannelErrors, CreateChannelResponses, DeleteChannelData, DeleteChannelErrors, DeleteChannelResponses, GetChannelData, GetChannelErrors, GetChannelResponses, ListChannelAdaptersData, ListChannelAdaptersResponses, ListChannelsData, ListChannelsResponses, UpdateChannelData, UpdateChannelErrors, UpdateChannelResponses } from './types.gen';

export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
    /**
     * 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>;
};

/**
 * List channel adapters
 *
 * Lists installed channel adapters and the schema describing their config form.
 */
export const listChannelAdapters = <ThrowOnError extends boolean = false>(options?: Options<ListChannelAdaptersData, ThrowOnError>) => (options?.client ?? client).get<ListChannelAdaptersResponses, unknown, ThrowOnError>({
    security: [{
            in: 'cookie',
            name: '_bullx_key',
            type: 'apiKey'
        }],
    url: '/.internal-apis/v1/channel-adapters',
    ...options
});

/**
 * List channels
 *
 * Lists every configured channel source across all enabled adapters.
 */
export const listChannels = <ThrowOnError extends boolean = false>(options?: Options<ListChannelsData, ThrowOnError>) => (options?.client ?? client).get<ListChannelsResponses, unknown, ThrowOnError>({
    security: [{
            in: 'cookie',
            name: '_bullx_key',
            type: 'apiKey'
        }],
    url: '/.internal-apis/v1/channels',
    ...options
});

/**
 * Create a channel
 */
export const createChannel = <ThrowOnError extends boolean = false>(options?: Options<CreateChannelData, ThrowOnError>) => (options?.client ?? client).post<CreateChannelResponses, CreateChannelErrors, ThrowOnError>({
    security: [{
            in: 'cookie',
            name: '_bullx_key',
            type: 'apiKey'
        }],
    url: '/.internal-apis/v1/channels',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options?.headers
    }
});

/**
 * Check channel connectivity
 *
 * Validates a source payload and probes the adapter without persisting anything.
 */
export const checkChannelConnectivity = <ThrowOnError extends boolean = false>(options?: Options<CheckChannelConnectivityData, ThrowOnError>) => (options?.client ?? client).post<CheckChannelConnectivityResponses, CheckChannelConnectivityErrors, ThrowOnError>({
    security: [{
            in: 'cookie',
            name: '_bullx_key',
            type: 'apiKey'
        }],
    url: '/.internal-apis/v1/channels/connectivity-check',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options?.headers
    }
});

/**
 * Delete a channel
 */
export const deleteChannel = <ThrowOnError extends boolean = false>(options: Options<DeleteChannelData, ThrowOnError>) => (options.client ?? client).delete<DeleteChannelResponses, DeleteChannelErrors, ThrowOnError>({
    security: [{
            in: 'cookie',
            name: '_bullx_key',
            type: 'apiKey'
        }],
    url: '/.internal-apis/v1/channels/{adapter_id}/{id}',
    ...options
});

/**
 * Get a channel
 */
export const getChannel = <ThrowOnError extends boolean = false>(options: Options<GetChannelData, ThrowOnError>) => (options.client ?? client).get<GetChannelResponses, GetChannelErrors, ThrowOnError>({
    security: [{
            in: 'cookie',
            name: '_bullx_key',
            type: 'apiKey'
        }],
    url: '/.internal-apis/v1/channels/{adapter_id}/{id}',
    ...options
});

/**
 * Update a channel
 */
export const updateChannel = <ThrowOnError extends boolean = false>(options: Options<UpdateChannelData, ThrowOnError>) => (options.client ?? client).put<UpdateChannelResponses, UpdateChannelErrors, ThrowOnError>({
    security: [{
            in: 'cookie',
            name: '_bullx_key',
            type: 'apiKey'
        }],
    url: '/.internal-apis/v1/channels/{adapter_id}/{id}',
    ...options,
    headers: {
        'Content-Type': 'application/json',
        ...options.headers
    }
});

/**
 * Well-known service description
 */
export const bullXWebApiSpecServiceDesc = <ThrowOnError extends boolean = false>(options?: Options<BullXWebApiSpecServiceDescData, ThrowOnError>) => (options?.client ?? client).get<BullXWebApiSpecServiceDescResponses, unknown, ThrowOnError>({ url: '/.well-known/service-desc', ...options });
