nadeo_api/request/mod.rs
1use crate::auth::AuthType;
2use crate::request::request_builder::NadeoRequestBuilder;
3use reqwest::header::HeaderMap;
4
5pub use reqwest::Method;
6pub use reqwest::Response;
7
8pub mod request_builder;
9
10pub(crate) mod metadata;
11
12/// Contains information about an API request. NadeoRequests can be executed on an instance of a [`NadeoClient`].
13/// If you want to create a request use the [`NadeoRequestBuilder`] with `NadeoRequest::builder()`.
14///
15/// # Examples
16///
17/// Gets the clubtag of a player given the *accountID*.
18/// ```rust
19/// # use reqwest::Method;
20/// # use nadeo_api::auth::AuthType;
21/// # use nadeo_api::request::NadeoRequest;
22///
23/// let mut client = //snap;
24///
25/// let request = NadeoRequest::builder()
26/// .url("https://prod.trackmania.core.nadeo.online/accounts/clubTags/?accountIdList=29e75531-1a9d-4880-98da-e2acfe17c578")
27/// .auth_type(AuthType::NadeoServices)
28/// .method(Method::GET)
29/// .build()?;
30///
31/// let response = client.execute(request).await?;
32/// ```
33///
34/// [`NadeoClient`]: crate::client::NadeoClient
35/// [`NadeoRequestBuilder`]: NadeoRequestBuilder
36
37#[derive(Debug, Clone)]
38pub struct NadeoRequest {
39 pub(crate) auth_type: AuthType,
40 pub(crate) url: String,
41 pub(crate) method: Method,
42 pub(crate) headers: HeaderMap,
43 pub(crate) body: Option<String>,
44}
45
46impl NadeoRequest {
47 /// Creates a new [`NadeoRequestBuilder`]. This is the only way of creating a [NadeoRequest].
48 ///
49 /// [`NadeoRequest`]: NadeoRequest
50 pub fn builder() -> NadeoRequestBuilder {
51 NadeoRequestBuilder::default()
52 }
53}