1mod cargo;
2mod fitting;
3mod mining;
4
5use std::num::NonZeroU64;
6
7use crate::client::StClient;
8use crate::client::{ClientError, RequestPriority};
9use crate::types;
10
11impl StClient {
12 pub async fn get_my_ships(
13 &self,
14 limit: Option<NonZeroU64>,
15 page: Option<NonZeroU64>,
16 ) -> Result<types::GetMyShipsResponse, ClientError> {
17 self.get_my_ships_with_priority(limit, page, RequestPriority::Normal)
18 .await
19 }
20
21 pub async fn get_my_ships_with_priority(
22 &self,
23 limit: Option<NonZeroU64>,
24 page: Option<NonZeroU64>,
25 priority: RequestPriority,
26 ) -> Result<types::GetMyShipsResponse, ClientError> {
27 self.send("get_my_ships", priority, || {
28 self.inner.get_my_ships(limit, page)
29 })
30 .await
31 }
32
33 pub async fn purchase_ship(
34 &self,
35 ship_type: types::ShipType,
36 waypoint_symbol: &str,
37 ) -> Result<types::PurchaseShipResponse, ClientError> {
38 self.purchase_ship_with_priority(ship_type, waypoint_symbol, RequestPriority::Normal)
39 .await
40 }
41
42 pub async fn purchase_ship_with_priority(
43 &self,
44 ship_type: types::ShipType,
45 waypoint_symbol: &str,
46 priority: RequestPriority,
47 ) -> Result<types::PurchaseShipResponse, ClientError> {
48 let body = types::PurchaseShipBody {
49 ship_type,
50 waypoint_symbol: waypoint_symbol.to_string(),
51 };
52 self.send_mutating("purchase_ship", priority, || {
53 self.inner.purchase_ship(&body)
54 })
55 .await
56 }
57
58 pub async fn get_my_ship(
59 &self,
60 ship_symbol: &str,
61 ) -> Result<types::GetMyShipResponse, ClientError> {
62 self.get_my_ship_with_priority(ship_symbol, RequestPriority::Normal)
63 .await
64 }
65
66 pub async fn get_my_ship_with_priority(
67 &self,
68 ship_symbol: &str,
69 priority: RequestPriority,
70 ) -> Result<types::GetMyShipResponse, ClientError> {
71 self.send("get_my_ship", priority, || {
72 self.inner.get_my_ship(ship_symbol)
73 })
74 .await
75 }
76
77 pub async fn get_my_ship_cargo(
78 &self,
79 ship_symbol: &str,
80 ) -> Result<types::GetMyShipCargoResponse, ClientError> {
81 self.get_my_ship_cargo_with_priority(ship_symbol, RequestPriority::Normal)
82 .await
83 }
84
85 pub async fn get_my_ship_cargo_with_priority(
86 &self,
87 ship_symbol: &str,
88 priority: RequestPriority,
89 ) -> Result<types::GetMyShipCargoResponse, ClientError> {
90 self.send("get_my_ship_cargo", priority, || {
91 self.inner.get_my_ship_cargo(ship_symbol)
92 })
93 .await
94 }
95
96 pub async fn orbit_ship(
97 &self,
98 ship_symbol: &str,
99 ) -> Result<types::OrbitShip200Response, ClientError> {
100 self.orbit_ship_with_priority(ship_symbol, RequestPriority::Normal)
101 .await
102 }
103
104 pub async fn orbit_ship_with_priority(
105 &self,
106 ship_symbol: &str,
107 priority: RequestPriority,
108 ) -> Result<types::OrbitShip200Response, ClientError> {
109 self.send_mutating("orbit_ship", priority, || {
110 self.inner.orbit_ship(ship_symbol)
111 })
112 .await
113 }
114
115 pub async fn dock_ship(
116 &self,
117 ship_symbol: &str,
118 ) -> Result<types::DockShip200Response, ClientError> {
119 self.dock_ship_with_priority(ship_symbol, RequestPriority::Normal)
120 .await
121 }
122
123 pub async fn dock_ship_with_priority(
124 &self,
125 ship_symbol: &str,
126 priority: RequestPriority,
127 ) -> Result<types::DockShip200Response, ClientError> {
128 self.send_mutating("dock_ship", priority, || self.inner.dock_ship(ship_symbol))
129 .await
130 }
131
132 pub async fn navigate_ship(
133 &self,
134 ship_symbol: &str,
135 waypoint_symbol: &str,
136 ) -> Result<types::NavigateShipResponse, ClientError> {
137 self.navigate_ship_with_priority(ship_symbol, waypoint_symbol, RequestPriority::Normal)
138 .await
139 }
140
141 pub async fn navigate_ship_with_priority(
142 &self,
143 ship_symbol: &str,
144 waypoint_symbol: &str,
145 priority: RequestPriority,
146 ) -> Result<types::NavigateShipResponse, ClientError> {
147 let body = types::NavigateShipBody {
148 waypoint_symbol: waypoint_symbol
149 .parse()
150 .map_err(|e| ClientError::Api(format!("invalid waypoint symbol: {e:?}")))?,
151 };
152 self.send_mutating("navigate_ship", priority, || {
153 self.inner.navigate_ship(ship_symbol, &body)
154 })
155 .await
156 }
157
158 pub async fn refuel_ship(
159 &self,
160 ship_symbol: &str,
161 units: Option<NonZeroU64>,
162 from_cargo: bool,
163 ) -> Result<types::RefuelShipResponse, ClientError> {
164 self.refuel_ship_with_priority(ship_symbol, units, from_cargo, RequestPriority::Normal)
165 .await
166 }
167
168 pub async fn refuel_ship_with_priority(
169 &self,
170 ship_symbol: &str,
171 units: Option<NonZeroU64>,
172 from_cargo: bool,
173 priority: RequestPriority,
174 ) -> Result<types::RefuelShipResponse, ClientError> {
175 let body = types::RefuelShipBody { units, from_cargo };
176 self.send_mutating("refuel_ship", priority, || {
177 self.inner.refuel_ship(ship_symbol, &body)
178 })
179 .await
180 }
181
182 pub async fn get_ship_cooldown(
183 &self,
184 ship_symbol: &str,
185 ) -> Result<types::GetShipCooldownResponse, ClientError> {
186 self.get_ship_cooldown_with_priority(ship_symbol, RequestPriority::Normal)
187 .await
188 }
189
190 pub async fn get_ship_cooldown_with_priority(
191 &self,
192 ship_symbol: &str,
193 priority: RequestPriority,
194 ) -> Result<types::GetShipCooldownResponse, ClientError> {
195 self.send("get_ship_cooldown", priority, || {
196 self.inner.get_ship_cooldown(ship_symbol)
197 })
198 .await
199 }
200
201 pub async fn get_ship_nav(
202 &self,
203 ship_symbol: &str,
204 ) -> Result<types::GetShipNavResponse, ClientError> {
205 self.get_ship_nav_with_priority(ship_symbol, RequestPriority::Normal)
206 .await
207 }
208
209 pub async fn get_ship_nav_with_priority(
210 &self,
211 ship_symbol: &str,
212 priority: RequestPriority,
213 ) -> Result<types::GetShipNavResponse, ClientError> {
214 self.send("get_ship_nav", priority, || {
215 self.inner.get_ship_nav(ship_symbol)
216 })
217 .await
218 }
219
220 pub async fn patch_ship_nav(
221 &self,
222 ship_symbol: &str,
223 flight_mode: Option<types::ShipNavFlightMode>,
224 ) -> Result<types::PatchShipNavResponse, ClientError> {
225 self.patch_ship_nav_with_priority(ship_symbol, flight_mode, RequestPriority::Normal)
226 .await
227 }
228
229 pub async fn patch_ship_nav_with_priority(
230 &self,
231 ship_symbol: &str,
232 flight_mode: Option<types::ShipNavFlightMode>,
233 priority: RequestPriority,
234 ) -> Result<types::PatchShipNavResponse, ClientError> {
235 let body = types::PatchShipNavBody { flight_mode };
236 self.send_mutating("patch_ship_nav", priority, || {
237 self.inner.patch_ship_nav(ship_symbol, &body)
238 })
239 .await
240 }
241
242 pub async fn jump_ship(
243 &self,
244 ship_symbol: &str,
245 waypoint_symbol: &str,
246 ) -> Result<types::JumpShipResponse, ClientError> {
247 self.jump_ship_with_priority(ship_symbol, waypoint_symbol, RequestPriority::Normal)
248 .await
249 }
250
251 pub async fn jump_ship_with_priority(
252 &self,
253 ship_symbol: &str,
254 waypoint_symbol: &str,
255 priority: RequestPriority,
256 ) -> Result<types::JumpShipResponse, ClientError> {
257 let body = types::JumpShipBody {
258 waypoint_symbol: waypoint_symbol.to_string(),
259 };
260 self.send_mutating("jump_ship", priority, || {
261 self.inner.jump_ship(ship_symbol, &body)
262 })
263 .await
264 }
265
266 pub async fn warp_ship(
267 &self,
268 ship_symbol: &str,
269 waypoint_symbol: &str,
270 ) -> Result<types::WarpShipResponse, ClientError> {
271 self.warp_ship_with_priority(ship_symbol, waypoint_symbol, RequestPriority::Normal)
272 .await
273 }
274
275 pub async fn warp_ship_with_priority(
276 &self,
277 ship_symbol: &str,
278 waypoint_symbol: &str,
279 priority: RequestPriority,
280 ) -> Result<types::WarpShipResponse, ClientError> {
281 let body = types::WarpShipBody {
282 waypoint_symbol: waypoint_symbol
283 .parse()
284 .map_err(|e| ClientError::Api(format!("invalid waypoint symbol: {e:?}")))?,
285 };
286 self.send_mutating("warp_ship", priority, || {
287 self.inner.warp_ship(ship_symbol, &body)
288 })
289 .await
290 }
291}