47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { fetchWithAuth } from "./client";
|
|
|
|
export interface BrandScoreDimension {
|
|
name: string;
|
|
score: number;
|
|
max_score: number;
|
|
description: string;
|
|
}
|
|
|
|
export interface BrandScore {
|
|
overall_score: number;
|
|
dimensions: BrandScoreDimension[];
|
|
generated_at: string;
|
|
}
|
|
|
|
export interface BrandCompareCompetitor {
|
|
name: string;
|
|
scores: Record<string, number>;
|
|
}
|
|
|
|
export interface BrandCompare {
|
|
brand_name: string;
|
|
competitors: BrandCompareCompetitor[];
|
|
dimensions: string[];
|
|
}
|
|
|
|
export interface ScoreHistoryEntry {
|
|
date: string;
|
|
overall_score: number;
|
|
dimension_scores: Record<string, number>;
|
|
}
|
|
|
|
export interface ScoreHistory {
|
|
scores: ScoreHistoryEntry[];
|
|
}
|
|
|
|
export const scoringApi = {
|
|
getScore: (token: string, brandId: string) =>
|
|
fetchWithAuth(`/api/v1/brands/${brandId}/score/`, {}, token) as Promise<BrandScore>,
|
|
|
|
getHistory: (token: string, brandId: string) =>
|
|
fetchWithAuth(`/api/v1/brands/${brandId}/score/history/`, {}, token) as Promise<ScoreHistory>,
|
|
|
|
getCompare: (token: string, brandId: string) =>
|
|
fetchWithAuth(`/api/v1/brands/${brandId}/compare/`, {}, token) as Promise<BrandCompare>,
|
|
};
|