Skip to main content

polyoxide_data/api/
misc.rs

1use polyoxide_core::{HttpClient, QueryBuilder, Request};
2
3use crate::{
4    error::DataApiError,
5    types::{OtherSize, RevisionPayload},
6};
7
8/// Misc namespace for endpoints that don't belong to a larger group.
9#[derive(Clone)]
10pub struct MiscApi {
11    pub(crate) http_client: HttpClient,
12}
13
14impl MiscApi {
15    /// Get the "Other" size for an augmented neg-risk event and user
16    /// (`GET /other`).
17    ///
18    /// `event_id` is the Gamma event ID of the augmented neg-risk event.
19    pub fn other_size(
20        &self,
21        event_id: u64,
22        user_address: impl Into<String>,
23    ) -> Request<Vec<OtherSize>, DataApiError> {
24        Request::new(self.http_client.clone(), "/other")
25            .query("id", event_id)
26            .query("user", user_address.into())
27    }
28
29    /// Get moderated revisions for a question (`GET /revisions`).
30    ///
31    /// `question_id` is a 32-byte hash (`0x` + 64 hex).
32    pub fn revisions(&self, question_id: impl Into<String>) -> ListRevisions {
33        ListRevisions {
34            request: Request::new(self.http_client.clone(), "/revisions")
35                .query("questionID", question_id.into()),
36        }
37    }
38}
39
40/// Request builder for listing moderated question revisions.
41pub struct ListRevisions {
42    request: Request<Vec<RevisionPayload>, DataApiError>,
43}
44
45impl ListRevisions {
46    /// Set maximum number of revisions returned (0-500, default: 100).
47    pub fn limit(mut self, limit: u32) -> Self {
48        self.request = self.request.query("limit", limit);
49        self
50    }
51
52    /// Execute the request.
53    pub async fn send(self) -> Result<Vec<RevisionPayload>, DataApiError> {
54        self.request.send().await
55    }
56}