All files / src/store/features/triggers/api getMSTeamsWebhookOptionsApi.ts

0% Statements 0/12
0% Branches 0/1
0% Functions 0/5
0% Lines 0/11

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                                                             
import { ALL_CONNECTORS } from "../../../../constants/index.ts";
import { apiSlice } from "../../../app/apiSlice.ts";
 
export const getMSTeamsWebhookOptionsApi = apiSlice.injectEndpoints({
  endpoints: (builder) => ({
    getMSTeamsWebhookOptions: builder.query<any, void>({
      query: () => ({
        url: ALL_CONNECTORS,
        method: "POST",
        body: {
          connector_type: "MS_TEAMS",
        },
      }),
      transformResponse: (response) => {
        Iif (response?.connectors?.length > 0) {
          const active_webhooks = response.connectors.map((connector: any) => ({
            name: connector.name,
            keyId: connector.keys.find(
              (key: any) => key.key_type === "MS_TEAMS_CONNECTOR_WEBHOOK_URL",
            )?.key,
          }));
          return active_webhooks;
        }
        return [];
      },
    }),
  }),
});
 
export const { useGetMSTeamsWebhookOptionsQuery } = getMSTeamsWebhookOptionsApi;