spacetraders_client/endpoints/fleet/
mining.rs1use crate::client::StClient;
2use crate::client::{ClientError, RequestPriority};
3use crate::types;
4
5impl StClient {
6 pub async fn extract_resources(
7 &self,
8 ship_symbol: &str,
9 ) -> Result<types::ExtractResourcesResponse, ClientError> {
10 self.extract_resources_with_priority(ship_symbol, RequestPriority::Normal)
11 .await
12 }
13
14 pub async fn extract_resources_with_priority(
15 &self,
16 ship_symbol: &str,
17 priority: RequestPriority,
18 ) -> Result<types::ExtractResourcesResponse, ClientError> {
19 self.send_mutating("extract_resources", priority, || {
20 self.inner.extract_resources(ship_symbol)
21 })
22 .await
23 }
24
25 pub async fn siphon_resources(
26 &self,
27 ship_symbol: &str,
28 ) -> Result<types::SiphonResourcesResponse, ClientError> {
29 self.siphon_resources_with_priority(ship_symbol, RequestPriority::Normal)
30 .await
31 }
32
33 pub async fn siphon_resources_with_priority(
34 &self,
35 ship_symbol: &str,
36 priority: RequestPriority,
37 ) -> Result<types::SiphonResourcesResponse, ClientError> {
38 self.send_mutating("siphon_resources", priority, || {
39 self.inner.siphon_resources(ship_symbol)
40 })
41 .await
42 }
43
44 pub async fn extract_resources_with_survey(
45 &self,
46 ship_symbol: &str,
47 survey: &types::Survey,
48 ) -> Result<types::ExtractResourcesWithSurveyResponse, ClientError> {
49 self.extract_resources_with_survey_with_priority(
50 ship_symbol,
51 survey,
52 RequestPriority::Normal,
53 )
54 .await
55 }
56
57 pub async fn extract_resources_with_survey_with_priority(
58 &self,
59 ship_symbol: &str,
60 survey: &types::Survey,
61 priority: RequestPriority,
62 ) -> Result<types::ExtractResourcesWithSurveyResponse, ClientError> {
63 self.send_mutating("extract_resources_with_survey", priority, || {
64 self.inner
65 .extract_resources_with_survey(ship_symbol, survey)
66 })
67 .await
68 }
69
70 pub async fn create_survey(
71 &self,
72 ship_symbol: &str,
73 ) -> Result<types::CreateSurveyResponse, ClientError> {
74 self.create_survey_with_priority(ship_symbol, RequestPriority::Normal)
75 .await
76 }
77
78 pub async fn create_survey_with_priority(
79 &self,
80 ship_symbol: &str,
81 priority: RequestPriority,
82 ) -> Result<types::CreateSurveyResponse, ClientError> {
83 self.send_mutating("create_survey", priority, || {
84 self.inner.create_survey(ship_symbol)
85 })
86 .await
87 }
88
89 pub async fn create_chart(
90 &self,
91 ship_symbol: &str,
92 ) -> Result<types::CreateChartResponse, ClientError> {
93 self.create_chart_with_priority(ship_symbol, RequestPriority::Normal)
94 .await
95 }
96
97 pub async fn create_chart_with_priority(
98 &self,
99 ship_symbol: &str,
100 priority: RequestPriority,
101 ) -> Result<types::CreateChartResponse, ClientError> {
102 self.send_mutating("create_chart", priority, || {
103 self.inner.create_chart(ship_symbol)
104 })
105 .await
106 }
107
108 pub async fn ship_refine(
109 &self,
110 ship_symbol: &str,
111 produce: &str,
112 ) -> Result<types::ShipRefine201Response, ClientError> {
113 self.ship_refine_with_priority(ship_symbol, produce, RequestPriority::Normal)
114 .await
115 }
116
117 pub async fn ship_refine_with_priority(
118 &self,
119 ship_symbol: &str,
120 produce: &str,
121 priority: RequestPriority,
122 ) -> Result<types::ShipRefine201Response, ClientError> {
123 let body = types::ShipRefineBody {
124 produce: produce
125 .parse()
126 .map_err(|e| ClientError::Api(format!("invalid produce type: {e:?}")))?,
127 };
128 self.send_mutating("ship_refine", priority, || {
129 self.inner.ship_refine(ship_symbol, &body)
130 })
131 .await
132 }
133}