eve_esi 0.4.9

Thread-safe, asynchronous client for EVE Online's ESI & OAuth2
Documentation
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
//! # EVE ESI Character Endpoints
//!
//! This module provides the [`CharacterEndpoints`] struct and associated methods for accessing
//! character-related ESI endpoints.
//!
//! For an overview & usage examples, see the [endpoints module documentation](super)
//!
//! ## ESI Documentation
//! - <https://developers.eveonline.com/api-explorer>
//!
//! ## Endpoints (11)
//! ### Public (3)
//! |                       Endpoint                           |                               Description                                 |
//! | -------------------------------------------------------- | ------------------------------------------------------------------------- |
//! | [`CharacterEndpoints::get_character_public_information`] | Retrieves the public information of a specific character                  |
//! | [`CharacterEndpoints::get_corporation_history`]          | Retrieves the public corporation history of the provided character ID     |
//! | [`CharacterEndpoints::get_character_portraits`]          | Retrieves the image URLs of a chacter's portraits with various dimensions |
//!
//! ### Authenticated (9)
//! |                         Endpoint                         |                                          Description                                            |
//! | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
//! | [`CharacterEndpoints::get_agents_research`]              | Retrieves character's research agents using the character's ID                                  |
//! | [`CharacterEndpoints::get_blueprints`]                   | Retrieves character's blueprints using the character's ID & page to fetch of the blueprint list |
//! | [`CharacterEndpoints::calculate_a_cspa_charge_cost`]     | Calculates CSPA cost for evemailing a list of characters with the provided character ID         |
//! | [`CharacterEndpoints::get_jump_fatigue`]                 | Retrieves jump fatigue for the provided character's ID                                          |
//! | [`CharacterEndpoints::get_medals`]                       | Retrieves a list of medals for the provided character ID                                        |
//! | [`CharacterEndpoints::get_character_notifications`]      | Retrieves a list of character's notifications                                                   |
//! | [`CharacterEndpoints::get_character_corporation_roles`]  | Retrieves a list of the provided character ID's corporation roles                               |
//! | [`CharacterEndpoints::get_standings`]                    | Retrieves a paginated list of NPC standing entries for the provided character ID                |
//! | [`CharacterEndpoints::get_character_corporation_titles`] | Retrieves a list of the provided character ID's corporation titles                              |

use crate::error::Error;
use crate::model::standing::Standing;
use crate::scope::CharactersScopes;
use crate::{Client, ScopeBuilder};

use crate::model::asset::Blueprint;
use crate::model::character::{
    Character, CharacterAffiliation, CharacterCorporationHistory, CharacterCorporationRole,
    CharacterCorporationTitle, CharacterJumpFatigue, CharacterMedal,
    CharacterNewContactNotification, CharacterNotification, CharacterPortraits,
    CharacterResearchAgent,
};

/// Provides methods for accessing character-related endpoints of the EVE Online ESI API.
///
/// For an overview & usage examples, see the [endpoints module documentation](super)
pub struct CharacterEndpoints<'a> {
    client: &'a Client,
}

impl<'a> CharacterEndpoints<'a> {
    /// Creates a new instance of [`CharacterEndpoints`].
    ///
    /// For an overview & usage examples, see the [endpoints module documentation](super)e
    ///
    /// # Arguments
    /// - `client` (&[`Client`]): ESI client used for making HTTP requests to the ESI endpoints.
    pub(super) fn new(client: &'a Client) -> Self {
        Self { client }
    }

    define_endpoint! {
        /// Retrieves the public information of the provided character ID
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterId>
        ///
        /// # Arguments
        /// - `character_id` (`i64`): The ID of the character to retrieve information for.
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - [`Character`]: The character's information if successfully retrieved
        /// - [`Error`]: An error if the fetch request fails
        pub_get get_character_public_information(
            character_id: i64
        ) -> Result<Character, Error>
        url = "{}/characters/{}";
        label = "public information";
    }

    define_endpoint! {
        /// Retrieve affiliations for a list of characters
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/PostCharactersAffiliation>
        ///
        /// # Arguments
        /// - `character_ids` (Vec<[`i64`]>): A vec of character IDs to retrieve affiliations for.
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - Vec<[`CharacterAffiliation`]>: The affiliations of the characters if successfully retrieved
        /// - [`Error`]: An error if the fetch request fails
        pub_post character_affiliation(
            character_ids: Vec<i64>,
        ) -> Result<Vec<CharacterAffiliation>, Error>
        url = "{}/characters/affiliation";
        label = "character affiliation";
    }

    define_endpoint! {
        /// Retrieves character's research agents using the character's ID
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/schemas/CharactersCharacterIdAgentsResearchGet>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_agents_research`](crate::scope::CharactersScopes::read_agents_research):
        ///   `esi-characters.read_agents_research.v1`
        ///
        /// # Arguments
        /// - `access_token` (`&str`): Access token used for authenticated ESI routes in string format.
        /// - `character_id` (`i64`): The ID of the character to retrieve research agent information for.
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - Vec<[`CharacterResearchAgent`]>: A Vec of the character's research agents
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_agents_research(
            access_token: &str,
            character_id: i64
        ) -> Result<Vec<CharacterResearchAgent>, Error>
        url = "{}/characters/{}/agents_research";
        label = "research agents";
        required_scopes = ScopeBuilder::new()
            .characters(CharactersScopes::new().read_agents_research())
            .build();
    }

    define_endpoint! {
        /// Retrieves character's blueprints using the character's ID & page to fetch of the blueprint list
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdBlueprints>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_blueprints`](crate::scope::CharactersScopes::read_blueprints):
        ///   `esi-characters.read_blueprints.v1`
        ///
        /// # Arguments
        /// - `access_token` (`&str`): Access token used for authenticated ESI routes in string format.
        /// - `character_id` (`i64`): The ID of the character to retrieve blueprints for
        /// - `page`         (`i32`): The page of blueprints to retrieve, page numbers start at `1`
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - Vec<[`Blueprint`]>: A Vec of the character's blueprints
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_blueprints(
            access_token: &str,
            character_id: i64;
            page: i32
        ) -> Result<Vec<Blueprint>, Error>
        url = "{}/characters/{}/blueprints";
        label = "blueprints";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_blueprints()).build();
    }

    define_endpoint! {
        /// Retrieves the public corporation history of the provided character ID
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdCorporationhistory>
        ///
        /// # Arguments
        /// - `character_id` (`i64`): The ID of the character to retrieve corporation history for.
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - [Vec<`CharacterCorporationHistory`>]: The character's corporation history if request is successful
        /// - [`Error`]: An error if the fetch request fails
        pub_get get_corporation_history(
            character_id: i64
        ) -> Result<Vec<CharacterCorporationHistory>, Error>
        url = "{}/characters/{}/corporationhistory";
        label = "corporation history";
    }

    define_endpoint! {
        /// Calculates CSPA cost for evemailing a list of characters with the provided character ID
        ///
        /// This ESI route is used to calculate the CSPA cost for a list of characters based upon the
        /// contacts of the provided character ID which could affect the cost based upon standing.
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <developers.eveonline.com/api-explorer#/operations/PostCharactersCharacterIdCspa>
        ///
        /// # Arguments
        /// - `access_token` (`&str`): Access token used for authenticated ESI routes in string format
        /// - `character_ids` (`Vec<i64>`): List of character IDs to calculate the CSPA cost to
        ///   evemail.
        /// - `character_id` (`i64`): ID of the character who would be sending the evemails
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - `f64`: An f64 representing the total cost to evemail the list of characters
        /// - [`Error`]: An error if the fetch request fails
        auth_post calculate_a_cspa_charge_cost(
            access_token: &str,
            character_ids: Vec<i64>,
            character_id: i64
        ) -> Result<f64, Error>
        url = "{}/characters/{}/cspa";
        label = "CSPA charge cost";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_contacts()).build();
    }

    define_endpoint! {
        /// Retrieves jump fatigue for the provided character's ID
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdFatigue>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_fatigue`](crate::scope::CharactersScopes::read_fatigue):
        ///   `esi-characters.read_fatigue.v1`
        ///
        /// # Arguments
        /// - `access_token` (`&str`): Access token used for authenticated ESI routes in string format.
        /// - `character_id` (`i64`): The ID of the character to retrieve jump fatigue for
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - [`CharacterJumpFatigue`]: The character's jump fatigue status
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_jump_fatigue(
            access_token: &str,
            character_id: i64
        ) -> Result<CharacterJumpFatigue, Error>
        url = "{}/characters/{}/fatigue";
        label = "jump fatigue";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_fatigue()).build();
    }

    define_endpoint! {
        /// Retrieves a list of medals for the provided character ID
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdMedals>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_medals`](crate::scope::CharactersScopes::read_medals):
        ///   `esi-characters.read_medals.v1`
        ///
        /// # Arguments
        /// - `access_token` (`&str`): Access token used for authenticated ESI routes in string format.
        /// - `character_id` (`i64`): The ID of the character to retrieve jump fatigue for
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - `Vec<`[`CharacterMedal`]`>`: A list of the character's medals
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_medals(
            access_token: &str,
            character_id: i64
        ) -> Result<Vec<CharacterMedal>, Error>
        url = "{}/characters/{}/medals";
        label = "medals";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_medals()).build();
    }

    define_endpoint! {
        /// Retrieves a list of character's notifications
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdNotifications>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_notifications`](crate::scope::CharactersScopes::read_notifications):
        ///   `esi-characters.read_notifications.v1`
        ///
        /// # Arguments
        /// - `access_token` (`&str`): Access token used for authenticated ESI routes in string format.
        /// - `character_id` (`i64`): The ID of the character to retrieve notifications for
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - `Vec<`[`CharacterNotification`]`>`: A list of the character's notifications
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_character_notifications(
            access_token: &str,
            character_id: i64
        ) -> Result<Vec<CharacterNotification>, Error>
        url = "{}/characters/{}/notifications";
        label = "notifications";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_notifications()).build();
    }

    define_endpoint! {
        /// Retrieves a list of character's notifications about being added to someone's contact list
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdNotificationsContacts>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_notifications`](crate::scope::CharactersScopes::read_notifications):
        ///   `esi-characters.read_notifications.v1`
        ///
        /// # Arguments
        /// - `access_token` (`&str`): Access token used for authenticated ESI routes in string format.
        /// - `character_id` (`i64`): The ID of the character to retrieve added as contact notifications
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - `Vec<`[`CharacterNewContactNotification`]`>`: A list of character's notifications about being added to
        ///   someone's contact list
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_new_contact_notifications(
            access_token: &str,
            character_id: i64
        ) -> Result<Vec<CharacterNewContactNotification>, Error>
        url = "{}/characters/{}/notifications/contacts";
        label = "new contact notifications";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_notifications()).build();
    }

    define_endpoint! {
        /// Retrieves the image URLs of a chacter's portraits with various dimensions
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdPortrait>
        ///
        /// # Arguments
        /// - `character_id` (`i64`): The ID of the character to retrieve portrait image URLs for
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - [`CharacterPortraits`]: Struct of character's portrait URLs with various dimensions
        /// - [`Error`]: An error if the fetch request fails
        pub_get get_character_portraits(
            character_id: i64
        ) -> Result<CharacterPortraits, Error>
        url = "{}/characters/{}/portrait";
        label = "portraits";
    }

    define_endpoint! {
        /// Retrieves a list of the provided character ID's corporation roles
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdRoles>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_corporation_roles`](crate::scope::CharactersScopes::read_corporation_roles):
        ///   `esi-characters.read_corporation_roles.v1`
        ///
        /// # Arguments
        /// - `character_id` (`i64`): The ID of the character to retrieve corporation roles for
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - [`CharacterCorporationRole`]: Struct containing entries for the provided character ID's corporation roles.
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_character_corporation_roles(
            access_token: &str,
            character_id: i64
        ) -> Result<CharacterCorporationRole, Error>
        url = "{}/characters/{}/roles";
        label = "corporation roles";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_corporation_roles()).build();
    }

    define_endpoint! {
        /// Retrieves a paginated list of NPC standing entries for the provided character ID
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdStandings>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_standings`](crate::scope::CharactersScopes::read_standings):
        ///   `esi-characters.read_standings.v1`
        ///
        /// # Arguments
        /// - `character_id` (`i64`): The ID of the character to retrieve standings for
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - `Vec<`[`Standing`]`>`: Paginated list of NPC standing entries for the provided character ID
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_standings(
            access_token: &str,
            character_id: i64
        ) -> Result<Vec<Standing>, Error>
        url = "{}/characters/{}/standings";
        label = "NPC standings";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_standings()).build();
    }

    define_endpoint! {
        /// Retrieves a list of the provided character ID's corporation titles
        ///
        /// For an overview & usage examples, see the [endpoints module documentation](super)
        ///
        /// # ESI Documentation
        /// - <https://developers.eveonline.com/api-explorer#/operations/GetCharactersCharacterIdTitles>
        ///
        /// # Required Scopes
        /// - [`CharactersScopes::read_titles`](crate::scope::CharactersScopes::read_titles):
        ///   `esi-characters.read_titles.v1`
        ///
        /// # Arguments
        /// - `character_id` (`i64`): The ID of the character to retrieve corporation titles for
        ///
        /// # Returns
        /// Returns a [`Result`] containing either:
        /// - `Vec<`[`CharacterCorporationTitle`]`>`: List of entries for the provided character ID's
        ///   corporation titles
        /// - [`Error`]: An error if the fetch request fails
        auth_get get_character_corporation_titles(
            access_token: &str,
            character_id: i64
        ) -> Result<Vec<CharacterCorporationTitle>, Error>
        url = "{}/characters/{}/titles";
        label = "standings";
        required_scopes = ScopeBuilder::new().characters(CharactersScopes::new().read_titles()).build();
    }
}