web/src/utils/fetch-privacy-policy.ts

64 lines · 1269 bytes

6 symbols in this file
 1import { fetchEnrich } from './fetch-enrich';
 2
 3// Wrap the flat ToS;DR v3 record in the shape the app already consumes.
 4export const fetchTosdrPrivacy = async (
 5  serviceId: string,
 6): Promise<PrivacyPolicyResponse | null> => {
 7  const parameters = await fetchEnrich<Params>(
 8    'ToS;DR',
 9    `/v1/enrich/privacy/${serviceId}`,
10    `service ${serviceId}`,
11  );
12  return parameters && { error: 0, message: '', parameters };
13};
14
15interface Document {
16  id: number;
17  name: string;
18  url: string;
19  updated_at: string;
20  created_at: string;
21}
22
23interface Case {
24  id: number;
25  weight: number;
26  title: string;
27  description: string;
28  updated_at: string;
29  created_at: string;
30  topic_id: number;
31  classification: string;
32}
33
34interface Point {
35  id: number;
36  title: string;
37  source: string;
38  status: string;
39  analysis: string;
40  case: Case;
41  document_id: number | null;
42  updated_at: string;
43  created_at: string;
44}
45
46interface Params {
47  id: number;
48  is_comprehensively_reviewed: boolean;
49  name: string;
50  updated_at: string;
51  created_at: string;
52  slug: string;
53  rating: string;
54  urls: string[];
55  image: string;
56  documents: Document[];
57  points: Point[];
58}
59
60export interface PrivacyPolicyResponse {
61  error: number;
62  message: string;
63  parameters: Params;
64}