ic_query/sns/report/model/requests/
proposals.rs1use super::lookup::SnsLookupRequest;
8use crate::sns::report::{
9 SnsProposalEligibilityFilter, SnsProposalSortDirection, SnsProposalStatusFilter,
10 SnsProposalTopicFilter, SnsProposalsSort,
11};
12use std::path::PathBuf;
13
14#[derive(Clone, Debug, Eq, PartialEq)]
21pub struct SnsProposalRequest {
22 pub lookup: SnsLookupRequest,
24 pub proposal_id: u64,
25 pub cache_root: Option<PathBuf>,
26 pub verbose: bool,
27 pub show_ballots: bool,
28}
29
30impl SnsProposalRequest {
31 #[must_use]
32 pub const fn new(lookup: SnsLookupRequest, proposal_id: u64) -> Self {
33 Self {
34 lookup,
35 proposal_id,
36 cache_root: None,
37 verbose: false,
38 show_ballots: false,
39 }
40 }
41
42 #[must_use]
43 pub fn with_cache_root(mut self, cache_root: impl Into<PathBuf>) -> Self {
44 self.cache_root = Some(cache_root.into());
45 self
46 }
47
48 #[must_use]
49 pub const fn with_verbose(mut self, verbose: bool) -> Self {
50 self.verbose = verbose;
51 self
52 }
53
54 #[must_use]
55 pub const fn with_show_ballots(mut self, show_ballots: bool) -> Self {
56 self.show_ballots = show_ballots;
57 self
58 }
59}
60
61#[derive(Clone, Debug, Eq, PartialEq)]
68pub struct SnsProposalsRequest {
69 pub lookup: SnsLookupRequest,
71 pub limit: u32,
72 pub before_proposal_id: Option<u64>,
73 pub status: SnsProposalStatusFilter,
74 pub topic: SnsProposalTopicFilter,
75 pub eligibility: SnsProposalEligibilityFilter,
76 pub proposer_neuron_id: Option<String>,
77 pub query: Option<String>,
78 pub sort: SnsProposalsSort,
79 pub sort_direction: SnsProposalSortDirection,
80 pub cache_root: Option<PathBuf>,
81 pub verbose: bool,
82}
83
84impl SnsProposalsRequest {
85 #[must_use]
86 pub fn new(lookup: SnsLookupRequest, limit: u32) -> Self {
87 Self {
88 lookup,
89 limit,
90 before_proposal_id: None,
91 status: SnsProposalStatusFilter::default(),
92 topic: SnsProposalTopicFilter::default(),
93 eligibility: SnsProposalEligibilityFilter::default(),
94 proposer_neuron_id: None,
95 query: None,
96 sort: SnsProposalsSort::default(),
97 sort_direction: SnsProposalSortDirection::default(),
98 cache_root: None,
99 verbose: false,
100 }
101 }
102
103 #[must_use]
104 pub const fn with_before_proposal_id(mut self, before_proposal_id: u64) -> Self {
105 self.before_proposal_id = Some(before_proposal_id);
106 self
107 }
108
109 #[must_use]
110 pub const fn with_status(mut self, status: SnsProposalStatusFilter) -> Self {
111 self.status = status;
112 self
113 }
114
115 #[must_use]
116 pub const fn with_topic(mut self, topic: SnsProposalTopicFilter) -> Self {
117 self.topic = topic;
118 self
119 }
120
121 #[must_use]
122 pub const fn with_eligibility(mut self, eligibility: SnsProposalEligibilityFilter) -> Self {
123 self.eligibility = eligibility;
124 self
125 }
126
127 #[must_use]
128 pub fn with_proposer_neuron_id(mut self, proposer_neuron_id: impl Into<String>) -> Self {
129 self.proposer_neuron_id = Some(proposer_neuron_id.into());
130 self
131 }
132
133 #[must_use]
134 pub fn with_query(mut self, query: impl Into<String>) -> Self {
135 self.query = Some(query.into());
136 self
137 }
138
139 #[must_use]
140 pub const fn with_sort(mut self, sort: SnsProposalsSort) -> Self {
141 self.sort = sort;
142 self.sort_direction = sort.default_direction();
143 self
144 }
145
146 #[must_use]
147 pub const fn with_sort_direction(mut self, sort_direction: SnsProposalSortDirection) -> Self {
148 self.sort_direction = sort_direction;
149 self
150 }
151
152 #[must_use]
153 pub fn with_cache_root(mut self, cache_root: impl Into<PathBuf>) -> Self {
154 self.cache_root = Some(cache_root.into());
155 self
156 }
157
158 #[must_use]
159 pub const fn with_verbose(mut self, verbose: bool) -> Self {
160 self.verbose = verbose;
161 self
162 }
163}