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

import type { CancelablePromise } from './core/CancelablePromise';
import { OpenAPI } from './core/OpenAPI';
import { request as __request } from './core/request';
import type { ListAllAppsResponse, ListAllConnectionsData, ListAllConnectionsResponse, CreateConnectionData, CreateConnectionResponse, GetConnectedAccountData, GetConnectedAccountResponse, DeleteConnectionData, DeleteConnectionResponse, GetIntegrationData, GetIntegrationResponse, UpdateIntegrationData, UpdateIntegrationResponse, ListAllIntegrationsData, ListAllIntegrationsResponse, CreateIntegrationData, CreateIntegrationResponse, GetActionData, GetActionResponse, GetListActionsResponse, ExecuteActionData, ExecuteActionResponse, ListTriggersData, ListTriggersResponse, ListActiveTriggersData, ListActiveTriggersResponse, GetActiveTriggerData, GetActiveTriggerResponse, PatchUpdateActiveTriggerStatusData, PatchUpdateActiveTriggerStatusResponse, GetAppData, GetAppResponse, GetListActionsData, SetupTriggerData, SetupTriggerResponse } from './types.gen';

/**
 * List All Apps
 * Retrieves a list of all available apps in the Composio platform.
 *
 * This endpoint allows clients to explore and discover the supported apps. It returns an array of app objects, each containing essential details such as the app's key, name, description, logo, categories, and unique identifier.
 *
 * Use this endpoint to build a catalog of available apps and provide your users with an overview of the apps they can integrate with.
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const listAllApps = (config: typeof OpenAPI): CancelablePromise<ListAllAppsResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/apps'
}); };

/**
 * Get a Specific App
 * Retrieves details of a specific app in the Composio platform.
 * @param data The data for the request.
 * @param data.appKey The unique identifier of the app.
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const getApp = (data: GetAppData, config: typeof OpenAPI): CancelablePromise<GetAppResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/apps/{appKey}',
    path: {
        appKey: data.appKey
    }
}); };

/**
 * List All Connected Accounts
 * Retrieves a list of all connected accounts in the Composio platform.
 *
 * It supports pagination and filtering based on various parameters such as app ID, integration ID, and connected  ID. The response includes an array of connection objects, each containing details like the connector ID, connection parameters, status, creation/update timestamps, and associated app information.
 *
 * Use this endpoint to manage and monitor all active connections.
 * @param data The data for the request.
 * @param data.page Page number to fetch
 * @param data.pageSize Page size to assume
 * @param data.integrationId Filter by using specific Integration
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const listAllConnections = (data: ListAllConnectionsData = {}, config: typeof OpenAPI): CancelablePromise<ListAllConnectionsResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/connectedAccounts',
    query: {
        user_uuid: data.user_uuid,
        appNames: data.appNames?.join(','),
        page: data.page,
        pageSize: data.pageSize,
        integrationId: data.integrationId
    }
}); };

/**
 * Connect an Account
 * Connect an account
 *
 * This endpoint allows you to connect an external app account with Composio. It requires the integration ID in the request body and returns the connection status, connection ID, and a redirect URL (if applicable) for completing the connection flow.
 *
 * Use this endpoint to initiate the process of connecting an external app for your end user.
 * @param data The data for the request.
 * @param data.requestBody
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const createConnection = (data: CreateConnectionData = {}, config: typeof OpenAPI): CancelablePromise<CreateConnectionResponse> => { return __request(config, {
    method: 'POST',
    url: '/v1/connectedAccounts',
    body: data.requestBody,
    mediaType: 'application/json',
    errors: {
        404: `{
    "message": "Connector not found"
}`
    }
}); };

/**
 * Get a Connected Account
 * Retrieves details of a specific account connected to the Composio platform by providing its connected account ID.
 * The response includes the integration ID, connection parameters (such as scope, base URL, client ID, token type, access token, etc.), connection ID, status, and creation/update timestamps.
 * @param data The data for the request.
 * @param data.connectedAccountId The unique identifier of the connection.
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const getConnectedAccount = (data: GetConnectedAccountData, config: typeof OpenAPI): CancelablePromise<GetConnectedAccountResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/connectedAccounts/{connectedAccountId}',
    path: {
        connectedAccountId: data.connectedAccountId
    },
    errors: {
        404: `{
    "message": "Connection not found or already deleted"
}`
    }
}); };

/**
 * Delete a Connected Account
 * Remove a specific account from the Composio platform by providing its connection ID. Upon successful deletion, the response includes a status indicating the success of the operation.
 * Use this endpoint to clean up unwanted connections for your end user and manage the connection lifecycle.
 * @param data The data for the request.
 * @param data.connectedAccountId The unique identifier of the connection.
 * @param config The OpenAPI configuration.
 * @returns unknown {
 * "message": "Connection not found or already deleted"
 * }
 * @throws ApiError
 */
export const deleteConnection = (data: DeleteConnectionData, config: typeof OpenAPI): CancelablePromise<DeleteConnectionResponse> => { return __request(config, {
    method: 'DELETE',
    url: '/v1/connectedAccounts/{connectedAccountId}',
    path: {
        connectedAccountId: data.connectedAccountId
    },
    errors: {
        404: 'Not Found'
    }
}); };

/**
 * Get an Integration
 * Retrieves details of a specific integration in the Composio platform by providing its unique identifier. The response includes the connector's name, authentication scheme, authentication configuration, creation and update timestamps, enabled status, associated app information, expected input fields, and logo.
 *
 * Use this endpoint to obtain detailed information about a integration and its configuration. It can be shown to end user for selection.
 *
 * You will also get parameters that are required to be captured from end user to connect an account using this connector.
 * ex. API Key or subdomain URL.
 *
 * If the end-user selects this flow, collect the parameters and connect an account using it.
 * @param data The data for the request.
 * @param data.integrationId The unique identifier of the integration.
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const getIntegration = (data: GetIntegrationData, config: typeof OpenAPI): CancelablePromise<GetIntegrationResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/integrations/{integrationId}',
    path: {
        integrationId: data.integrationId
    },
    errors: {
        404: 'Not Found'
    }
}); };

/**
 * Update an Integration
 * Updates the settings of a specific integration in the Composio platform.
 *
 * This endpoint allows you to modify the settings of a integration, such as enabling or disabling it, by providing its unique identifier. The request body should include the updated settings, and the response indicates the success of the update operation.
 *
 * Use this endpoint to manage the configuration and behavior of integrations in the Composio platform.
 * @param data The data for the request.
 * @param data.integrationId The unique identifier of the integration.
 * @param data.requestBody
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const updateIntegration = (data: UpdateIntegrationData, config: typeof OpenAPI): CancelablePromise<UpdateIntegrationResponse> => { return __request(config, {
    method: 'PATCH',
    url: '/v1/integrations/{integrationId}',
    path: {
        integrationId: data.integrationId
    },
    body: data.requestBody,
    mediaType: 'application/json',
    errors: {
        404: 'Not Found'
    }
}); };

/**
 * List All Integrations
 * Retrieves a list of all integrations in the Composio platform. It supports pagination to handle large numbers of connectors. The response includes an array of connector objects, each containing information such as the connector's ID, name, authentication scheme, creation/update timestamps, enabled status, associated app information, and logo.
 *
 * This are the integration you can showcase to end user, and let them select which integration they want to connect an account with.
 * @param data The data for the request.
 * @param data.page Page number to fetch
 * @param data.pageSize Page Size to assume
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const listAllIntegrations = (data: ListAllIntegrationsData = {}, config: typeof OpenAPI): CancelablePromise<ListAllIntegrationsResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/integrations',
    query: {
        page: data.page,
        pageSize: data.pageSize
    }
}); };

/**
 * Create a new integration
 * This endpoint allows you to add a new integration by providing the necessary details such as the integration name, authentication scheme, associated app ID, and authentication configuration. Upon successful creation, the response includes the newly created connector object.
 * @param data The data for the request.
 * @param data.requestBody
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const createIntegration = (data: CreateIntegrationData = {}, config: typeof OpenAPI): CancelablePromise<CreateIntegrationResponse> => { return __request(config, {
    method: 'POST',
    url: '/v1/integrations',
    body: data.requestBody,
    mediaType: 'application/json',
    errors: {
        400: 'Bad Request'
    }
}); };

/**
 * Get a Specific Action
 * Retrieves details of a specific action in the Composio platform.
 *
 * This endpoint allows you to fetch comprehensive information about a particular action by providing its unique identifier.
 * The response includes the action's name, display name, description, input parameters, expected response, associated app information, and enabled status.
 * Use this endpoint to obtain detailed information about an action, including its configuration and usage requirements.
 * You can then pass this to function calling or use LLM to fill in the parameters.
 * @param data The data for the request.
 * @param data.actionName The unique identifier of the action.
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const getAction = (data: GetActionData, config: typeof OpenAPI): CancelablePromise<GetActionResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/actions/{actionName}',
    path: {
        actionName: data.actionName
    },
    errors: {
        404: 'Not Found'
    }
}); };

/**
 * Get List of Actions
 * Retrieves a list of all actions in the Composio platform.
 *
 * This endpoint allows you to fetch a list of all the available actions. It supports pagination to handle large numbers of actions. The response includes an array of action objects, each containing information such as the action's name, display name, description, input parameters, expected response, associated app information, and enabled status.
 *
 * Use this endpoint to explore and discover the actions supported by the Composio platform and showcase them to end user.
 * @param data The data for the request.
 * @param data.appNames Name of the app like "github", "linear"
 * @param data.useCase Natural language usecase
 * @param data.showEnabledOnly Show actions enabled for the API Key
 * @param data.limit Limit of apis
 * @param data.requestBody
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const getListActions = (data: GetListActionsData = {}, config: typeof OpenAPI): CancelablePromise<GetListActionsResponse> => { 
    return __request(config, {
    method: 'GET',
    url: '/v2/actions',
    query: {
        apps: data.apps,
        actions: data.actions,
        tags: data.tags,
        useCase: data.useCase,
        showEnabledOnly: data.showEnabledOnly,
        usecaseLimit: data.usecaseLimit,
        filterImportantActions: data.filterImportantActions
    }
}); };

/**
 * Execute action
 * Executes a specific action in the Composio platform.
 *
 * This endpoint allows you to trigger the execution of an action by providing its name and the necessary input parameters. The request includes the connected account ID to identify the app connection to use for the action, and the input parameters required by the action. The response provides details about the execution status and the response data returned by the action.
 *
 * Use this endpoint to execute actions available in the Composio platform for your end customer.
 *
 * Executed will indicate whether the action was successfully executed.
 * @param data The data for the request.
 * @param data.actionName The name of the action to execute.
 * @param data.requestBody
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const executeAction = (data: ExecuteActionData, config: typeof OpenAPI): CancelablePromise<ExecuteActionResponse> => { return __request(config, {
    method: 'POST',
    url: '/v1/actions/{actionName}/execute',
    path: {
        actionName: data.actionName
    },
    body: data.requestBody,
    mediaType: 'application/json',
    errors: {
        404: 'Not Found'
    }
}); };

/**
 * Get List of Triggers
 * Retrieves a list of all triggers in the Composio platform.
 *
 * This endpoint allows you to fetch a list of all the available triggers. It supports pagination to handle large numbers of triggers. The response includes an array of trigger objects, each containing information such as the trigger's name, description, input parameters, expected response, associated app information, and enabled status.
 *
 * Use this endpoint to explore and discover the triggers supported by the Composio platform and showcase them to end user.
 * @param data The data for the request.
 * @param data.appNames Name of the apps like "github", "linear" seperated by a comma
 * @param data.showEnabledOnly Show triggers enabled for the API Key
 * @param data.connectedAccountIds Filter by Aonnected Account ids
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const listTriggers = (data: ListTriggersData = {}, config: typeof OpenAPI): CancelablePromise<ListTriggersResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/triggers',
    query: {
        appNames: data.appNames,
        showEnabledOnly: data.showEnabledOnly,
        connectedAccountIds: data.connectedAccountIds
    }
}); };

/**
 * Setup trigger for a connected account
 * This endpoint allows you to enable a trigger for a specific connected account by providing the connected account ID and the trigger name.
 * 
 * @param data The data for the request.
 * @param data.connectedAccountId The ID of the connected account.
 * @param data.triggerName The name of the trigger to enable.
 * @param data.requestBody The request body containing additional configuration for the trigger.
 * @param config The OpenAPI configuration.
 * @returns unknown OK
 * @throws ApiError
 */
export const setupTrigger = (data: SetupTriggerData, config: typeof OpenAPI): CancelablePromise<SetupTriggerResponse> => { return __request(config, {
    method: 'POST',
    url: '/v1/triggers/enable/{connectedAccountId}/{triggerName}',
    path: {
        connectedAccountId: data.connectedAccountId,
        triggerName: data.triggerName
    },
    body: data.requestBody,
    mediaType: 'application/json',
    errors: {
        404: 'Not Found',
        500: 'Internal server error'
    }
}); };

/**
 * Get List of Active Triggers
 * @param data The data for the request.
 * @param data.connectedAccountIds Filter by Connected Account ids
 * @param data.integrationIds Filter by Integration ids
 * @param data.triggerIds Filter by Trigger ids
 * @param data.triggerNames Filter by Trigger names
 * @param config The OpenAPI configuration.
 * @returns unknown A list of active triggers
 * @throws ApiError
 */
export const listActiveTriggers = (data: ListActiveTriggersData = {}, config: typeof OpenAPI): CancelablePromise<ListActiveTriggersResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/triggers/active_triggers',
    query: {
        connectedAccountIds: data.connectedAccountIds,
        integrationIds: data.integrationIds,
        triggerIds: data.triggerIds,
        triggerNames: data.triggerNames
    }
}); };

/**
 * Get Active Trigger
 * Retrieves details of a specific active trigger in the Composio platform by providing its trigger ID.
 * @param data The data for the request.
 * @param data.triggerId The ID of the trigger to retrieve.
 * @param config The OpenAPI configuration.
 * @returns unknown A successful response containing the details of the active trigger.
 * @throws ApiError
 */
export const getActiveTrigger = (data: GetActiveTriggerData, config: typeof OpenAPI): CancelablePromise<GetActiveTriggerResponse> => { return __request(config, {
    method: 'GET',
    url: '/v1/triggers/get/{triggerId}',
    path: {
        triggerId: data.triggerId
    },
    errors: {
        404: 'Trigger not found',
        500: 'Internal server error'
    }
}); };


/**
 * Update active trigger status
 * Retrieves details of a specific active trigger in the Composio platform by providing its trigger ID.
 * @param data The data for the request.
 * @param data.triggerId The ID of the trigger to retrieve.
 * @param data.requestBody
 * @param config The OpenAPI configuration.
 * @returns unknown A successful response containing the details of the active trigger.
 * @throws ApiError
 */
export const updateActiveTriggerStatus = (data: PatchUpdateActiveTriggerStatusData, config: typeof OpenAPI): CancelablePromise<PatchUpdateActiveTriggerStatusResponse> => { return __request(config, {
    method: 'PATCH',
    url: '/v1/triggers/instance/{triggerId}/status',
    path: {
        triggerId: data.triggerId
    },
    body: data.requestBody,
    mediaType: 'application/json',
    errors: {
        404: 'Trigger not found',
        500: 'Internal server error'
    }
}); };