import { serviceFactory } from "../config/service-factory";
import { ApiKey, ApiResponse, systemApiKeyRequestModel } from "../models/models";

export const systemApiKeyService = {
  getBySystemApiKey: async (apyKey: string): Promise<ApiKey> => {
    const response = await serviceFactory
      .getSystemApiKeyServiceAxios()
      .get(`/byKey/${apyKey}`);
    return response.data;
  },
  generateSystemApiKey: async (requestModel: systemApiKeyRequestModel): Promise<ApiResponse> => {
    try {
      const response =  await serviceFactory.getSystemApiKeyServiceAxios().post('', requestModel);
      return response.data;
    } catch {
      throw new Error("User authentication failed.");
    }
  }
};