]>
Commit | Line | Data |
---|---|---|
06a05d5f C |
1 | import { makeDeleteRequest, makeGetRequest, makePostBodyRequest } from '../' |
2 | ||
3 | function addUserSubscription (url: string, token: string, targetUri: string, statusCodeExpected = 204) { | |
4 | const path = '/api/v1/users/me/subscriptions' | |
5 | ||
6 | return makePostBodyRequest({ | |
7 | url, | |
8 | path, | |
9 | token, | |
10 | statusCodeExpected, | |
11 | fields: { uri: targetUri } | |
12 | }) | |
13 | } | |
14 | ||
15 | function listUserSubscriptions (url: string, token: string, sort = '-createdAt', statusCodeExpected = 200) { | |
16 | const path = '/api/v1/users/me/subscriptions' | |
17 | ||
18 | return makeGetRequest({ | |
19 | url, | |
20 | path, | |
21 | token, | |
22 | statusCodeExpected, | |
23 | query: { sort } | |
24 | }) | |
25 | } | |
26 | ||
27 | function listUserSubscriptionVideos (url: string, token: string, sort = '-createdAt', statusCodeExpected = 200) { | |
28 | const path = '/api/v1/users/me/subscriptions/videos' | |
29 | ||
30 | return makeGetRequest({ | |
31 | url, | |
32 | path, | |
33 | token, | |
34 | statusCodeExpected, | |
35 | query: { sort } | |
36 | }) | |
37 | } | |
38 | ||
39 | function removeUserSubscription (url: string, token: string, uri: string, statusCodeExpected = 204) { | |
40 | const path = '/api/v1/users/me/subscriptions/' + uri | |
41 | ||
42 | return makeDeleteRequest({ | |
43 | url, | |
44 | path, | |
45 | token, | |
46 | statusCodeExpected | |
47 | }) | |
48 | } | |
49 | ||
50 | // --------------------------------------------------------------------------- | |
51 | ||
52 | export { | |
53 | addUserSubscription, | |
54 | listUserSubscriptions, | |
55 | listUserSubscriptionVideos, | |
56 | removeUserSubscription | |
57 | } |