spacetraders_client/endpoints/systems/
mod.rs1mod data;
2mod global;
3
4use std::num::NonZeroU64;
5
6use crate::client::StClient;
7use crate::client::{ClientError, RequestPriority};
8use crate::types;
9
10impl StClient {
11 pub async fn get_systems(
12 &self,
13 limit: Option<NonZeroU64>,
14 page: Option<NonZeroU64>,
15 ) -> Result<types::GetSystemsResponse, ClientError> {
16 self.get_systems_with_priority(limit, page, RequestPriority::Normal)
17 .await
18 }
19
20 pub async fn get_systems_with_priority(
21 &self,
22 limit: Option<NonZeroU64>,
23 page: Option<NonZeroU64>,
24 priority: RequestPriority,
25 ) -> Result<types::GetSystemsResponse, ClientError> {
26 self.send("get_systems", priority, || {
27 self.inner.get_systems(limit, page)
28 })
29 .await
30 }
31
32 pub async fn get_system(
33 &self,
34 system_symbol: &str,
35 ) -> Result<types::GetSystemResponse, ClientError> {
36 self.get_system_with_priority(system_symbol, RequestPriority::Normal)
37 .await
38 }
39
40 pub async fn get_system_with_priority(
41 &self,
42 system_symbol: &str,
43 priority: RequestPriority,
44 ) -> Result<types::GetSystemResponse, ClientError> {
45 self.send("get_system", priority, || {
46 self.inner.get_system(system_symbol)
47 })
48 .await
49 }
50
51 pub async fn get_system_waypoints(
52 &self,
53 system_symbol: &str,
54 limit: Option<NonZeroU64>,
55 page: Option<NonZeroU64>,
56 traits: Option<&types::GetSystemWaypointsTraits>,
57 type_: Option<types::WaypointType>,
58 ) -> Result<types::GetSystemWaypointsResponse, ClientError> {
59 self.get_system_waypoints_with_priority(
60 system_symbol,
61 limit,
62 page,
63 traits,
64 type_,
65 RequestPriority::Normal,
66 )
67 .await
68 }
69
70 pub async fn get_system_waypoints_with_priority(
71 &self,
72 system_symbol: &str,
73 limit: Option<NonZeroU64>,
74 page: Option<NonZeroU64>,
75 traits: Option<&types::GetSystemWaypointsTraits>,
76 type_: Option<types::WaypointType>,
77 priority: RequestPriority,
78 ) -> Result<types::GetSystemWaypointsResponse, ClientError> {
79 self.send("get_system_waypoints", priority, || {
80 self.inner
81 .get_system_waypoints(system_symbol, limit, page, traits, type_)
82 })
83 .await
84 }
85
86 pub async fn get_waypoint(
87 &self,
88 system_symbol: &str,
89 waypoint_symbol: &str,
90 ) -> Result<types::GetWaypointResponse, ClientError> {
91 self.get_waypoint_with_priority(system_symbol, waypoint_symbol, RequestPriority::Normal)
92 .await
93 }
94
95 pub async fn get_waypoint_with_priority(
96 &self,
97 system_symbol: &str,
98 waypoint_symbol: &str,
99 priority: RequestPriority,
100 ) -> Result<types::GetWaypointResponse, ClientError> {
101 self.send("get_waypoint", priority, || {
102 self.inner.get_waypoint(system_symbol, waypoint_symbol)
103 })
104 .await
105 }
106
107 pub async fn get_market(
108 &self,
109 system_symbol: &str,
110 waypoint_symbol: &str,
111 ) -> Result<types::GetMarketResponse, ClientError> {
112 self.get_market_with_priority(system_symbol, waypoint_symbol, RequestPriority::Normal)
113 .await
114 }
115
116 pub async fn get_market_with_priority(
117 &self,
118 system_symbol: &str,
119 waypoint_symbol: &str,
120 priority: RequestPriority,
121 ) -> Result<types::GetMarketResponse, ClientError> {
122 self.send("get_market", priority, || {
123 self.inner.get_market(system_symbol, waypoint_symbol)
124 })
125 .await
126 }
127
128 pub async fn get_shipyard(
129 &self,
130 system_symbol: &str,
131 waypoint_symbol: &str,
132 ) -> Result<types::GetShipyardResponse, ClientError> {
133 self.get_shipyard_with_priority(system_symbol, waypoint_symbol, RequestPriority::Normal)
134 .await
135 }
136
137 pub async fn get_shipyard_with_priority(
138 &self,
139 system_symbol: &str,
140 waypoint_symbol: &str,
141 priority: RequestPriority,
142 ) -> Result<types::GetShipyardResponse, ClientError> {
143 self.send("get_shipyard", priority, || {
144 self.inner.get_shipyard(system_symbol, waypoint_symbol)
145 })
146 .await
147 }
148
149 pub async fn get_jump_gate(
150 &self,
151 system_symbol: &str,
152 waypoint_symbol: &str,
153 ) -> Result<types::GetJumpGateResponse, ClientError> {
154 self.get_jump_gate_with_priority(system_symbol, waypoint_symbol, RequestPriority::Normal)
155 .await
156 }
157
158 pub async fn get_jump_gate_with_priority(
159 &self,
160 system_symbol: &str,
161 waypoint_symbol: &str,
162 priority: RequestPriority,
163 ) -> Result<types::GetJumpGateResponse, ClientError> {
164 self.send("get_jump_gate", priority, || {
165 self.inner.get_jump_gate(system_symbol, waypoint_symbol)
166 })
167 .await
168 }
169
170 pub async fn get_construction(
171 &self,
172 system_symbol: &str,
173 waypoint_symbol: &str,
174 ) -> Result<types::GetConstructionResponse, ClientError> {
175 self.get_construction_with_priority(system_symbol, waypoint_symbol, RequestPriority::Normal)
176 .await
177 }
178
179 pub async fn get_construction_with_priority(
180 &self,
181 system_symbol: &str,
182 waypoint_symbol: &str,
183 priority: RequestPriority,
184 ) -> Result<types::GetConstructionResponse, ClientError> {
185 self.send("get_construction", priority, || {
186 self.inner.get_construction(system_symbol, waypoint_symbol)
187 })
188 .await
189 }
190
191 pub async fn supply_construction(
192 &self,
193 system_symbol: &str,
194 waypoint_symbol: &str,
195 ship_symbol: &str,
196 trade_symbol: types::TradeSymbol,
197 units: NonZeroU64,
198 ) -> Result<types::SupplyConstructionResponse, ClientError> {
199 self.supply_construction_with_priority(
200 system_symbol,
201 waypoint_symbol,
202 ship_symbol,
203 trade_symbol,
204 units,
205 RequestPriority::Normal,
206 )
207 .await
208 }
209
210 pub async fn supply_construction_with_priority(
211 &self,
212 system_symbol: &str,
213 waypoint_symbol: &str,
214 ship_symbol: &str,
215 trade_symbol: types::TradeSymbol,
216 units: NonZeroU64,
217 priority: RequestPriority,
218 ) -> Result<types::SupplyConstructionResponse, ClientError> {
219 let body = types::SupplyConstructionBody {
220 ship_symbol: ship_symbol.to_string(),
221 trade_symbol,
222 units,
223 };
224 self.send_mutating("supply_construction", priority, || {
225 self.inner
226 .supply_construction(system_symbol, waypoint_symbol, &body)
227 })
228 .await
229 }
230}