import axios from 'api'; import { ErrorResponseHandler } from 'api/ErrorResponseHandler'; import { AxiosError } from 'axios'; import { SOMETHING_WENT_WRONG } from 'constants/api'; import { ErrorResponse, SuccessResponse } from 'types/api'; import { MessagingQueueServicePayload, MessagingQueuesPayloadProps, } from './getConsumerLagDetails'; export const getTopicThroughputDetails = async ( props: MessagingQueueServicePayload, ): Promise< SuccessResponse | ErrorResponse > => { const { detailType, ...rest } = props; const endpoint = `/messaging-queues/kafka/topic-throughput/${detailType}`; try { const response = await axios.post(endpoint, { ...rest, }); return { statusCode: 200, error: null, message: response.data.status, payload: response.data.data, }; } catch (error) { return ErrorResponseHandler((error as AxiosError) || SOMETHING_WENT_WRONG); } };