import { IDeleteFakeResponseParams, IPostSaveFakeResponseRequestBody } from "@business-logic/types/CcisApi";
import axios from "axios";

const authToken = process.env.CCIS_API_AUTH || '';
const ccisUrl = process.env.CCIS_API_URL || '';

export default class CcisApiUtil {
    readonly baseUrl = ccisUrl;
    readonly postCreateMockPolicyUrl = `${this.baseUrl}/ccis/api/v1/admin/fakeResponses/save`
    readonly deleteFakeResponseUrl = `${this.baseUrl}/ccis/api/v1/admin/fakeResponses`

    createFakeResponse(requestBody: IPostSaveFakeResponseRequestBody) {
        return axios.post(this.postCreateMockPolicyUrl, requestBody, {
            headers: {
                'X-Mule-Origin-Verify': authToken
            }
        });
    }

    deleteFakeResponse(params: IDeleteFakeResponseParams) {
        const deleteUrl = `${this.deleteFakeResponseUrl}/${params.accountNumber}/${params.key}/${params.responseType}`;
        return axios.delete(deleteUrl, {
            headers: {
                'X-Mule-Origin-Verify': authToken
            }
        });
    }
}