All files / sdk/models activeTriggers.ts

81.81% Statements 9/11
100% Branches 1/1
77.77% Functions 7/9
80% Lines 8/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 669x     9x         13x                         1x                         2x   2x                                         1x         1x      
import apiClient from "../client/client"
import { BackendClient } from "./backendClient";
 
export class ActiveTriggers {
 
    backendClient: BackendClient;
 
    constructor(backendClient: BackendClient) {
        this.backendClient = backendClient;
    }
    /**
     * Retrieves details of a specific active trigger in the Composio platform by providing its trigger name.
     * 
     * The response includes the trigger's name, description, input parameters, expected response, associated app information, and enabled status.
     * 
     * @param {GetActiveTriggerData} data The data for the request.
     * @returns {CancelablePromise<GetActiveTriggerResponse>} A promise that resolves to the details of the active trigger.
     * @throws {ApiError} If the request fails.
     */
     get(data: any): any {
        //@ts-ignore
        return apiClient.triggers.getTrigger(data).then(res => res.data)
    }
 
    /**
     * Retrieves a list of all active triggers in the Composio platform.
     * 
     * This method allows you to fetch a list of all the available active 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.
     * 
     * @param {ListActiveTriggersData} data The data for the request.
     * @returns {CancelablePromise<ListActiveTriggersResponse>} A promise that resolves to the list of all active triggers.
     * @throws {ApiError} If the request fails.
     */
     list(data: any = {}): any {
        return apiClient.triggers.getActiveTriggers({
            query: data
        }).then(res => (res.data as Record<string,string>).triggers)
    }
 
    /**
     * Enables the previously disabled trigger.
     * 
     * @param {Object} data The data for the request.
     * @param {string} data.triggerId Id of the trigger
     * @returns {CancelablePromise<Record<string, any>>} A promise that resolves to the response of the enable request.
     * @throws {ApiError} If the request fails.
     */
    enable(data: {triggerId: any}): any {
        return apiClient.triggers.switchTriggerInstanceStatus({
            path: data,
            body:{
                enabled: true
            }
        }).then(res => res.data)
    }
 
    static disable(data: {triggerId: any}): any {
        return apiClient.triggers.switchTriggerInstanceStatus({
            path: data,
            body: {
                enabled: false
            }
        }).then(res => res.data)
    }
}