spacetraders_client/endpoints/fleet/
fitting.rs1use crate::client::StClient;
2use crate::client::{ClientError, RequestPriority};
3use crate::types;
4
5impl StClient {
6 pub async fn get_mounts(
7 &self,
8 ship_symbol: &str,
9 ) -> Result<types::GetMounts200Response, ClientError> {
10 self.get_mounts_with_priority(ship_symbol, RequestPriority::Normal)
11 .await
12 }
13
14 pub async fn get_mounts_with_priority(
15 &self,
16 ship_symbol: &str,
17 priority: RequestPriority,
18 ) -> Result<types::GetMounts200Response, ClientError> {
19 self.send("get_mounts", priority, || {
20 self.inner.get_mounts(ship_symbol)
21 })
22 .await
23 }
24
25 pub async fn install_mount(
26 &self,
27 ship_symbol: &str,
28 symbol: &str,
29 ) -> Result<types::InstallMount201Response, ClientError> {
30 self.install_mount_with_priority(ship_symbol, symbol, RequestPriority::Normal)
31 .await
32 }
33
34 pub async fn install_mount_with_priority(
35 &self,
36 ship_symbol: &str,
37 symbol: &str,
38 priority: RequestPriority,
39 ) -> Result<types::InstallMount201Response, ClientError> {
40 let body = types::InstallMountRequest {
41 symbol: symbol
42 .parse()
43 .map_err(|e| ClientError::Api(format!("invalid mount symbol: {e:?}")))?,
44 };
45 self.send_mutating("install_mount", priority, || {
46 self.inner.install_mount(ship_symbol, &body)
47 })
48 .await
49 }
50
51 pub async fn remove_mount(
52 &self,
53 ship_symbol: &str,
54 symbol: &str,
55 ) -> Result<types::RemoveMount201Response, ClientError> {
56 self.remove_mount_with_priority(ship_symbol, symbol, RequestPriority::Normal)
57 .await
58 }
59
60 pub async fn remove_mount_with_priority(
61 &self,
62 ship_symbol: &str,
63 symbol: &str,
64 priority: RequestPriority,
65 ) -> Result<types::RemoveMount201Response, ClientError> {
66 let body = types::RemoveMountRequest {
67 symbol: symbol
68 .parse()
69 .map_err(|e| ClientError::Api(format!("invalid mount symbol: {e:?}")))?,
70 };
71 self.send_mutating("remove_mount", priority, || {
72 self.inner.remove_mount(ship_symbol, &body)
73 })
74 .await
75 }
76
77 pub async fn get_repair_ship(
78 &self,
79 ship_symbol: &str,
80 ) -> Result<types::GetRepairShipResponse, ClientError> {
81 self.get_repair_ship_with_priority(ship_symbol, RequestPriority::Normal)
82 .await
83 }
84
85 pub async fn get_repair_ship_with_priority(
86 &self,
87 ship_symbol: &str,
88 priority: RequestPriority,
89 ) -> Result<types::GetRepairShipResponse, ClientError> {
90 self.send("get_repair_ship", priority, || {
91 self.inner.get_repair_ship(ship_symbol)
92 })
93 .await
94 }
95
96 pub async fn repair_ship(
97 &self,
98 ship_symbol: &str,
99 ) -> Result<types::RepairShipResponse, ClientError> {
100 self.repair_ship_with_priority(ship_symbol, RequestPriority::Normal)
101 .await
102 }
103
104 pub async fn repair_ship_with_priority(
105 &self,
106 ship_symbol: &str,
107 priority: RequestPriority,
108 ) -> Result<types::RepairShipResponse, ClientError> {
109 self.send_mutating("repair_ship", priority, || {
110 self.inner.repair_ship(ship_symbol)
111 })
112 .await
113 }
114
115 pub async fn get_scrap_ship(
116 &self,
117 ship_symbol: &str,
118 ) -> Result<types::GetScrapShipResponse, ClientError> {
119 self.get_scrap_ship_with_priority(ship_symbol, RequestPriority::Normal)
120 .await
121 }
122
123 pub async fn get_scrap_ship_with_priority(
124 &self,
125 ship_symbol: &str,
126 priority: RequestPriority,
127 ) -> Result<types::GetScrapShipResponse, ClientError> {
128 self.send("get_scrap_ship", priority, || {
129 self.inner.get_scrap_ship(ship_symbol)
130 })
131 .await
132 }
133
134 pub async fn scrap_ship(
135 &self,
136 ship_symbol: &str,
137 ) -> Result<types::ScrapShipResponse, ClientError> {
138 self.scrap_ship_with_priority(ship_symbol, RequestPriority::Normal)
139 .await
140 }
141
142 pub async fn scrap_ship_with_priority(
143 &self,
144 ship_symbol: &str,
145 priority: RequestPriority,
146 ) -> Result<types::ScrapShipResponse, ClientError> {
147 self.send_mutating("scrap_ship", priority, || {
148 self.inner.scrap_ship(ship_symbol)
149 })
150 .await
151 }
152
153 pub async fn get_ship_modules(
154 &self,
155 ship_symbol: &str,
156 ) -> Result<types::GetShipModulesResponse, ClientError> {
157 self.get_ship_modules_with_priority(ship_symbol, RequestPriority::Normal)
158 .await
159 }
160
161 pub async fn get_ship_modules_with_priority(
162 &self,
163 ship_symbol: &str,
164 priority: RequestPriority,
165 ) -> Result<types::GetShipModulesResponse, ClientError> {
166 self.send("get_ship_modules", priority, || {
167 self.inner.get_ship_modules(ship_symbol)
168 })
169 .await
170 }
171
172 pub async fn install_ship_module(
173 &self,
174 ship_symbol: &str,
175 symbol: &str,
176 ) -> Result<types::InstallShipModuleResponse, ClientError> {
177 self.install_ship_module_with_priority(ship_symbol, symbol, RequestPriority::Normal)
178 .await
179 }
180
181 pub async fn install_ship_module_with_priority(
182 &self,
183 ship_symbol: &str,
184 symbol: &str,
185 priority: RequestPriority,
186 ) -> Result<types::InstallShipModuleResponse, ClientError> {
187 let body = types::InstallShipModuleBody {
188 symbol: symbol
189 .parse()
190 .map_err(|e| ClientError::Api(format!("invalid module symbol: {e:?}")))?,
191 };
192 self.send_mutating("install_ship_module", priority, || {
193 self.inner.install_ship_module(ship_symbol, &body)
194 })
195 .await
196 }
197
198 pub async fn remove_ship_module(
199 &self,
200 ship_symbol: &str,
201 symbol: &str,
202 ) -> Result<types::RemoveShipModuleResponse, ClientError> {
203 self.remove_ship_module_with_priority(ship_symbol, symbol, RequestPriority::Normal)
204 .await
205 }
206
207 pub async fn remove_ship_module_with_priority(
208 &self,
209 ship_symbol: &str,
210 symbol: &str,
211 priority: RequestPriority,
212 ) -> Result<types::RemoveShipModuleResponse, ClientError> {
213 let body = types::RemoveShipModuleBody {
214 symbol: symbol
215 .parse()
216 .map_err(|e| ClientError::Api(format!("invalid module symbol: {e:?}")))?,
217 };
218 self.send_mutating("remove_ship_module", priority, || {
219 self.inner.remove_ship_module(ship_symbol, &body)
220 })
221 .await
222 }
223
224 pub async fn create_ship_ship_scan(
225 &self,
226 ship_symbol: &str,
227 ) -> Result<types::CreateShipShipScanResponse, ClientError> {
228 self.create_ship_ship_scan_with_priority(ship_symbol, RequestPriority::Normal)
229 .await
230 }
231
232 pub async fn create_ship_ship_scan_with_priority(
233 &self,
234 ship_symbol: &str,
235 priority: RequestPriority,
236 ) -> Result<types::CreateShipShipScanResponse, ClientError> {
237 self.send_mutating("create_ship_ship_scan", priority, || {
238 self.inner.create_ship_ship_scan(ship_symbol)
239 })
240 .await
241 }
242
243 pub async fn create_ship_system_scan(
244 &self,
245 ship_symbol: &str,
246 ) -> Result<types::CreateShipSystemScanResponse, ClientError> {
247 self.create_ship_system_scan_with_priority(ship_symbol, RequestPriority::Normal)
248 .await
249 }
250
251 pub async fn create_ship_system_scan_with_priority(
252 &self,
253 ship_symbol: &str,
254 priority: RequestPriority,
255 ) -> Result<types::CreateShipSystemScanResponse, ClientError> {
256 self.send_mutating("create_ship_system_scan", priority, || {
257 self.inner.create_ship_system_scan(ship_symbol)
258 })
259 .await
260 }
261
262 pub async fn create_ship_waypoint_scan(
263 &self,
264 ship_symbol: &str,
265 ) -> Result<types::CreateShipWaypointScanResponse, ClientError> {
266 self.create_ship_waypoint_scan_with_priority(ship_symbol, RequestPriority::Normal)
267 .await
268 }
269
270 pub async fn create_ship_waypoint_scan_with_priority(
271 &self,
272 ship_symbol: &str,
273 priority: RequestPriority,
274 ) -> Result<types::CreateShipWaypointScanResponse, ClientError> {
275 self.send_mutating("create_ship_waypoint_scan", priority, || {
276 self.inner.create_ship_waypoint_scan(ship_symbol)
277 })
278 .await
279 }
280}