import axios from 'axios';

export const callTolgee = async <R>(
	method: 'GET' | 'POST' | 'PUT' | 'DELETE' = 'GET',
	path: string,
	params?: any,
	data?: any,
) => {
	const args = process.argv.slice(2);
	const projectId = args[1];
	try {
		return await axios<R>(`https://translate.romanjaros.local/v2/projects/${projectId}${path}`, {
			method,
			data,
			params,
			headers: {
				'X-API-KEY': process.env.TOLGEE_PAT as string,
			},
		});
	} catch (e) {
		throw e;
	}
};