Skip to main content

esi_openapi/groups/
corporation.rs

1use crate::groups::{Blueprint, CorporationRole, MedalStatus, Standing};
2use crate::prelude::*;
3
4#[derive(Debug, Deserialize, Serialize, Clone)]
5#[allow(missing_docs)]
6pub struct CorporationPublicInfo {
7    pub alliance_id: Option<i64>,
8    pub ceo_id: Option<i64>,
9    pub creator_id: Option<i64>,
10    pub date_founded: Option<String>,
11    pub description: Option<String>,
12    pub enlisted_faction_id: Option<i64>,
13    /// `legal` or `illegal`.
14    pub friendly_fire: Option<String>,
15    pub home_station_id: Option<i64>,
16    pub member_count: i64,
17    pub name: String,
18    pub palette: Option<CorporationPalette>,
19    pub shares: Option<i64>,
20    /// `active` or `closed`.
21    pub state: Option<String>,
22    pub tax_rates: Option<CorporationTaxRates>,
23    pub ticker: Option<String>,
24    /// `player_owned` or `npc_owned`.
25    #[serde(rename = "type")]
26    pub corporation_type: Option<String>,
27    pub url: Option<String>,
28    pub war_eligible: Option<bool>,
29}
30
31/// Corporation tax rates, as percentages (0.0 - 100.0).
32#[derive(Debug, Deserialize, Serialize, Clone)]
33pub struct CorporationTaxRates {
34    /// ISK tax rate.
35    pub isk: Option<f64>,
36    /// Loyalty point tax rate.
37    pub loyalty_point: Option<f64>,
38}
39
40/// Corporation palette colors (`#rrggbb`).
41#[derive(Debug, Deserialize, Serialize, Clone)]
42pub struct CorporationPalette {
43    /// Main color.
44    pub main_color: Option<String>,
45    /// Secondary color.
46    pub secondary_color: Option<String>,
47    /// Tertiary color.
48    pub tertiary_color: Option<String>,
49}
50
51#[derive(Debug, Deserialize)]
52#[allow(missing_docs)]
53pub struct CorporationHistoryItem {
54    pub alliance_id: Option<i64>,
55    pub is_deleted: Option<bool>,
56    pub record_id: i64,
57    pub start_date: String,
58}
59
60/// Icon URLs of a corporation.
61#[derive(Debug, Deserialize, Serialize, Clone)]
62pub struct CorporationIcons {
63    /// 128x128 icon.
64    pub px128x128: Option<String>,
65    /// 256x256 icon.
66    pub px256x256: Option<String>,
67    /// 64x64 icon.
68    pub px64x64: Option<String>,
69}
70
71/// The action recorded in a container log entry.
72#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
73#[serde(rename_all = "snake_case")]
74pub enum ContainerAction {
75    /// Item added.
76    Add,
77    /// Container assembled.
78    Assemble,
79    /// Container configured.
80    Configure,
81    /// Password entered.
82    EnterPassword,
83    /// Container locked.
84    Lock,
85    /// Item moved.
86    Move,
87    /// Container repackaged.
88    Repackage,
89    /// Container renamed.
90    SetName,
91    /// Password set.
92    SetPassword,
93    /// Container unlocked.
94    Unlock,
95    /// A value this version of the crate does not know about.
96    #[serde(other)]
97    Unrecognized,
98}
99
100/// The kind of password involved in a container log entry.
101#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
102#[serde(rename_all = "snake_case")]
103pub enum ContainerPasswordType {
104    /// Configuration password.
105    Config,
106    /// General password.
107    General,
108    /// A value this version of the crate does not know about.
109    #[serde(other)]
110    Unrecognized,
111}
112
113/// An entry of the corporation container log.
114#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
115pub struct ContainerLogEntry {
116    /// What happened.
117    pub action: ContainerAction,
118    /// Character that did it.
119    pub character_id: i64,
120    /// ID of the container.
121    pub container_id: i64,
122    /// Type ID of the container.
123    pub container_type_id: i64,
124    /// Where the container is (see the ESI location flags).
125    pub location_flag: String,
126    /// ID of the location.
127    pub location_id: i64,
128    /// When it happened.
129    pub logged_at: String,
130    /// Configuration bitmask after the change.
131    pub new_config_bitmask: Option<i64>,
132    /// Configuration bitmask before the change.
133    pub old_config_bitmask: Option<i64>,
134    /// Kind of password involved.
135    pub password_type: ContainerPasswordType,
136    /// Quantity moved.
137    pub quantity: Option<i64>,
138    /// Type ID of the item moved.
139    pub type_id: Option<i64>,
140}
141
142/// A hangar or wallet division.
143#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
144pub struct Division {
145    /// Number of the division.
146    pub division: Option<i64>,
147    /// Name of the division.
148    pub name: Option<String>,
149}
150
151/// The hangar and wallet divisions of a corporation.
152#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
153pub struct CorporationDivisions {
154    /// Hangar divisions.
155    #[serde(default)]
156    pub hangar: Vec<Division>,
157    /// Wallet divisions.
158    #[serde(default)]
159    pub wallet: Vec<Division>,
160}
161
162/// An industry facility of a corporation.
163#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
164pub struct CorporationFacility {
165    /// ID of the facility.
166    pub facility_id: i64,
167    /// Solar system of the facility.
168    pub system_id: i64,
169    /// Type ID of the facility.
170    pub type_id: i64,
171}
172
173/// A medal created by a corporation.
174#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
175pub struct CorporationMedal {
176    /// When the medal was created.
177    pub created_at: String,
178    /// Character that created the medal.
179    pub creator_id: i64,
180    /// Description of the medal.
181    pub description: String,
182    /// ID of the medal.
183    pub medal_id: i64,
184    /// Title of the medal.
185    pub title: String,
186}
187
188/// A medal issued to a character.
189#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
190pub struct IssuedMedal {
191    /// Character the medal was issued to.
192    pub character_id: i64,
193    /// When the medal was issued.
194    pub issued_at: String,
195    /// Character that issued the medal.
196    pub issuer_id: i64,
197    /// ID of the medal.
198    pub medal_id: i64,
199    /// Reason for the medal.
200    pub reason: String,
201    /// Visibility of the medal.
202    pub status: MedalStatus,
203}
204
205/// The titles of a corporation member.
206#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
207pub struct MemberTitles {
208    /// Character ID of the member.
209    pub character_id: i64,
210    /// Title IDs held by the member.
211    pub titles: Vec<i64>,
212}
213
214/// Tracking information about a corporation member.
215#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
216pub struct MemberTracking {
217    /// Base (home station) of the member.
218    pub base_id: Option<i64>,
219    /// Character ID of the member.
220    pub character_id: i64,
221    /// Current location of the member.
222    pub location_id: Option<i64>,
223    /// Last logoff.
224    pub logoff_date: Option<String>,
225    /// Last logon.
226    pub logon_date: Option<String>,
227    /// Type ID of the ship the member flies.
228    pub ship_type_id: Option<i64>,
229    /// When the member joined.
230    pub start_date: Option<String>,
231}
232
233/// The roles of a corporation member.
234#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
235pub struct MemberRoles {
236    /// Character ID of the member.
237    pub character_id: i64,
238    /// Roles the member can grant.
239    #[serde(default)]
240    pub grantable_roles: Vec<CorporationRole>,
241    /// Roles the member can grant at the base.
242    #[serde(default)]
243    pub grantable_roles_at_base: Vec<CorporationRole>,
244    /// Roles the member can grant at the headquarters.
245    #[serde(default)]
246    pub grantable_roles_at_hq: Vec<CorporationRole>,
247    /// Roles the member can grant at other locations.
248    #[serde(default)]
249    pub grantable_roles_at_other: Vec<CorporationRole>,
250    /// Roles of the member.
251    #[serde(default)]
252    pub roles: Vec<CorporationRole>,
253    /// Roles of the member at the base.
254    #[serde(default)]
255    pub roles_at_base: Vec<CorporationRole>,
256    /// Roles of the member at the headquarters.
257    #[serde(default)]
258    pub roles_at_hq: Vec<CorporationRole>,
259    /// Roles of the member at other locations.
260    #[serde(default)]
261    pub roles_at_other: Vec<CorporationRole>,
262}
263
264/// Which set of roles a role history entry changed.
265#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
266#[serde(rename_all = "snake_case")]
267pub enum RoleType {
268    /// Grantable roles.
269    GrantableRoles,
270    /// Grantable roles at the base.
271    GrantableRolesAtBase,
272    /// Grantable roles at the headquarters.
273    GrantableRolesAtHq,
274    /// Grantable roles at other locations.
275    GrantableRolesAtOther,
276    /// Roles.
277    Roles,
278    /// Roles at the base.
279    RolesAtBase,
280    /// Roles at the headquarters.
281    RolesAtHq,
282    /// Roles at other locations.
283    RolesAtOther,
284    /// A value this version of the crate does not know about.
285    #[serde(other)]
286    Unrecognized,
287}
288
289/// An entry of the corporation roles history.
290#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
291pub struct RoleHistoryEntry {
292    /// When the change happened.
293    pub changed_at: String,
294    /// Character whose roles changed.
295    pub character_id: i64,
296    /// Character that made the change.
297    pub issuer_id: i64,
298    /// Roles after the change.
299    pub new_roles: Vec<CorporationRole>,
300    /// Roles before the change.
301    pub old_roles: Vec<CorporationRole>,
302    /// Which set of roles changed.
303    pub role_type: RoleType,
304}
305
306/// The kind of entity that holds shares.
307#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
308#[serde(rename_all = "snake_case")]
309pub enum ShareholderType {
310    /// A character.
311    Character,
312    /// A corporation.
313    Corporation,
314    /// A value this version of the crate does not know about.
315    #[serde(other)]
316    Unrecognized,
317}
318
319/// A shareholder of a corporation.
320#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
321pub struct Shareholder {
322    /// Number of shares held.
323    pub share_count: i64,
324    /// ID of the shareholder.
325    pub shareholder_id: i64,
326    /// Kind of the shareholder.
327    pub shareholder_type: ShareholderType,
328}
329
330/// The state of a starbase.
331#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
332#[serde(rename_all = "snake_case")]
333pub enum StarbaseState {
334    /// Offline.
335    Offline,
336    /// Online.
337    Online,
338    /// Onlining.
339    Onlining,
340    /// Reinforced.
341    Reinforced,
342    /// Unanchoring.
343    Unanchoring,
344    /// A value this version of the crate does not know about.
345    #[serde(other)]
346    Unrecognized,
347}
348
349/// A starbase (POS) of a corporation.
350#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
351pub struct Starbase {
352    /// Moon the starbase is anchored at.
353    pub moon_id: Option<i64>,
354    /// When the starbase went online.
355    pub onlined_since: Option<String>,
356    /// Until when the starbase is reinforced.
357    pub reinforced_until: Option<String>,
358    /// ID of the starbase.
359    pub starbase_id: i64,
360    /// State of the starbase.
361    pub state: Option<StarbaseState>,
362    /// Solar system of the starbase.
363    pub system_id: i64,
364    /// Type ID of the starbase.
365    pub type_id: i64,
366    /// When the starbase unanchors.
367    pub unanchor_at: Option<String>,
368}
369
370/// Who is allowed to perform an action on a starbase.
371#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
372#[serde(rename_all = "snake_case")]
373pub enum StarbasePermission {
374    /// Alliance members.
375    AllianceMember,
376    /// Members with the Config Starbase Equipment role.
377    ConfigStarbaseEquipmentRole,
378    /// Corporation members.
379    CorporationMember,
380    /// Members with the Starbase Fuel Technician role.
381    StarbaseFuelTechnicianRole,
382    /// A value this version of the crate does not know about.
383    #[serde(other)]
384    Unrecognized,
385}
386
387/// Fuel in a starbase.
388#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
389pub struct StarbaseFuel {
390    /// Quantity of fuel.
391    pub quantity: i64,
392    /// Type ID of the fuel.
393    pub type_id: i64,
394}
395
396/// The settings of a starbase.
397#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
398pub struct StarbaseDetails {
399    /// Whether alliance members may use the starbase.
400    pub allow_alliance_members: bool,
401    /// Whether corporation members may use the starbase.
402    pub allow_corporation_members: bool,
403    /// Who can anchor.
404    pub anchor: StarbasePermission,
405    /// Whether the starbase attacks entities at war with it.
406    pub attack_if_at_war: bool,
407    /// Whether the starbase attacks entities with dropping security status.
408    pub attack_if_other_security_status_dropping: bool,
409    /// Security status threshold for attacks.
410    pub attack_security_status_threshold: Option<f64>,
411    /// Standing threshold for attacks.
412    pub attack_standing_threshold: Option<f64>,
413    /// Who can take from the fuel bay.
414    pub fuel_bay_take: StarbasePermission,
415    /// Who can view the fuel bay.
416    pub fuel_bay_view: StarbasePermission,
417    /// Fuel in the starbase.
418    #[serde(default)]
419    pub fuels: Vec<StarbaseFuel>,
420    /// Who can take it offline.
421    pub offline: StarbasePermission,
422    /// Who can bring it online.
423    pub online: StarbasePermission,
424    /// Who can unanchor.
425    pub unanchor: StarbasePermission,
426    /// Whether alliance standings are used.
427    pub use_alliance_standings: bool,
428}
429
430/// The state of a structure service.
431#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
432#[serde(rename_all = "snake_case")]
433pub enum ServiceState {
434    /// Online.
435    Online,
436    /// Offline.
437    Offline,
438    /// Cleanup.
439    Cleanup,
440    /// A value this version of the crate does not know about.
441    #[serde(other)]
442    Unrecognized,
443}
444
445/// A service installed in a structure.
446#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
447pub struct StructureService {
448    /// Name of the service.
449    pub name: String,
450    /// State of the service.
451    pub state: ServiceState,
452}
453
454/// The state of a structure.
455#[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)]
456#[serde(rename_all = "snake_case")]
457pub enum StructureState {
458    /// Anchor vulnerable.
459    AnchorVulnerable,
460    /// Anchoring.
461    Anchoring,
462    /// Armor reinforce.
463    ArmorReinforce,
464    /// Armor vulnerable.
465    ArmorVulnerable,
466    /// Deploy vulnerable.
467    DeployVulnerable,
468    /// Fitting invulnerable.
469    FittingInvulnerable,
470    /// Hull reinforce.
471    HullReinforce,
472    /// Hull vulnerable.
473    HullVulnerable,
474    /// Online (deprecated).
475    OnlineDeprecated,
476    /// Onlining vulnerable.
477    OnliningVulnerable,
478    /// Shield vulnerable.
479    ShieldVulnerable,
480    /// Unanchored.
481    Unanchored,
482    /// Unknown.
483    Unknown,
484    /// A value this version of the crate does not know about.
485    #[serde(other)]
486    Unrecognized,
487}
488
489/// A structure owned by a corporation.
490#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
491pub struct CorporationStructure {
492    /// Corporation that owns the structure.
493    pub corporation_id: i64,
494    /// When the fuel runs out.
495    pub fuel_expires: Option<String>,
496    /// Name of the structure.
497    pub name: Option<String>,
498    /// When the next reinforcement hour applies.
499    pub next_reinforce_apply: Option<String>,
500    /// Next reinforcement hour.
501    pub next_reinforce_hour: Option<i64>,
502    /// ID of the structure's vulnerability profile.
503    pub profile_id: i64,
504    /// Current reinforcement hour.
505    pub reinforce_hour: Option<i64>,
506    /// Services of the structure.
507    #[serde(default)]
508    pub services: Vec<StructureService>,
509    /// State of the structure.
510    pub state: StructureState,
511    /// When the current state timer ends.
512    pub state_timer_end: Option<String>,
513    /// When the current state timer started.
514    pub state_timer_start: Option<String>,
515    /// ID of the structure.
516    pub structure_id: i64,
517    /// Solar system of the structure.
518    pub system_id: i64,
519    /// Type ID of the structure.
520    pub type_id: i64,
521    /// When the structure unanchors.
522    pub unanchors_at: Option<String>,
523}
524
525/// A corporation title.
526#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
527pub struct CorporationTitle {
528    /// Roles the title can grant.
529    #[serde(default)]
530    pub grantable_roles: Vec<CorporationRole>,
531    /// Roles the title can grant at the base.
532    #[serde(default)]
533    pub grantable_roles_at_base: Vec<CorporationRole>,
534    /// Roles the title can grant at the headquarters.
535    #[serde(default)]
536    pub grantable_roles_at_hq: Vec<CorporationRole>,
537    /// Roles the title can grant at other locations.
538    #[serde(default)]
539    pub grantable_roles_at_other: Vec<CorporationRole>,
540    /// Name of the title.
541    pub name: Option<String>,
542    /// Roles of the title.
543    #[serde(default)]
544    pub roles: Vec<CorporationRole>,
545    /// Roles of the title at the base.
546    #[serde(default)]
547    pub roles_at_base: Vec<CorporationRole>,
548    /// Roles of the title at the headquarters.
549    #[serde(default)]
550    pub roles_at_hq: Vec<CorporationRole>,
551    /// Roles of the title at other locations.
552    #[serde(default)]
553    pub roles_at_other: Vec<CorporationRole>,
554    /// ID of the title.
555    pub title_id: Option<i64>,
556}
557
558/// Endpoints for Corporation
559pub struct CorporationGroup<'a> {
560    pub(crate) esi: &'a Esi,
561}
562
563impl CorporationGroup<'_> {
564    api_get!(
565        /// Get a corporation's public info.
566        get_public_info,
567        "GetCorporationsCorporationId",
568        RequestType::Public,
569        CorporationPublicInfo,
570        (corporation_id: i64) => "{corporation_id}"
571    );
572
573    api_get!(
574        /// Get a corporation's alliance history.
575        get_history,
576        "GetCorporationsCorporationIdAlliancehistory",
577        RequestType::Public,
578        Vec<CorporationHistoryItem>,
579        (corporation_id: i64) => "{corporation_id}"
580    );
581
582    api_get!(
583        /// Get a corporation's member list.
584        ///
585        /// Requires the auth'd character to be in the corporation.
586        get_members,
587        "GetCorporationsCorporationIdMembers",
588        RequestType::Authenticated,
589        Vec<i64>,
590        (corporation_id: i64) => "{corporation_id}"
591    );
592
593    api_get!(
594        /// Get a list of NPC corporations.
595        get_npc_corps,
596        "GetCorporationsNpccorps",
597        RequestType::Public,
598        Vec<i64>,
599    );
600
601    api_get!(
602        /// Get the blueprints of a corporation.
603        ///
604        /// Requires the Director role.
605        get_blueprints,
606        "GetCorporationsCorporationIdBlueprints",
607        RequestType::Authenticated,
608        Vec<Blueprint>,
609        (corporation_id: i64) => "{corporation_id}";
610        Optional(page: i32) => "page"
611    );
612
613    api_get!(
614        /// Get the container logs of a corporation.
615        ///
616        /// Requires the Director role.
617        get_container_logs,
618        "GetCorporationsCorporationIdContainersLogs",
619        RequestType::Authenticated,
620        Vec<ContainerLogEntry>,
621        (corporation_id: i64) => "{corporation_id}";
622        Optional(page: i32) => "page"
623    );
624
625    api_get!(
626        /// Get the hangar and wallet divisions of a corporation.
627        ///
628        /// Requires the Director role.
629        get_divisions,
630        "GetCorporationsCorporationIdDivisions",
631        RequestType::Authenticated,
632        CorporationDivisions,
633        (corporation_id: i64) => "{corporation_id}"
634    );
635
636    api_get!(
637        /// Get the industry facilities of a corporation.
638        ///
639        /// Requires the Factory Manager role.
640        get_facilities,
641        "GetCorporationsCorporationIdFacilities",
642        RequestType::Authenticated,
643        Vec<CorporationFacility>,
644        (corporation_id: i64) => "{corporation_id}"
645    );
646
647    api_get!(
648        /// Get the icons of a corporation.
649        get_icons,
650        "GetCorporationsCorporationIdIcons",
651        RequestType::Public,
652        CorporationIcons,
653        (corporation_id: i64) => "{corporation_id}"
654    );
655
656    api_get!(
657        /// Get the medals created by a corporation.
658        get_medals,
659        "GetCorporationsCorporationIdMedals",
660        RequestType::Authenticated,
661        Vec<CorporationMedal>,
662        (corporation_id: i64) => "{corporation_id}";
663        Optional(page: i32) => "page"
664    );
665
666    api_get!(
667        /// Get the medals issued by a corporation.
668        ///
669        /// Requires the Director role.
670        get_issued_medals,
671        "GetCorporationsCorporationIdMedalsIssued",
672        RequestType::Authenticated,
673        Vec<IssuedMedal>,
674        (corporation_id: i64) => "{corporation_id}";
675        Optional(page: i32) => "page"
676    );
677
678    api_get!(
679        /// Get the member limit of a corporation.
680        ///
681        /// Requires the Director role.
682        get_members_limit,
683        "GetCorporationsCorporationIdMembersLimit",
684        RequestType::Authenticated,
685        i64,
686        (corporation_id: i64) => "{corporation_id}"
687    );
688
689    api_get!(
690        /// Get the titles of the members of a corporation.
691        ///
692        /// Requires the Director role.
693        get_member_titles,
694        "GetCorporationsCorporationIdMembersTitles",
695        RequestType::Authenticated,
696        Vec<MemberTitles>,
697        (corporation_id: i64) => "{corporation_id}"
698    );
699
700    api_get!(
701        /// Track the members of a corporation.
702        ///
703        /// Requires the Director role.
704        get_member_tracking,
705        "GetCorporationsCorporationIdMembertracking",
706        RequestType::Authenticated,
707        Vec<MemberTracking>,
708        (corporation_id: i64) => "{corporation_id}"
709    );
710
711    api_get!(
712        /// Get the roles of the members of a corporation.
713        get_roles,
714        "GetCorporationsCorporationIdRoles",
715        RequestType::Authenticated,
716        Vec<MemberRoles>,
717        (corporation_id: i64) => "{corporation_id}"
718    );
719
720    api_get!(
721        /// Get the role changes of a corporation in the last 30 days.
722        ///
723        /// Requires the Director role.
724        get_roles_history,
725        "GetCorporationsCorporationIdRolesHistory",
726        RequestType::Authenticated,
727        Vec<RoleHistoryEntry>,
728        (corporation_id: i64) => "{corporation_id}";
729        Optional(page: i32) => "page"
730    );
731
732    api_get!(
733        /// Get the shareholders of a corporation.
734        ///
735        /// Requires the Director role.
736        get_shareholders,
737        "GetCorporationsCorporationIdShareholders",
738        RequestType::Authenticated,
739        Vec<Shareholder>,
740        (corporation_id: i64) => "{corporation_id}";
741        Optional(page: i32) => "page"
742    );
743
744    api_get!(
745        /// Get the standings of a corporation.
746        get_standings,
747        "GetCorporationsCorporationIdStandings",
748        RequestType::Authenticated,
749        Vec<Standing>,
750        (corporation_id: i64) => "{corporation_id}";
751        Optional(page: i32) => "page"
752    );
753
754    api_get!(
755        /// Get the starbases of a corporation.
756        ///
757        /// Requires the Director role.
758        get_starbases,
759        "GetCorporationsCorporationIdStarbases",
760        RequestType::Authenticated,
761        Vec<Starbase>,
762        (corporation_id: i64) => "{corporation_id}";
763        Optional(page: i32) => "page"
764    );
765
766    api_get!(
767        /// Get the settings of a starbase. `system_id` is the solar system
768        /// the starbase is in.
769        ///
770        /// Requires the Director role.
771        get_starbase,
772        "GetCorporationsCorporationIdStarbasesStarbaseId",
773        RequestType::Authenticated,
774        StarbaseDetails,
775        (corporation_id: i64) => "{corporation_id}",
776        (starbase_id: i64) => "{starbase_id}";
777        Required(system_id: i64) => "system_id"
778    );
779
780    api_get!(
781        /// Get the structures of a corporation.
782        ///
783        /// Requires the Station Manager role.
784        get_structures,
785        "GetCorporationsCorporationIdStructures",
786        RequestType::Authenticated,
787        Vec<CorporationStructure>,
788        (corporation_id: i64) => "{corporation_id}";
789        Optional(page: i32) => "page"
790    );
791
792    api_get!(
793        /// Get the titles of a corporation.
794        ///
795        /// Requires the Director role.
796        get_titles,
797        "GetCorporationsCorporationIdTitles",
798        RequestType::Authenticated,
799        Vec<CorporationTitle>,
800        (corporation_id: i64) => "{corporation_id}"
801    );
802}
803
804#[cfg(test)]
805mod corporation_management_tests {
806    use super::*;
807
808    #[test]
809    fn test_parse_roles_and_history() {
810        let r: Vec<MemberRoles> = serde_json::from_str(
811            r#"[{"character_id": 2124758468, "roles": ["Director", "Brand_New_Role"],
812                 "roles_at_hq": ["Trader"]}]"#,
813        )
814        .unwrap();
815        assert_eq!(r[0].roles[0], CorporationRole::Director);
816        assert_eq!(r[0].roles[1], CorporationRole::Unrecognized);
817        assert!(r[0].grantable_roles.is_empty());
818        let h: Vec<RoleHistoryEntry> = serde_json::from_str(
819            r#"[{"changed_at": "t", "character_id": 1, "issuer_id": 2, "new_roles": ["Trader"],
820                 "old_roles": [], "role_type": "roles_at_hq"}]"#,
821        )
822        .unwrap();
823        assert_eq!(h[0].role_type, RoleType::RolesAtHq);
824    }
825
826    #[test]
827    fn test_parse_structures_and_starbases() {
828        let s: Vec<CorporationStructure> = serde_json::from_str(
829            r#"[{"corporation_id": 98000001, "profile_id": 1, "state": "shield_vulnerable",
830                 "structure_id": 1040000000000, "system_id": 30000142, "type_id": 35832,
831                 "services": [{"name": "Market", "state": "online"}]},
832                {"corporation_id": 98000001, "profile_id": 1, "state": "something_new",
833                 "structure_id": 1, "system_id": 1, "type_id": 1}]"#,
834        )
835        .unwrap();
836        assert_eq!(s[0].structure_id, 1_040_000_000_000);
837        assert_eq!(s[0].services[0].state, ServiceState::Online);
838        assert_eq!(s[1].state, StructureState::Unrecognized);
839        let d: StarbaseDetails = serde_json::from_str(
840            r#"{"allow_alliance_members": true, "allow_corporation_members": true,
841                "anchor": "alliance_member", "attack_if_at_war": false,
842                "attack_if_other_security_status_dropping": false,
843                "fuel_bay_take": "corporation_member", "fuel_bay_view": "corporation_member",
844                "offline": "starbase_fuel_technician_role", "online": "x", "unanchor": "alliance_member",
845                "use_alliance_standings": false, "fuels": [{"quantity": 4000000000, "type_id": 4247}]}"#,
846        )
847        .unwrap();
848        assert_eq!(d.offline, StarbasePermission::StarbaseFuelTechnicianRole);
849        assert_eq!(d.online, StarbasePermission::Unrecognized);
850        assert_eq!(d.fuels[0].quantity, 4_000_000_000);
851    }
852
853    #[test]
854    fn test_parse_misc() {
855        let d: CorporationDivisions =
856            serde_json::from_str(r#"{"hangar": [{"division": 1, "name": "Main"}]}"#).unwrap();
857        assert_eq!(d.hangar[0].division, Some(1));
858        assert!(d.wallet.is_empty());
859        let l: Vec<ContainerLogEntry> = serde_json::from_str(
860            r#"[{"action": "enter_password", "character_id": 1, "container_id": 1000000000000,
861                 "container_type_id": 17366, "location_flag": "CorpSAG1", "location_id": 2,
862                 "logged_at": "t", "password_type": "config"}]"#,
863        )
864        .unwrap();
865        assert_eq!(l[0].action, ContainerAction::EnterPassword);
866        let t: Vec<CorporationTitle> =
867            serde_json::from_str(r#"[{"title_id": 1, "name": "CEO", "roles": ["Director"]}]"#)
868                .unwrap();
869        assert_eq!(t[0].roles, vec![CorporationRole::Director]);
870        let sh: Vec<Shareholder> = serde_json::from_str(
871            r#"[{"share_count": 5000000000, "shareholder_id": 1, "shareholder_type": "character"}]"#,
872        )
873        .unwrap();
874        assert_eq!(sh[0].share_count, 5_000_000_000);
875    }
876}