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
use crate::client::endpoints::TargetAPI;
use crate::client::response::{Paginated, Wrapped};
use crate::client::{EndpointMood, Error, RequestParameters};
use crate::mc::mood::Mood;
use std::collections::HashMap;
use std::fmt::Display;
impl<ClientAuthState> EndpointMood<'_, ClientAuthState> {
/// Get all artists.
///
/// Use the optional parameters to alter the pagination or search term.
///
/// Example
/// ```rust
/// use bombay::client::Client;
///
/// let mc = Client::default(); // Without authentication.
/// let all_moods_res = mc.mood().get_all(None);
///
/// if let Ok(moods_resp) = all_moods_res {
/// if let Some(moods) = moods_resp.data {
/// println!("Found all moods:");
/// for mood in &moods {
/// println!(" {} ({})", mood.name, mood.id)
/// }
/// }
/// }
/// ```
///
/// Example URL: <https://player.monstercat.app/api/moods>
pub fn get_all(&self, parameters: Option<RequestParameters>) -> Result<Paginated<Mood>, Error> {
self.client
.get::<Wrapped<Paginated<Mood>>>(TargetAPI::Player, "/moods", parameters)?
.remove("Moods")
.ok_or(Error::NotFound("all moods"))
}
/// Get mood by name uri, which is a slight variation on the name depending on the characters involved.
///
/// Example
/// ```rust
/// use bombay::client::Client;
///
/// let mc = Client::default(); // Without authentication.
/// let chill_res = mc.mood().get_by_name_uri("chill");
///
/// if let Ok(chill) = chill_res {
/// println!("Found mood {}.", chill.name);
/// }
/// ```
///
/// Example URL: <https://player.monstercat.app/api/mood/chill>
pub fn get_by_name_uri(&self, mood_name_uri: impl AsRef<str> + Display) -> Result<Mood, Error> {
self.client
.get::<Wrapped<Mood>>(
TargetAPI::Player,
&format!("/mood/{mood_name_uri}"),
None::<HashMap<String, String>>,
)?
.remove("Mood")
.ok_or(Error::NotFound("mood"))
}
}