pub struct Esi {
pub access_token: Option<String>,
pub access_expiration: Option<i64>,
pub refresh_token: Option<String>,
/* private fields */
}Expand description
Struct to interact with ESI.
Construct an instance of this struct using EsiBuilder.
§Example
use rfesi::prelude::EsiBuilder;
// the struct must be mutable for some functionality
let mut esi = EsiBuilder::new()
.user_agent("some user agent")
.client_id("your_client_id")
.client_secret("your_client_secret")
.callback_url("your_callback_url")
.build()
.unwrap();Fields§
§access_token: Option<String>The access token from ESI, if set.
access_expiration: Option<i64>The millisecond unix timestamp after which the access token expires, if present.
refresh_token: Option<String>The refresh token from ESI, if set.
Implementations§
Source§impl Esi
impl Esi
Sourcepub async fn update_spec(&mut self) -> EsiResult<()>
pub async fn update_spec(&mut self) -> EsiResult<()>
Get the Swagger spec from ESI and store it in this struct.
If you are making use of the try_get_endpoint_for_op_id,
then this function will be called there when needed
(which should only really be when the struct is
constructed unless the struct is kept in memory for a very
long time). When using get_endpoint_for_op_id however,
you are responsible for calling this function beforehand.
§Example
esi.update_spec().await.unwrap();Generate and return the URL required for the user to grant you an auth code, as wells as infos for future authentication request.
You can inspect the URL returned by ESI to your web service to ensure it matches.
No checking is done by rfesi.
§Example
let auth_info = esi.get_authorize_url().unwrap();
// then send your user to that URL
let url = auth_info.authorization_url;If you opted to not include client information in the EsiBuilder flow, then this function will return an error instead.
Sourcepub async fn authenticate(
&mut self,
code: &str,
pkce_verifier: Option<PkceVerifier>,
) -> EsiResult<Option<TokenClaims>>
pub async fn authenticate( &mut self, code: &str, pkce_verifier: Option<PkceVerifier>, ) -> EsiResult<Option<TokenClaims>>
Authenticate with ESI, exchanging a code from the authorize flow for an access token that is used to make authenticated calls to ESI.
Note that this is one of the functions that requires the struct be mutable, as the struct mutates to include the resulting access token.
If the “validate_jwt” feature is enabled (by default), then the access
token’s claims will be returned. If the feature is not enabled, then
the returned value will be None.
§Example (client secret)
let claims = esi.authenticate("abcdef...", None).await.unwrap();§Example (PKCE/Application authentication)
async fn run() {Sourcepub async fn use_refresh_token(&mut self, refresh_token: &str) -> EsiResult<()>
pub async fn use_refresh_token(&mut self, refresh_token: &str) -> EsiResult<()>
Authenticate via a previously-fetched refresh token.
The functionality of a refresh token allows re-authenticating this struct
instance without prompting the user to log into EVE SSO again. When the user
is authenticated in that manner, a refresh token is returned and available
via the refresh_token struct field. Store this securely should you wish
to later make authenticate calls for that user.
§Example
esi.use_refresh_token("abcdef...").await.unwrap();Sourcepub async fn refresh_access_token(
&mut self,
refresh_token: Option<&str>,
) -> EsiResult<()>
pub async fn refresh_access_token( &mut self, refresh_token: Option<&str>, ) -> EsiResult<()>
Authenticate via a refresh token given as input, or using the internal refresh_token if it’s available.
The functionality of a refresh token allows re-authenticating this struct
instance without prompting the user to log into EVE SSO again. When the user
is authenticated in that manner, a refresh token is returned and available
via the refresh_token struct field. Store this securely should you wish
to later make authenticate calls for that user.
§Example with internal token
esi.refresh_access_token(None).await.unwrap();§Example with input token
esi.refresh_access_token(Some("MyRefreshToken")).await.unwrap();Sourcepub async fn query<T: DeserializeOwned>(
&self,
method: &str,
request_type: RequestType,
endpoint: &str,
query: Option<&[(&str, &str)]>,
body: Option<&str>,
) -> EsiResult<T>
pub async fn query<T: DeserializeOwned>( &self, method: &str, request_type: RequestType, endpoint: &str, query: Option<&[(&str, &str)]>, body: Option<&str>, ) -> EsiResult<T>
Make a request to ESI.
This is mainly used as the underlying function for this library when making calls to ESI; the other functions that you should primarily be using contain more functionality, including matching endpoint with deserialization struct, evaluating & replacing URL parameters, etc.
In the event that there is not a wrapper function for the endpoint that you want to use, you can use this function to make an API call without waiting for the library to be updated.
§Example
#[derive(Deserialize)]
struct ReturnedData {}
let data: ReturnedData = esi.query("GET", RequestType::Public, "abc", None, None).await.unwrap();Sourcepub async fn try_get_endpoint_for_op_id(
&mut self,
op_id: &str,
) -> EsiResult<String>
pub async fn try_get_endpoint_for_op_id( &mut self, op_id: &str, ) -> EsiResult<String>
Resolve an operationId to a URL path utilizing the Swagger spec.
If the spec has not yet been retrieved when calling this function,
an API call will be made to ESI to fetch that data (thus the
async signature of this function). If you don’t need that help (by
explicitly making a call to update_spec prior) then you can use
the get_endpoint_for_op_id function, which is synchronous.
Note that when making use of this function along with query, you
are responsible for resolving any/all URL parameters that the endpoint
may contain.
§Example
let endpoint = esi
.try_get_endpoint_for_op_id("get_alliances_alliance_id_contacts_labels")
.await
.unwrap();Sourcepub fn get_endpoint_for_op_id(&self, op_id: &str) -> EsiResult<String>
pub fn get_endpoint_for_op_id(&self, op_id: &str) -> EsiResult<String>
Resolve an operationId to a URL path utilizing the Swagger spec.
If the spec has not yet been retrieved when calling this function, this function will return an error.
Note that when making use of this function along with query, you
are responsible for resolving any/all URL parameters that the endpoint
may contain.
§Example
let endpoint = esi.get_endpoint_for_op_id("get_alliances_alliance_id_contacts_labels").unwrap();Sourcepub async fn is_error_limited(&self) -> Result<ErrorLimitStatus, EsiError>
pub async fn is_error_limited(&self) -> Result<ErrorLimitStatus, EsiError>
Returns whether we have temporarily encountered the error limit due to too many failed responses.
If this returns true, then this client will refuse to process further requests.
Sourcepub fn get_spec(&self) -> Option<&Spec>
pub fn get_spec(&self) -> Option<&Spec>
Retrieve this struct’s OpenAPI specification.
Use in tandem with EsiBuilder::spec.
Sourcepub fn group_alliance(&self) -> AllianceGroup<'_>
pub fn group_alliance(&self) -> AllianceGroup<'_>
Call endpoints under the “alliance” group in ESI.
Sourcepub fn group_assets(&self) -> AssetsGroup<'_>
pub fn group_assets(&self) -> AssetsGroup<'_>
Call endpoints under the “Assets” group in ESI.
Sourcepub fn group_bookmarks(&self) -> BookmarksGroup<'_>
pub fn group_bookmarks(&self) -> BookmarksGroup<'_>
Call endpoints under the “Bookmarks” group in ESI.
Sourcepub fn group_calendar(&self) -> CalendarGroup<'_>
pub fn group_calendar(&self) -> CalendarGroup<'_>
Call endpoints under the “Calendar” group in ESI.
Sourcepub fn group_character(&self) -> CharacterGroup<'_>
pub fn group_character(&self) -> CharacterGroup<'_>
Call endpoints under the “Character” group in ESI.
Sourcepub fn group_clones(&self) -> ClonesGroup<'_>
pub fn group_clones(&self) -> ClonesGroup<'_>
Call endpoints under the “Clones” group in ESI.
Sourcepub fn group_contacts(&self) -> ContactsGroup<'_>
pub fn group_contacts(&self) -> ContactsGroup<'_>
Call endpoints under the “Contacts” group in ESI.
Sourcepub fn group_contracts(&self) -> ContractsGroup<'_>
pub fn group_contracts(&self) -> ContractsGroup<'_>
Call endpoints under the “Contracts” group in ESI.
Sourcepub fn group_corporation(&self) -> CorporationGroup<'_>
pub fn group_corporation(&self) -> CorporationGroup<'_>
Call endpoints under the “Corporation” group in ESI.
Sourcepub fn group_dogma(&self) -> DogmaGroup<'_>
pub fn group_dogma(&self) -> DogmaGroup<'_>
Call endpoints under the “Dogma” group in ESI.
Sourcepub fn group_faction_warfare(&self) -> FactionWarfareGroup<'_>
pub fn group_faction_warfare(&self) -> FactionWarfareGroup<'_>
Call endpoints under the “FactionWarfare” group in ESI.
Sourcepub fn group_fittings(&self) -> FittingsGroup<'_>
pub fn group_fittings(&self) -> FittingsGroup<'_>
Call endpoints under the “Fittings” group in ESI.
Sourcepub fn group_fleets(&self) -> FleetsGroup<'_>
pub fn group_fleets(&self) -> FleetsGroup<'_>
Call endpoints under the “Fleets” group in ESI.
Sourcepub fn group_incursions(&self) -> IncursionsGroup<'_>
pub fn group_incursions(&self) -> IncursionsGroup<'_>
Call endpoints under the “Incursions” group in ESI.
Sourcepub fn group_industry(&self) -> IndustryGroup<'_>
pub fn group_industry(&self) -> IndustryGroup<'_>
Call endpoints under the “Industry” group in ESI.
Sourcepub fn group_insurance(&self) -> InsuranceGroup<'_>
pub fn group_insurance(&self) -> InsuranceGroup<'_>
Call endpoints under the “Insurance” group in ESI.
Sourcepub fn group_killmails(&self) -> KillmailsGroup<'_>
pub fn group_killmails(&self) -> KillmailsGroup<'_>
Call endpoints under the “Killmails” group in ESI.
Sourcepub fn group_location(&self) -> LocationGroup<'_>
pub fn group_location(&self) -> LocationGroup<'_>
Call endpoints under the “Location” group in ESI.
Sourcepub fn group_loyalty(&self) -> LoyaltyGroup<'_>
pub fn group_loyalty(&self) -> LoyaltyGroup<'_>
Call endpoints under the “Loyalty” group in ESI.
Sourcepub fn group_mail(&self) -> MailGroup<'_>
pub fn group_mail(&self) -> MailGroup<'_>
Call endpoints under the “Mail” group in ESI.
Sourcepub fn group_market(&self) -> MarketGroup<'_>
pub fn group_market(&self) -> MarketGroup<'_>
Call endpoints under the “Market” group in ESI.
Sourcepub fn group_opportunities(&self) -> OpportunitiesGroup<'_>
pub fn group_opportunities(&self) -> OpportunitiesGroup<'_>
Call endpoints under the “Opportunities” group in ESI.
Sourcepub fn group_planetary_interaction(&self) -> PlanetaryInteractionGroup<'_>
pub fn group_planetary_interaction(&self) -> PlanetaryInteractionGroup<'_>
Call endpoints under the “PlanetaryInteraction” group in ESI.
Sourcepub fn group_routes(&self) -> RoutesGroup<'_>
pub fn group_routes(&self) -> RoutesGroup<'_>
Call endpoints under the “Routes” group in ESI.
Sourcepub fn group_search(&self) -> SearchGroup<'_>
pub fn group_search(&self) -> SearchGroup<'_>
Call endpoints under the “Search” group in ESI.
Sourcepub fn group_skills(&self) -> SkillsGroup<'_>
pub fn group_skills(&self) -> SkillsGroup<'_>
Call endpoints under the “Skills” group in ESI.
Sourcepub fn group_sovereignty(&self) -> SovereigntyGroup<'_>
pub fn group_sovereignty(&self) -> SovereigntyGroup<'_>
Call endpoints under the “Sovereignty” group in ESI.
Sourcepub fn group_status(&self) -> StatusGroup<'_>
pub fn group_status(&self) -> StatusGroup<'_>
Call endpoints under the “Status” group in ESI.
Sourcepub fn group_universe(&self) -> UniverseGroup<'_>
pub fn group_universe(&self) -> UniverseGroup<'_>
Call endpoints under the “Universe” group in ESI.
Sourcepub fn group_user_interface(&self) -> UserInterfaceGroup<'_>
pub fn group_user_interface(&self) -> UserInterfaceGroup<'_>
Call endpoints under the “UserInterface” group in ESI.
Sourcepub fn group_wallet(&self) -> WalletGroup<'_>
pub fn group_wallet(&self) -> WalletGroup<'_>
Call endpoints under the “Wallet” group in ESI.
Sourcepub fn group_wars(&self) -> WarsGroup<'_>
pub fn group_wars(&self) -> WarsGroup<'_>
Call endpoints under the “Wars” group in ESI.