[−][src]Struct rfesi::client::Esi
Struct to interact with ESI.
Construct an instance of this struct using EsiBuilder
.
Example
use rfesi::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<u64>
The expiration timestamp of the access token.
refresh_token: Option<String>
The refresh token from ESI, if set.
Implementations
impl Esi
[src]
pub async fn update_spec<'_>(&'_ mut self) -> Result<(), EsiError>
[src]
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();
pub fn get_authorize_url(&self) -> String
[src]
Generate and return the URL required for the user to grant you an auth code.
Example
let url = esi.get_authorize_url(); // then send your user to that URL
pub async fn authenticate<'_, '_>(
&'_ mut self,
code: &'_ str
) -> Result<(), EsiError>
[src]
&'_ mut self,
code: &'_ str
) -> Result<(), EsiError>
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.
Example
esi.authenticate("abcdef").await.unwrap();
pub async fn query<'_, '_, '_, '_, '_, '_, T: DeserializeOwned>(
&'_ self,
method: &'_ str,
url_base: UrlBase,
endpoint: &'_ str,
query: Option<&'_ [(&'_ str, &'_ str)]>
) -> Result<T, EsiError>
[src]
&'_ self,
method: &'_ str,
url_base: UrlBase,
endpoint: &'_ str,
query: Option<&'_ [(&'_ str, &'_ str)]>
) -> Result<T, EsiError>
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", UrlBase::Public, "abc", None).await.unwrap();
pub async fn try_get_endpoint_for_op_id<'_, '_>(
&'_ mut self,
op_id: &'_ str
) -> Result<String, EsiError>
[src]
&'_ mut self,
op_id: &'_ str
) -> Result<String, EsiError>
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();
pub fn get_endpoint_for_op_id(&self, op_id: &str) -> Result<String, EsiError>
[src]
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();
pub async fn get_whoami_info<'_>(&'_ self) -> Result<WhoAmIResponse, EsiError>
[src]
Gets information on the currently-authenticated user.
pub fn alliances(&self) -> AllianceGroup
[src]
Get endpoints under the "Alliance" group in ESI.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Esi
impl Send for Esi
impl Sync for Esi
impl Unpin for Esi
impl !UnwindSafe for Esi
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,