import { HasOnComplete, HasOnSuccess } from "@insite/client-framework/HandlerCreator";
import { ApiParameter, get } from "@insite/client-framework/Services/ApiService";
import { SearchRedirectModel } from "@insite/client-framework/Types/ApiModels";

export interface SearchApiParameter extends ApiParameter {
    term: string;
}

const searchUrl = "/api/v1/search";

export function getSearchRedirect(parameter: SearchApiParameter & HasOnSuccess<string> & HasOnComplete<string>) {
    const apiParameter = { ...parameter };
    delete apiParameter.onSuccess;
    delete apiParameter.onComplete;
    return get<SearchRedirectModel>(`${searchUrl}/redirect`, apiParameter);
}
