use crate::client::{Client, Response};
use crate::error::Error;
use reqwest_middleware::RequestBuilder;
use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct Position {
pub coin_id: String,
pub coin_name: String,
pub position: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Person {
pub id: String,
pub name: String,
pub description: String,
pub teams_count: i32,
pub links: Value,
pub positions: Vec<Position>,
}
pub struct GetPersonRequest<'a> {
client: &'a Client,
person_id: String,
}
impl<'a> GetPersonRequest<'a> {
pub fn new(client: &'a Client, person_id: &str) -> Self {
Self {
client,
person_id: String::from(person_id),
}
}
pub async fn send(&self) -> Result<Person, Error> {
let request: RequestBuilder = self
.client
.client
.get(format!("{}/people/{}", self.client.api_url, self.person_id));
let response: Response = self.client.request(request).await?;
let data: Person = response.response.json().await?;
Ok(data)
}
}