import axios from "axios";
import { Error400 } from "../../../../utils/customError";
import { IPayload } from "../../dtos/IPayload";

export class UseCase {
  constructor() {}

  async execute(payload: IPayload): Promise<void> {
    try {

      if(!payload.cliente)
        throw new Error400('cliente is required');

      await axios.post(
        `https://dcistore-default-rtdb.firebaseio.com/${payload.cliente}/elephantfy/webhook.json?auth=${process.env.FIREBASE_AUTH}`,
        payload.payload
      )

    } catch (error) {
      throw error;
    }
  }
}