polyte_gamma/api/
comments.rs1use polyte_core::{QueryBuilder, Request};
2use reqwest::Client;
3use url::Url;
4
5use crate::{error::GammaError, types::Comment};
6
7#[derive(Clone)]
9pub struct Comments {
10 pub(crate) client: Client,
11 pub(crate) base_url: Url,
12}
13
14impl Comments {
15 pub fn list(&self) -> ListComments {
17 ListComments {
18 request: Request::new(self.client.clone(), self.base_url.clone(), "/comments"),
19 }
20 }
21}
22
23pub struct ListComments {
25 request: Request<Vec<Comment>, GammaError>,
26}
27
28impl ListComments {
29 pub fn limit(mut self, limit: u32) -> Self {
31 self.request = self.request.query("limit", limit);
32 self
33 }
34
35 pub fn offset(mut self, offset: u32) -> Self {
37 self.request = self.request.query("offset", offset);
38 self
39 }
40
41 pub fn order(mut self, order: impl Into<String>) -> Self {
43 self.request = self.request.query("order", order.into());
44 self
45 }
46
47 pub fn ascending(mut self, ascending: bool) -> Self {
49 self.request = self.request.query("ascending", ascending);
50 self
51 }
52
53 pub fn parent_entity_type(mut self, entity_type: impl Into<String>) -> Self {
55 self.request = self.request.query("parent_entity_type", entity_type.into());
56 self
57 }
58
59 pub fn parent_entity_id(mut self, id: i64) -> Self {
61 self.request = self.request.query("parent_entity_id", id);
62 self
63 }
64
65 pub fn get_positions(mut self, include: bool) -> Self {
67 self.request = self.request.query("get_positions", include);
68 self
69 }
70
71 pub fn holders_only(mut self, holders_only: bool) -> Self {
73 self.request = self.request.query("holders_only", holders_only);
74 self
75 }
76
77 pub async fn send(self) -> crate::error::Result<Vec<Comment>> {
79 self.request.send().await
80 }
81}