shared/api/endpoints/user/
public_user.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use super::super::ApiEndpoint;
use crate::{
    api::Method,
    domain::{
        jig::JigBrowseResponse,
        playlist::PlaylistBrowseResponse,
        user::public_user::{
            BrowsePublicUserFollowersPath, BrowsePublicUserFollowersQuery,
            BrowsePublicUserFollowersResponse, BrowsePublicUserFollowingPath,
            BrowsePublicUserFollowingResponse, BrowsePublicUserFollowingsQuery,
            BrowsePublicUserJigsPath, BrowsePublicUserJigsQuery, BrowsePublicUserPlaylistsPath,
            BrowsePublicUserPlaylistsQuery, BrowsePublicUserResourcesPath,
            BrowsePublicUserResourcesQuery, BrowsePublicUserResourcesResponse,
            BrowsePublicUserResponse, PublicUser, PublicUserBrowsePath, PublicUserFollowPath,
            PublicUserGetPath, PublicUserSearchPath, PublicUserUnfollowPath, SearchPublicUserQuery,
            SearchPublicUserResponse, UserBrowseQuery,
        },
    },
    error::EmptyError,
};

/// Fetch user profile.
pub struct Get;
impl ApiEndpoint for Get {
    type Req = ();
    type Res = PublicUser;
    type Path = PublicUserGetPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Browse public user
pub struct BrowsePublicUser;
impl ApiEndpoint for BrowsePublicUser {
    type Req = UserBrowseQuery;
    type Res = BrowsePublicUserResponse;
    type Path = PublicUserBrowsePath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Search user profile
pub struct SearchPublicUser;
impl ApiEndpoint for SearchPublicUser {
    type Req = SearchPublicUserQuery;
    type Res = SearchPublicUserResponse;
    type Path = PublicUserSearchPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Browse public user
pub struct BrowseUserJigs;
impl ApiEndpoint for BrowseUserJigs {
    type Req = BrowsePublicUserJigsQuery;
    type Res = JigBrowseResponse;
    type Path = BrowsePublicUserJigsPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Browse user's resources
pub struct BrowseUserResources;
impl ApiEndpoint for BrowseUserResources {
    type Req = BrowsePublicUserResourcesQuery;
    type Res = BrowsePublicUserResourcesResponse;
    type Path = BrowsePublicUserResourcesPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Browse user's playlists
pub struct BrowseUserPlaylists;
impl ApiEndpoint for BrowseUserPlaylists {
    type Req = BrowsePublicUserPlaylistsQuery;
    type Res = PlaylistBrowseResponse;
    type Path = BrowsePublicUserPlaylistsPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Browse user's followers
pub struct BrowseFollowers;
impl ApiEndpoint for BrowseFollowers {
    type Req = BrowsePublicUserFollowersQuery;
    type Res = BrowsePublicUserFollowersResponse;
    type Path = BrowsePublicUserFollowersPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Browse user's followings
pub struct BrowseFollowing;
impl ApiEndpoint for BrowseFollowing {
    type Req = BrowsePublicUserFollowingsQuery;
    type Res = BrowsePublicUserFollowingResponse;
    type Path = BrowsePublicUserFollowingPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Get;
}

/// Follow a user
pub struct Follow;
impl ApiEndpoint for Follow {
    type Req = ();
    type Res = ();
    type Path = PublicUserFollowPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Post;
}

/// Unfollow a user
pub struct Unfollow;
impl ApiEndpoint for Unfollow {
    type Req = ();
    type Res = ();
    type Path = PublicUserUnfollowPath;
    type Err = EmptyError;
    const METHOD: Method = Method::Delete;
}