[−][src]Struct rparif::client::RParifClient
Client to call HTTP API
Implementations
impl<'_> RParifClient<'_>
[src]
pub fn new(api_key: &str) -> RParifClient
[src]
pub fn new_test(api_key: &str) -> RParifClient
[src]
Constructor used for test with httpmock. It use http://localhost:5000
as URL to call mock instead of real services
Arguments
api_key
- any string
pub fn index(&self) -> Result<Vec<Index>, RParifError>
[src]
Access global pollution index for previous day, current day and next day through indice
endpoint
Errors
-
RParifError::RequestError when reqwest lib fails. It contains the underlying error.
-
RParifError::CallError when HTTP status is other than 2XX. It contains the URL called, the HTTP status and the body response
-
RParifError::UnexpectedDate if the date can't be parsed (see
convert_json_to_date
) -
RParifError::MissingJsonKey if missing JSON is missing
ìndice
-
RParifError::WrongJsonType if
ìndice
is not a number or if JSON is not as expected -
RParifError::JsonError if response isn't a well formed JSON
pub fn index_day(&self, day: Day) -> Result<Vec<Index>, RParifError>
[src]
Retrieve index pollution (global and per pollutant) for a given date (previous day, current or next day) using
indiceJour
endpoint
Arguments
day
- Which day to get indices pollution for
Errors
-
RParifError::RequestError when reqwest lib fails. It contains the underlying error.
-
RParifError::CallError when HTTP status is other than 2XX. It contains the URL called, the HTTP status and the body response
-
RParifError::MissingJsonKey if missing JSON is missing
ìndice
ordate
-
RParifError::WrongJsonType if
ìndice
is not a number or ifdate
isn't a string -
RParifError::DateParseError if
date
is not indd/mm/yyyy
format -
RParifError::JsonError if response isn't a well formed JSON
pub fn index_city(&self, cities: Vec<&str>) -> Result<Vec<Index>, RParifError>
[src]
Allow to get pollution indices for multiple cities through idxville
endpoint.
The indes is the combination of indices for all pollutants listed in index
Arguments
Errors
-
RParifError::RequestError when reqwest lib fails. It contains the underlying error.
-
RParifError::CallError when HTTP status is other than 2XX. It contains the URL called, the HTTP status and the body response
-
RParifError::UnexpectedDate if the date can't be parsed (see
convert_string_to_date
) -
RParifError::MissingJsonKey if missing JSON is missing
ninsee
orindice
-
RParifError::WrongJsonType if
ninsee
isn't a string orindice
is not a number or if JSON is not as expected -
RParifError::JsonError if response isn't a well formed JSON
pub fn episode(&self) -> Result<Vec<Episode>, RParifError>
[src]
List pollution alert for previous day, current day and next day using episode
endpoint
Errors
-
RParifError::RequestError when reqwest lib fails. It contains the underlying error.
-
RParifError::CallError when HTTP status is other than 2XX. It contains the URL called, the HTTP status and the body response
-
RParifError::UnexpectedDate if the date can't be parsed (see
convert_json_to_date
) -
RParifError::MissingJsonKey if missing JSON is missing
type
orniveau
-
RParifError::UnkownEnumValue if
type
orniveau
can't be converted into corresponding enum variant -
RParifError::WrongJsonType if
type
orniveau
is not a string or if JSON is not as expected -
RParifError::JsonError if response isn't a well formed JSON
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for RParifClient<'a>
impl<'a> Send for RParifClient<'a>
impl<'a> Sync for RParifClient<'a>
impl<'a> Unpin for RParifClient<'a>
impl<'a> !UnwindSafe for RParifClient<'a>
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>,