esi_openapi/groups/
activities.rs1use crate::prelude::*;
2use uuid::Uuid;
3
4pub struct ActivitiesGroup<'a> {
6 pub(crate) esi: &'a Esi,
7}
8
9#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
11pub struct TacticalOperationSummary {
12 pub id: Uuid,
14 pub mercenary_den_id: i64,
16}
17
18#[derive(Debug, Deserialize)]
19struct TacticalOperations {
20 operations: Vec<TacticalOperationSummary>,
21}
22
23#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
25pub enum TacticalOperationState {
26 Unspecified,
28 Available,
30 Started,
32 Completed,
34 Expired,
36 Removed,
38 #[serde(other)]
40 Unrecognized,
41}
42
43#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
45#[allow(missing_docs)]
46pub struct TacticalOperation {
47 pub dungeon_type_id: i64,
48 pub expires: String,
49 pub id: Uuid,
50 pub mercenary_den_id: i64,
51 pub state: TacticalOperationState,
52}
53
54#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
56pub struct TheftVulnerability {
57 pub end: String,
59 pub start: String,
61}
62
63#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
65#[allow(missing_docs)]
66pub struct RaidableSkyhook {
67 pub planet_id: i64,
68 pub solar_system_id: i64,
69 pub theft_vulnerability: TheftVulnerability,
70}
71
72#[derive(Debug, Deserialize)]
73struct RaidableSkyhooks {
74 skyhooks: Vec<RaidableSkyhook>,
75}
76
77impl ActivitiesGroup<'_> {
78 pub async fn get_character_tactical_operations(
80 &self,
81 character_id: i64,
82 ) -> EsiResult<Vec<TacticalOperationSummary>> {
83 let path = self
84 .esi
85 .get_endpoint_for_op_id("GetCharactersMercenaryTacticalOperationsListing")?
86 .replace("{character_id}", &character_id.to_string());
87 let wrapper: TacticalOperations = self
88 .esi
89 .query("GET", RequestType::Authenticated, &path, None, None)
90 .await?;
91 Ok(wrapper.operations)
92 }
93
94 api_get!(
95 get_character_tactical_operation,
97 "GetCharactersMercenaryTacticalOperationsDetail",
98 RequestType::Authenticated,
99 TacticalOperation,
100 (character_id: i64) => "{character_id}",
101 (operation_id: Uuid) => "{operation_id}"
102 );
103
104 pub async fn get_raidable_skyhooks(&self) -> EsiResult<Vec<RaidableSkyhook>> {
106 let path = self.esi.get_endpoint_for_op_id("GetSkyhooksRaidable")?;
107 let wrapper: RaidableSkyhooks = self
108 .esi
109 .query("GET", RequestType::Public, &path, None, None)
110 .await?;
111 Ok(wrapper.skyhooks)
112 }
113}
114
115#[cfg(test)]
116mod tests {
117 use super::*;
118
119 #[test]
120 fn test_parse_operation_and_skyhook() {
121 let op: TacticalOperation = serde_json::from_str(
122 r#"{"dungeon_type_id":1,"expires":"x","id":"67e6b7a0-6f58-4b5b-a2c4-4f3a1f0f2b11",
123 "mercenary_den_id":2,"state":"Weird"}"#,
124 )
125 .unwrap();
126 assert_eq!(op.state, TacticalOperationState::Unrecognized);
127 let hooks: RaidableSkyhooks = serde_json::from_str(
128 r#"{"skyhooks":[{"planet_id":1,"solar_system_id":2,
129 "theft_vulnerability":{"start":"a","end":"b"}}]}"#,
130 )
131 .unwrap();
132 assert_eq!(hooks.skyhooks[0].solar_system_id, 2);
133 }
134}