neptunium_http/endpoints/guild/
list_current_user_guilds.rs1use std::collections::HashMap;
2
3use bon::Builder;
4use neptunium_model::{
5 guild::Guild,
6 id::{Id, marker::GuildMarker},
7};
8use reqwest::Method;
9
10use crate::{endpoints::Endpoint, request::Request};
11
12#[derive(Builder, Copy, Clone, Debug)]
15pub struct ListCurrentUserGuildsParams {
16 pub before: Option<Id<GuildMarker>>,
17 pub after: Option<Id<GuildMarker>>,
18 pub limit: Option<u64>,
20 pub with_counts: Option<bool>,
22}
23
24#[derive(Builder, Copy, Clone, Debug)]
25pub struct ListCurrentUserGuilds {
26 pub params: ListCurrentUserGuildsParams,
27}
28
29impl Endpoint for ListCurrentUserGuilds {
30 type Response = Vec<Guild>;
31
32 fn into_request(self) -> crate::request::Request {
33 let mut params = HashMap::new();
34
35 if let Some(before) = self.params.before {
36 params.insert("before".to_owned(), before.to_string());
37 }
38 if let Some(after) = self.params.after {
39 params.insert("after".to_owned(), after.to_string());
40 }
41 if let Some(limit) = self.params.limit {
42 params.insert("limit".to_owned(), limit.to_string());
43 }
44 if let Some(with_counts) = self.params.with_counts {
45 params.insert("with_counts".to_owned(), with_counts.to_string());
46 }
47
48 Request::builder()
49 .method(Method::GET)
50 .params(params)
51 .path("/users/@me/guilds".to_owned())
52 .build()
53 }
54}