ic_query/sns/report/model/requests/
proposals.rs1use crate::sns::report::{
8 SnsProposalEligibilityFilter, SnsProposalSortDirection, SnsProposalStatusFilter,
9 SnsProposalTopicFilter, SnsProposalsSort,
10};
11#[cfg(feature = "host")]
12use std::path::Path;
13use std::path::PathBuf;
14
15#[cfg(feature = "host")]
22#[derive(Clone, Debug, Eq, PartialEq)]
23pub struct SnsProposalsCacheListRequest {
24 pub network: String,
25 pub icp_root: PathBuf,
26}
27
28#[cfg(feature = "host")]
29impl SnsProposalsCacheListRequest {
30 #[must_use]
31 pub fn new(icp_root: impl Into<PathBuf>, network: impl Into<String>) -> Self {
32 Self {
33 network: network.into(),
34 icp_root: icp_root.into(),
35 }
36 }
37
38 #[must_use]
39 pub fn icp_root(&self) -> &Path {
40 &self.icp_root
41 }
42}
43
44#[cfg(feature = "host")]
51#[derive(Clone, Debug, Eq, PartialEq)]
52pub struct SnsProposalsCacheStatusRequest {
53 pub network: String,
54 pub icp_root: PathBuf,
55 pub input: String,
56}
57
58#[cfg(feature = "host")]
59impl SnsProposalsCacheStatusRequest {
60 #[must_use]
61 pub fn new(
62 icp_root: impl Into<PathBuf>,
63 network: impl Into<String>,
64 input: impl Into<String>,
65 ) -> Self {
66 Self {
67 network: network.into(),
68 icp_root: icp_root.into(),
69 input: input.into(),
70 }
71 }
72
73 #[must_use]
74 pub fn icp_root(&self) -> &Path {
75 &self.icp_root
76 }
77}
78
79#[derive(Clone, Debug, Eq, PartialEq)]
86pub struct SnsProposalRequest {
87 pub network: String,
88 pub source_endpoint: String,
89 pub now_unix_secs: u64,
90 pub input: String,
91 pub proposal_id: u64,
92 pub icp_root: Option<PathBuf>,
93 pub verbose: bool,
94 pub show_ballots: bool,
95}
96
97impl SnsProposalRequest {
98 #[must_use]
99 pub fn new(
100 network: impl Into<String>,
101 source_endpoint: impl Into<String>,
102 now_unix_secs: u64,
103 input: impl Into<String>,
104 proposal_id: u64,
105 ) -> Self {
106 Self {
107 network: network.into(),
108 source_endpoint: source_endpoint.into(),
109 now_unix_secs,
110 input: input.into(),
111 proposal_id,
112 icp_root: None,
113 verbose: false,
114 show_ballots: false,
115 }
116 }
117
118 #[must_use]
119 pub fn with_icp_root(mut self, icp_root: impl Into<PathBuf>) -> Self {
120 self.icp_root = Some(icp_root.into());
121 self
122 }
123
124 #[must_use]
125 pub const fn with_verbose(mut self, verbose: bool) -> Self {
126 self.verbose = verbose;
127 self
128 }
129
130 #[must_use]
131 pub const fn with_show_ballots(mut self, show_ballots: bool) -> Self {
132 self.show_ballots = show_ballots;
133 self
134 }
135}
136
137#[derive(Clone, Debug, Eq, PartialEq)]
144pub struct SnsProposalsRequest {
145 pub network: String,
146 pub source_endpoint: String,
147 pub now_unix_secs: u64,
148 pub input: String,
149 pub limit: u32,
150 pub before_proposal_id: Option<u64>,
151 pub status: SnsProposalStatusFilter,
152 pub topic: SnsProposalTopicFilter,
153 pub eligibility: SnsProposalEligibilityFilter,
154 pub proposer_neuron_id: Option<String>,
155 pub query: Option<String>,
156 pub sort: SnsProposalsSort,
157 pub sort_direction: SnsProposalSortDirection,
158 pub icp_root: Option<PathBuf>,
159 pub verbose: bool,
160}
161
162impl SnsProposalsRequest {
163 #[must_use]
164 pub fn new(
165 network: impl Into<String>,
166 source_endpoint: impl Into<String>,
167 now_unix_secs: u64,
168 input: impl Into<String>,
169 limit: u32,
170 ) -> Self {
171 Self {
172 network: network.into(),
173 source_endpoint: source_endpoint.into(),
174 now_unix_secs,
175 input: input.into(),
176 limit,
177 before_proposal_id: None,
178 status: SnsProposalStatusFilter::default(),
179 topic: SnsProposalTopicFilter::default(),
180 eligibility: SnsProposalEligibilityFilter::default(),
181 proposer_neuron_id: None,
182 query: None,
183 sort: SnsProposalsSort::default(),
184 sort_direction: SnsProposalSortDirection::default(),
185 icp_root: None,
186 verbose: false,
187 }
188 }
189
190 #[must_use]
191 pub const fn with_before_proposal_id(mut self, before_proposal_id: u64) -> Self {
192 self.before_proposal_id = Some(before_proposal_id);
193 self
194 }
195
196 #[must_use]
197 pub const fn with_status(mut self, status: SnsProposalStatusFilter) -> Self {
198 self.status = status;
199 self
200 }
201
202 #[must_use]
203 pub const fn with_topic(mut self, topic: SnsProposalTopicFilter) -> Self {
204 self.topic = topic;
205 self
206 }
207
208 #[must_use]
209 pub const fn with_eligibility(mut self, eligibility: SnsProposalEligibilityFilter) -> Self {
210 self.eligibility = eligibility;
211 self
212 }
213
214 #[must_use]
215 pub fn with_proposer_neuron_id(mut self, proposer_neuron_id: impl Into<String>) -> Self {
216 self.proposer_neuron_id = Some(proposer_neuron_id.into());
217 self
218 }
219
220 #[must_use]
221 pub fn with_query(mut self, query: impl Into<String>) -> Self {
222 self.query = Some(query.into());
223 self
224 }
225
226 #[must_use]
227 pub const fn with_sort(mut self, sort: SnsProposalsSort) -> Self {
228 self.sort = sort;
229 self.sort_direction = sort.default_direction();
230 self
231 }
232
233 #[must_use]
234 pub const fn with_sort_direction(mut self, sort_direction: SnsProposalSortDirection) -> Self {
235 self.sort_direction = sort_direction;
236 self
237 }
238
239 #[must_use]
240 pub fn with_icp_root(mut self, icp_root: impl Into<PathBuf>) -> Self {
241 self.icp_root = Some(icp_root.into());
242 self
243 }
244
245 #[must_use]
246 pub const fn with_verbose(mut self, verbose: bool) -> Self {
247 self.verbose = verbose;
248 self
249 }
250}
251
252#[cfg(feature = "host")]
259#[derive(Clone, Debug, Eq, PartialEq)]
260pub struct SnsProposalsRefreshRequest {
261 pub network: String,
262 pub source_endpoint: String,
263 pub now_unix_secs: u64,
264 pub input: String,
265 pub icp_root: PathBuf,
266 pub page_size: u32,
267 pub max_pages: Option<u32>,
268}
269
270#[cfg(feature = "host")]
271impl SnsProposalsRefreshRequest {
272 #[must_use]
273 pub fn new(
274 icp_root: impl Into<PathBuf>,
275 network: impl Into<String>,
276 source_endpoint: impl Into<String>,
277 now_unix_secs: u64,
278 input: impl Into<String>,
279 page_size: u32,
280 ) -> Self {
281 Self {
282 network: network.into(),
283 source_endpoint: source_endpoint.into(),
284 now_unix_secs,
285 input: input.into(),
286 icp_root: icp_root.into(),
287 page_size,
288 max_pages: None,
289 }
290 }
291
292 #[must_use]
293 pub const fn with_max_pages(mut self, max_pages: Option<u32>) -> Self {
294 self.max_pages = max_pages;
295 self
296 }
297}