web/src/utils/fetch-ios-info.ts

61 lines · 1639 bytes

 1import { fetchEnrich } from './fetch-enrich';
 2
 3// Pull the id from an App Store URL's `/id123` segment, else pass it through.
 4const extractId = (iosUrl: string): string => {
 5  const match = iosUrl.match(/\/id(\d+)/);
 6  return match ? match[1] : iosUrl;
 7};
 8
 9export const fetchIosInfo = (iosUrl: string): Promise<IoSApiResponse | null> =>
10  fetchEnrich<IoSApiResponse>(
11    'iOS',
12    `/v1/enrich/ios/${extractId(iosUrl)}`,
13    iosUrl,
14  );
15
16export interface IoSApiResponse {
17  artistViewUrl: string;
18  releaseNotes: string;
19  artworkUrl60: string;
20  artworkUrl100: string;
21  artworkUrl512: string;
22  supportedDevices: string[];
23  features: string[];
24  screenshotUrls: string[];
25  ipadScreenshotUrls: string[];
26  appletvScreenshotUrls: string[];
27  advisories: string[];
28  isGameCenterEnabled: boolean;
29  kind: string;
30  fileSizeBytes: number;
31  sellerUrl: string;
32  formattedPrice: string;
33  userRatingCountForCurrentVersion: number;
34  trackContentRating: string;
35  trackCensoredName: string;
36  trackViewUrl: string;
37  contentAdvisoryRating: string;
38  artistId: number;
39  artistName: string;
40  genres: string[];
41  price: number;
42  trackId: number;
43  trackName: string;
44  description: string;
45  currentVersionReleaseDate: string;
46  averageUserRatingForCurrentVersion: number;
47  isVppDeviceBasedLicensingEnabled: boolean;
48  genreIds: string[];
49  sellerName: string;
50  languageCodesISO2A: string[];
51  releaseDate: string;
52  bundleId: string;
53  currency: string;
54  averageUserRating: number;
55  minimumOsVersion: string;
56  primaryGenreName: string;
57  primaryGenreId: number;
58  version: string;
59  wrapperType: string;
60  userRatingCount: number;
61}