shared/api/endpoints/
playlist.rs1use crate::{
2 api::Method,
3 domain::{
4 playlist::{
5 ListLikedPath, ListLikedRequest, ListLikedResponse, PlaylistAdminDataUpdatePath,
6 PlaylistBrowsePath, PlaylistBrowseQuery, PlaylistBrowseResponse, PlaylistClonePath,
7 PlaylistCreatePath, PlaylistCreateRequest, PlaylistDeletePath, PlaylistGetDraftPath,
8 PlaylistGetLivePath, PlaylistId, PlaylistLikePath, PlaylistLikedPath,
9 PlaylistLikedResponse, PlaylistPublishPath, PlaylistResponse, PlaylistSearchPath,
10 PlaylistSearchQuery, PlaylistSearchResponse, PlaylistUnlikePath,
11 PlaylistUpdateAdminDataRequest, PlaylistUpdateDraftDataPath,
12 PlaylistUpdateDraftDataRequest, PlaylistViewPath,
13 },
14 CreateResponse,
15 },
16 error::{EmptyError, MetadataNotFound},
17};
18
19use super::ApiEndpoint;
20
21pub struct Create;
37impl ApiEndpoint for Create {
38 type Req = PlaylistCreateRequest;
39 type Res = CreateResponse<PlaylistId>;
40 type Path = PlaylistCreatePath;
41 type Err = MetadataNotFound;
42 const METHOD: Method = Method::Post;
43}
44
45pub struct GetLive;
54impl ApiEndpoint for GetLive {
55 type Req = ();
56 type Res = PlaylistResponse;
57 type Path = PlaylistGetLivePath;
58 type Err = EmptyError;
59 const METHOD: Method = Method::Get;
60}
61
62pub struct GetDraft;
72impl ApiEndpoint for GetDraft {
73 type Req = ();
74 type Res = PlaylistResponse;
75 type Path = PlaylistGetDraftPath;
76 type Err = EmptyError;
77 const METHOD: Method = Method::Get;
78}
79
80pub struct UpdateDraftData;
92impl ApiEndpoint for UpdateDraftData {
93 type Req = PlaylistUpdateDraftDataRequest;
94 type Res = ();
95 type Path = PlaylistUpdateDraftDataPath;
96 type Err = MetadataNotFound;
97 const METHOD: Method = Method::Patch;
98}
99
100pub struct Publish;
106impl ApiEndpoint for Publish {
107 type Req = ();
108 type Res = ();
109 type Path = PlaylistPublishPath;
110 type Err = EmptyError;
111 const METHOD: Method = Method::Put;
112}
113
114pub struct Browse;
119impl ApiEndpoint for Browse {
120 type Req = PlaylistBrowseQuery;
121 type Res = PlaylistBrowseResponse;
122 type Path = PlaylistBrowsePath;
123 type Err = EmptyError;
124 const METHOD: Method = Method::Get;
125}
126
127pub struct Search;
132impl ApiEndpoint for Search {
133 type Req = PlaylistSearchQuery;
134 type Res = PlaylistSearchResponse;
135 type Path = PlaylistSearchPath;
136 type Err = EmptyError;
137 const METHOD: Method = Method::Get;
138}
139
140pub struct Delete;
146impl ApiEndpoint for Delete {
147 type Req = ();
148 type Res = ();
149 type Path = PlaylistDeletePath;
150 type Err = EmptyError;
151 const METHOD: Method = Method::Delete;
152}
153
154pub struct Clone;
165impl ApiEndpoint for Clone {
166 type Path = PlaylistClonePath;
167 type Req = ();
168 type Res = CreateResponse<PlaylistId>;
169 type Err = EmptyError;
170 const METHOD: Method = Method::Post;
171}
172
173pub struct Like;
178impl ApiEndpoint for Like {
179 type Path = PlaylistLikePath;
180 type Req = ();
181 type Res = ();
182 type Err = EmptyError;
183 const METHOD: Method = Method::Put;
184}
185
186pub struct Unlike;
191impl ApiEndpoint for Unlike {
192 type Path = PlaylistUnlikePath;
193 type Req = ();
194 type Res = ();
195 type Err = EmptyError;
196 const METHOD: Method = Method::Delete;
197}
198
199pub struct ListLiked;
201impl ApiEndpoint for ListLiked {
202 type Req = ListLikedRequest;
203 type Res = ListLikedResponse;
204 type Path = ListLikedPath;
205 type Err = EmptyError;
206 const METHOD: Method = Method::Get;
207}
208
209pub struct Liked;
214impl ApiEndpoint for Liked {
215 type Path = PlaylistLikedPath;
216 type Req = ();
217 type Res = PlaylistLikedResponse;
218 type Err = EmptyError;
219 const METHOD: Method = Method::Get;
220}
221
222pub struct View;
227impl ApiEndpoint for View {
228 type Path = PlaylistViewPath;
229 type Req = ();
230 type Res = ();
231 type Err = EmptyError;
232 const METHOD: Method = Method::Put;
233}
234
235pub struct PlaylistAdminDataUpdate;
247impl ApiEndpoint for PlaylistAdminDataUpdate {
248 type Path = PlaylistAdminDataUpdatePath;
249 type Req = PlaylistUpdateAdminDataRequest;
250 type Res = ();
251 type Err = EmptyError;
252 const METHOD: Method = Method::Patch;
253}