ic_query/nns/proposals/report/model/
requests.rs1use super::selection::{
8 NnsProposalListSort, NnsProposalRewardStatusFilter, NnsProposalSortDirection,
9 NnsProposalStatusFilter, NnsProposalTopicFilter,
10};
11
12#[derive(Clone, Debug, Eq, PartialEq)]
19pub struct NnsProposalListRequest {
20 pub network: String,
21 pub source_endpoint: String,
22 pub now_unix_secs: u64,
23 pub limit: u32,
24 pub before_proposal_id: Option<u64>,
25 pub status: NnsProposalStatusFilter,
26 pub reward_status: NnsProposalRewardStatusFilter,
27 pub topic: NnsProposalTopicFilter,
28 pub proposer_neuron_id: Option<u64>,
29 pub query: Option<String>,
30 pub sort: NnsProposalListSort,
31 pub sort_direction: NnsProposalSortDirection,
32 pub verbose: bool,
33}
34
35impl NnsProposalListRequest {
36 #[must_use]
37 pub fn new(
38 network: impl Into<String>,
39 source_endpoint: impl Into<String>,
40 now_unix_secs: u64,
41 limit: u32,
42 ) -> Self {
43 Self {
44 network: network.into(),
45 source_endpoint: source_endpoint.into(),
46 now_unix_secs,
47 limit,
48 before_proposal_id: None,
49 status: NnsProposalStatusFilter::default(),
50 reward_status: NnsProposalRewardStatusFilter::default(),
51 topic: NnsProposalTopicFilter::default(),
52 proposer_neuron_id: None,
53 query: None,
54 sort: NnsProposalListSort::default(),
55 sort_direction: NnsProposalSortDirection::default(),
56 verbose: false,
57 }
58 }
59
60 #[must_use]
61 pub const fn with_before_proposal_id(mut self, before_proposal_id: u64) -> Self {
62 self.before_proposal_id = Some(before_proposal_id);
63 self
64 }
65
66 #[must_use]
67 pub const fn with_status(mut self, status: NnsProposalStatusFilter) -> Self {
68 self.status = status;
69 self
70 }
71
72 #[must_use]
73 pub const fn with_reward_status(
74 mut self,
75 reward_status: NnsProposalRewardStatusFilter,
76 ) -> Self {
77 self.reward_status = reward_status;
78 self
79 }
80
81 #[must_use]
82 pub const fn with_topic(mut self, topic: NnsProposalTopicFilter) -> Self {
83 self.topic = topic;
84 self
85 }
86
87 #[must_use]
88 pub const fn with_proposer_neuron_id(mut self, proposer_neuron_id: u64) -> Self {
89 self.proposer_neuron_id = Some(proposer_neuron_id);
90 self
91 }
92
93 #[must_use]
94 pub fn with_query(mut self, query: impl Into<String>) -> Self {
95 self.query = Some(query.into());
96 self
97 }
98
99 #[must_use]
100 pub const fn with_sort(mut self, sort: NnsProposalListSort) -> Self {
101 self.sort = sort;
102 self.sort_direction = sort.default_direction();
103 self
104 }
105
106 #[must_use]
107 pub const fn with_sort_direction(mut self, sort_direction: NnsProposalSortDirection) -> Self {
108 self.sort_direction = sort_direction;
109 self
110 }
111
112 #[must_use]
113 pub const fn with_verbose(mut self, verbose: bool) -> Self {
114 self.verbose = verbose;
115 self
116 }
117}
118
119#[derive(Clone, Debug, Eq, PartialEq)]
126pub struct NnsProposalRequest {
127 pub network: String,
128 pub source_endpoint: String,
129 pub now_unix_secs: u64,
130 pub proposal_id: u64,
131 pub show_ballots: bool,
132 pub verbose: bool,
133}
134
135impl NnsProposalRequest {
136 #[must_use]
137 pub fn new(
138 network: impl Into<String>,
139 source_endpoint: impl Into<String>,
140 now_unix_secs: u64,
141 proposal_id: u64,
142 ) -> Self {
143 Self {
144 network: network.into(),
145 source_endpoint: source_endpoint.into(),
146 now_unix_secs,
147 proposal_id,
148 show_ballots: false,
149 verbose: false,
150 }
151 }
152
153 #[must_use]
154 pub const fn with_show_ballots(mut self, show_ballots: bool) -> Self {
155 self.show_ballots = show_ballots;
156 self
157 }
158
159 #[must_use]
160 pub const fn with_verbose(mut self, verbose: bool) -> Self {
161 self.verbose = verbose;
162 self
163 }
164}