1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
use crate::prelude::*;

/// Endpoints for FactionWarfare
pub struct FactionWarfareGroup<'a> {
    pub(crate) esi: &'a Esi,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FactionLeaderboardItem {
    pub amount: Option<i32>,
    pub faction_id: Option<i32>,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FactionLeaderboardListing {
    pub active_total: Vec<FactionLeaderboardItem>,
    pub last_week: Vec<FactionLeaderboardItem>,
    pub yesterday: Vec<FactionLeaderboardItem>,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FWLeaderboards {
    pub kills: FactionLeaderboardListing,
    pub victory_points: FactionLeaderboardListing,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct CharacterLeaderboardItem {
    pub amount: i32,
    pub character_id: i32,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct CharacterLeaderboardListing {
    pub active_total: Vec<CharacterLeaderboardItem>,
    pub last_week: Vec<CharacterLeaderboardItem>,
    pub yesterday: Vec<CharacterLeaderboardItem>,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FWCharacterLeaderboards {
    pub kills: CharacterLeaderboardListing,
    pub victory_points: CharacterLeaderboardListing,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct CorporationLeaderboardItem {
    pub amount: i32,
    pub corporation_id: i32,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct CorporationLeaderboardListing {
    pub active_total: Vec<CorporationLeaderboardItem>,
    pub last_week: Vec<CorporationLeaderboardItem>,
    pub yesterday: Vec<CorporationLeaderboardItem>,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FWCorporationLeaderboards {
    pub kills: CorporationLeaderboardListing,
    pub victory_points: CorporationLeaderboardListing,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FWStatsItemRange {
    pub total: i32,
    pub last_week: i32,
    pub yesterday: i32,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FWStatsItem {
    pub faction_id: u32,
    pub kills: FWStatsItemRange,
    pub pilots: u32,
    pub systems_controlled: u32,
    pub victory_points: FWStatsItemRange,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FWSystem {
    pub contested: String,
    pub occupier_faction_id: u8,
    pub owner_faction_id: u32,
    pub solar_system_id: u32,
    pub victory_points: u32,
    pub victory_points_threshold: u32,
}

#[derive(Debug, Deserialize)]
#[allow(missing_docs)]
pub struct FWWar {
    pub faction_id: i32,
    pub against_id: i32,
}

impl<'a> FactionWarfareGroup<'a> {
    api_get!(
        /// Get the top 4 leaderboards of factions for total, last week, and yesterday.
        leaderboards,
        "get_fw_leaderboards",
        RequestType::Public,
        FWLeaderboards,
    );

    api_get!(
        /// Get top 100 characters for total, last week, and yesterday.
        leaderboard_characters,
        "get_fw_leaderboards_characters",
        RequestType::Public,
        FWCharacterLeaderboards,
    );

    api_get!(
        /// Get top 10 corporations for total, last week, and yesterday.
        leaderboard_corporations,
        "get_fw_leaderboards_corporations",
        RequestType::Public,
        FWCorporationLeaderboards,
    );

    api_get!(
        /// Get FW overview stats.
        stats,
        "get_fw_stats",
        RequestType::Public,
        Vec<FWStatsItem>,
    );

    api_get!(
        /// Get FW system ownership.
        systems,
        "get_fw_systems",
        RequestType::Public,
        Vec<FWSystem>,
    );

    api_get!(
        /// Get FW faction information.
        wars,
        "get_fw_wars",
        RequestType::Public,
        Vec<FWWar>,
    );

    // more endpoints ...
}