Skip to content

Commit c6e5669

Browse files
committed
More details when net-connected.
1 parent 48bd84a commit c6e5669

File tree

4 files changed

+308
-100
lines changed

4 files changed

+308
-100
lines changed

frontend/src/api/discogs.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
ICollections,
44
IIdentify,
55
IProfile,
6+
IRelease,
67
IReleases,
78
IReleaseSet,
89
VinylAPIImageMap,
@@ -142,3 +143,18 @@ export const getCollectionAndWants = async (
142143
wants: wantsReleases,
143144
}
144145
}
146+
147+
export const getReleaseInfo = async (password: string, id: number): Promise<IRelease> => {
148+
const response = await fetch(`${API_URL}/releases/${id}`, {
149+
headers: {
150+
"Content-Type": "application/json",
151+
Authorization: `Discogs token=${password}`,
152+
},
153+
})
154+
155+
if (!response.ok) {
156+
throw new Error("Network response was not ok")
157+
}
158+
159+
return await response.json()
160+
}

frontend/src/api/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
export { getCollectionAndWants, getMe, getProfile } from "./discogs"
1+
export { getCollectionAndWants, getMe, getProfile, getReleaseInfo } from "./discogs"
22
export type {
33
ICollections,
44
IWants,
55
IIdentify,
66
IProfile,
77
IPagination,
8+
IRelease,
89
IReleases,
910
IReleaseSet,
1011
IVinylResponse,

frontend/src/api/interface.ts

Lines changed: 83 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,38 @@ interface label {
1717
entity_type_name: string
1818
}
1919

20+
interface format {
21+
name: string
22+
qty: string
23+
descriptions: string[]
24+
}
25+
26+
interface committer {
27+
username: string
28+
resource_url: string
29+
}
30+
31+
interface identifiers {
32+
type: string
33+
value: string
34+
description: string
35+
}
36+
37+
interface videos {
38+
uri: string
39+
title: string
40+
description: string
41+
duration: number
42+
embed: boolean
43+
}
44+
45+
interface track {
46+
title: string
47+
position: string
48+
type_: string
49+
duration: string
50+
}
51+
2052
export interface IPagination {
2153
page: number
2254
pages: number
@@ -36,31 +68,61 @@ export interface IReleases {
3668
folder_id: number
3769
date_added: Date
3870
rating: number
39-
basic_information: {
40-
id: number
41-
master_id: number
42-
master_url?: string
43-
resource_url: string
44-
thumb: string
45-
cover_image: string
46-
title: string
47-
year: number
48-
formats: [
49-
{
50-
name: string
51-
qty: string
52-
descriptions: string[]
53-
},
54-
]
55-
artists: artist[]
56-
labels: label[]
57-
genres: string[]
58-
styles: string[]
59-
}
71+
basic_information: IReleaseLight
6072
image_base64?: string
6173
barcode?: string
6274
}
6375

76+
export interface IReleaseLight {
77+
id: number
78+
master_id: number
79+
master_url?: string
80+
resource_url: string
81+
thumb: string
82+
cover_image: string
83+
title: string
84+
year: number
85+
formats: format[]
86+
artists: artist[]
87+
labels: label[]
88+
genres: string[]
89+
styles: string[]
90+
}
91+
92+
export interface IRelease extends IReleaseLight {
93+
status: string
94+
uri: string
95+
artists_sort: string
96+
data_quality: string
97+
community: {
98+
have: number
99+
want: number
100+
rating: {
101+
count: number
102+
average: number
103+
}
104+
submitter: committer
105+
contributors: committer[]
106+
data_quality: string
107+
status: string
108+
}
109+
format_quantity: number
110+
date_added: string
111+
date_changed: string
112+
num_for_sale: number
113+
lowest_price: number
114+
country: string
115+
released: string
116+
notes: string
117+
released_formatted: string
118+
identifiers: identifiers[]
119+
videos: videos[]
120+
tracklist: track[]
121+
extraartists: artist[]
122+
estimated_weight: number
123+
blocked_from_sale: boolean
124+
}
125+
64126
export interface IReleaseSet {
65127
collection: IReleases[]
66128
wants: IReleases[]

0 commit comments

Comments
 (0)