Skip to main content

esi_openapi/groups/
industry.rs

1#![allow(unused)]
2
3use crate::prelude::*;
4
5/// Endpoints for Industry
6pub struct IndustryGroup<'a> {
7    pub(crate) esi: &'a Esi,
8}
9
10#[derive(Debug, Deserialize, Serialize, Clone)]
11#[allow(missing_docs)]
12pub struct CostIndex {
13    pub activity: String,
14    pub cost_index: f64,
15}
16
17#[derive(Debug, Deserialize, Serialize, Clone)]
18#[allow(missing_docs)]
19pub struct IndustrialSystem {
20    pub cost_indices: Vec<CostIndex>,
21    pub solar_system_id: i64,
22}
23
24#[derive(Debug, Deserialize, Serialize, Clone)]
25#[allow(missing_docs)]
26pub struct IndustryJob {
27    pub activity_id: i64,
28    pub blueprint_id: i64,
29    pub blueprint_location_id: i64,
30    pub blueprint_type_id: i64,
31    pub completed_character_id: Option<i64>,
32    pub completed_date: Option<String>,
33    pub cost: Option<f64>,
34    pub duration: i64,
35    pub end_date: String,
36    pub facility_id: i64,
37    pub installer_id: i64,
38    pub job_id: i64,
39    pub licensed_runs: Option<i64>,
40    pub output_location_id: i64,
41    pub pause_date: Option<String>,
42    pub probability: Option<f64>,
43    pub product_type_id: Option<i64>,
44    pub runs: i64,
45    pub start_date: String,
46    pub station_id: i64,
47    pub status: String,
48    pub successful_runs: Option<i64>,
49}
50
51impl IndustryGroup<'_> {
52    api_get!(
53        /// Returns a list of solar systems with the cost index for every
54        /// activity
55        get_industry_systems,
56        "GetIndustrySystems",
57        RequestType::Public,
58        Vec<IndustrialSystem>,
59    );
60
61    api_get!(
62        /// List industry jobs placed by a character
63        get_character_industry_jobs,
64        "GetCharactersCharacterIdIndustryJobs",
65        RequestType::Authenticated,
66        Vec<IndustryJob>,
67        (character_id: i64) => "{character_id}";
68        Optional(include_completed: bool) => "include_completed"
69    );
70}
71
72/// A public industry facility.
73#[derive(Debug, Clone, PartialEq, Deserialize)]
74#[allow(missing_docs)]
75pub struct IndustryFacility {
76    pub facility_id: i64,
77    pub owner_id: i64,
78    pub region_id: i64,
79    pub solar_system_id: i64,
80    pub tax: Option<f64>,
81    pub type_id: i64,
82}
83
84impl IndustryGroup<'_> {
85    api_get!(
86        /// List the public industry facilities.
87        get_facilities,
88        "GetIndustryFacilities",
89        RequestType::Public,
90        Vec<IndustryFacility>,
91    );
92}
93
94/// A day of mining by a character.
95#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
96#[allow(missing_docs)]
97pub struct MiningEntry {
98    pub date: String,
99    pub quantity: i64,
100    pub solar_system_id: i64,
101    pub type_id: i64,
102}
103
104/// A moon mining extraction of a corporation.
105#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
106#[allow(missing_docs)]
107pub struct MiningExtraction {
108    pub chunk_arrival_time: String,
109    pub extraction_start_time: String,
110    pub moon_id: i64,
111    pub natural_decay_time: String,
112    pub structure_id: i64,
113}
114
115/// The kind of structure that observes mining.
116#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
117#[serde(rename_all = "snake_case")]
118pub enum ObserverType {
119    /// A structure.
120    Structure,
121    /// A kind this version of the crate does not know about.
122    #[serde(other)]
123    Unrecognized,
124}
125
126/// A structure that observed mining for a corporation.
127#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
128#[allow(missing_docs)]
129pub struct MiningObserver {
130    pub last_updated: String,
131    pub observer_id: i64,
132    pub observer_type: ObserverType,
133}
134
135/// Mining recorded by an observer for one character.
136#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
137#[allow(missing_docs)]
138pub struct ObservedMining {
139    pub character_id: i64,
140    pub last_updated: String,
141    pub quantity: i64,
142    pub recorded_corporation_id: i64,
143    pub type_id: i64,
144}
145
146/// Status of a corporation industry job.
147#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
148#[serde(rename_all = "snake_case")]
149pub enum IndustryJobStatus {
150    /// The job is running.
151    Active,
152    /// The job was cancelled.
153    Cancelled,
154    /// The job was delivered.
155    Delivered,
156    /// The job is paused.
157    Paused,
158    /// The job is ready to be delivered.
159    Ready,
160    /// The job was reverted.
161    Reverted,
162    /// A status this version of the crate does not know about.
163    #[serde(other)]
164    Unrecognized,
165}
166
167/// An industry job placed by a corporation.
168#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
169#[allow(missing_docs)]
170pub struct CorporationIndustryJob {
171    pub activity_id: i64,
172    pub blueprint_id: i64,
173    pub blueprint_location_id: i64,
174    pub blueprint_type_id: i64,
175    pub completed_character_id: Option<i64>,
176    pub completed_date: Option<String>,
177    pub cost: Option<f64>,
178    pub duration: i64,
179    pub end_date: String,
180    pub facility_id: i64,
181    pub installer_id: i64,
182    pub job_id: i64,
183    pub licensed_runs: Option<i64>,
184    pub location_id: i64,
185    pub output_location_id: i64,
186    pub pause_date: Option<String>,
187    pub probability: Option<f64>,
188    pub product_type_id: Option<i64>,
189    pub runs: i64,
190    pub start_date: String,
191    pub status: IndustryJobStatus,
192    pub successful_runs: Option<i64>,
193}
194
195impl IndustryGroup<'_> {
196    api_get!(
197        /// Paginated record of the mining done by a character in the last 30 days.
198        get_character_mining,
199        "GetCharactersCharacterIdMining",
200        RequestType::Authenticated,
201        Vec<MiningEntry>,
202        (character_id: i64) => "{character_id}";
203        Optional(page: i32) => "page"
204    );
205
206    api_get!(
207        /// Moon mining extractions of a corporation.
208        get_corporation_mining_extractions,
209        "GetCorporationCorporationIdMiningExtractions",
210        RequestType::Authenticated,
211        Vec<MiningExtraction>,
212        (corporation_id: i64) => "{corporation_id}";
213        Optional(page: i32) => "page"
214    );
215
216    api_get!(
217        /// Structures that observed mining for a corporation.
218        get_corporation_mining_observers,
219        "GetCorporationCorporationIdMiningObservers",
220        RequestType::Authenticated,
221        Vec<MiningObserver>,
222        (corporation_id: i64) => "{corporation_id}";
223        Optional(page: i32) => "page"
224    );
225
226    api_get!(
227        /// Mining recorded by one observer structure of a corporation.
228        get_corporation_mining_observer,
229        "GetCorporationCorporationIdMiningObserversObserverId",
230        RequestType::Authenticated,
231        Vec<ObservedMining>,
232        (corporation_id: i64) => "{corporation_id}",
233        (observer_id: i64) => "{observer_id}";
234        Optional(page: i32) => "page"
235    );
236
237    api_get!(
238        /// List industry jobs placed by a corporation.
239        get_corporation_industry_jobs,
240        "GetCorporationsCorporationIdIndustryJobs",
241        RequestType::Authenticated,
242        Vec<CorporationIndustryJob>,
243        (corporation_id: i64) => "{corporation_id}";
244        Optional(include_completed: bool) => "include_completed",
245        Optional(page: i32) => "page"
246    );
247}
248
249#[cfg(test)]
250mod mining_tests {
251    use super::*;
252
253    #[test]
254    fn test_parse_mining_and_jobs() {
255        let observer: MiningObserver = serde_json::from_str(
256            r#"{"last_updated":"2026-10-01","observer_id":1,"observer_type":"other"}"#,
257        )
258        .unwrap();
259        assert_eq!(observer.observer_type, ObserverType::Unrecognized);
260        let job: CorporationIndustryJob = serde_json::from_str(
261            r#"{"activity_id":1,"blueprint_id":2,"blueprint_location_id":3,"blueprint_type_id":4,
262            "duration":5,"end_date":"x","facility_id":6,"installer_id":7,"job_id":8,"location_id":9,
263            "output_location_id":10,"runs":1,"start_date":"y","status":"ready"}"#,
264        )
265        .unwrap();
266        assert_eq!(job.status, IndustryJobStatus::Ready);
267        assert!(job.cost.is_none());
268    }
269}