import APIUrl from "../helpers/ApiUrl";
import MakeRequest from "../helpers/makeRequest";
import { IProductDetailsReceiveFields, IProductSearchObj } from "../interfaces/Interfaces";

export default class Products {
    static async searchProducts(searchParam: IProductSearchObj) {
        const postData = null;
        const productsList = await MakeRequest.httpRequest(APIUrl.getProductsListAPI(), "GET", postData, searchParam);
        return productsList;
    }

    static async getProductDetails(productId: string, searchParam: IProductDetailsReceiveFields | null = null) {
        const postData = null;
        let params = {};
        if (searchParam) {
            params = {
                "fields": searchParam?.fields?.join(', ')
            }
        };
        const brandDetails = await MakeRequest.httpRequest(APIUrl.getProductDetailsAPI(productId), "GET", postData, params);
        return brandDetails;
    }

    static async getCreatedProductsDeltaList() {
        const list = await MakeRequest.httpRequest(APIUrl.getCreatedProductsDeltaListAPI(), "GET", null, null);
        return list;
    }

    static async getUpdatedProductsDeltaList() {
        const list = await MakeRequest.httpRequest(APIUrl.getUpdatedProductsDeltaListAPI(), "GET", null, null);
        return list;
    }

    static async getDeletedProductsDeltaList() {
        const list = await MakeRequest.httpRequest(APIUrl.getDeletedProductsDeltaListAPI(), "GET", null, null);
        return list;
    }
}