import { BadRequestError, ConflictError, NotFoundError } from '../errors/index.js';
export async function unwrapResponseDto(request) {
    const response = await request;
    if (!response.responseMeta.success || response.responseMeta.error || response.responseMeta.status !== 200) {
        const errorMessage = response.responseMeta.error?.message ?? response.responseMeta.message ?? `Request failed with status ${response.responseMeta.status}`;
        if (response.responseMeta.status === 409) {
            throw new ConflictError(errorMessage);
        }
        else if (response.responseMeta.status === 404) {
            throw new NotFoundError(errorMessage);
        }
        else if (response.responseMeta.status === 400) {
            throw new BadRequestError(errorMessage);
        }
        throw new Error(errorMessage);
    }
    return response.data;
}
//# sourceMappingURL=response-dto.js.map