import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { ApiConfigService } from '../../../core/services/api-config.service';
import { ExpenseAiSuggestion } from '../models/expense.model';

@Injectable({ providedIn: 'root' })
export class ExpenseAiService {
  private readonly endpoint: string;
  constructor(private http: HttpClient, private apiConfig: ApiConfigService) {
    this.endpoint = apiConfig.getApiUrl('expense-ai');
  }

  /** Ask the backend (which proxies Gemini) to translate the text and suggest a category. */
  assist(text: string, amount: number): Observable<ExpenseAiSuggestion> {
    return this.http.post<ExpenseAiSuggestion>(`${this.endpoint}/assist`, { text, amount });
  }
}
