coinpaprika_api/people/
mod.rs1use crate::client::{Client, Response};
2use crate::error::Error;
3use reqwest_middleware::RequestBuilder;
4use serde::{Deserialize, Serialize};
5use serde_json::Value;
6
7#[derive(Debug, Serialize, Deserialize)]
8pub struct Position {
10 pub coin_id: String,
11 pub coin_name: String,
12 pub position: String,
13}
14
15#[derive(Debug, Serialize, Deserialize)]
16pub struct Person {
18 pub id: String,
20
21 pub name: String,
23
24 pub description: String,
26
27 pub teams_count: i32,
29
30 pub links: Value,
32
33 pub positions: Vec<Position>,
35}
36
37pub struct GetPersonRequest<'a> {
42 client: &'a Client,
43 person_id: String,
44}
45
46impl<'a> GetPersonRequest<'a> {
47 pub fn new(client: &'a Client, person_id: &str) -> Self {
48 Self {
49 client,
50 person_id: String::from(person_id),
51 }
52 }
53
54 pub async fn send(&self) -> Result<Person, Error> {
55 let request: RequestBuilder = self
56 .client
57 .client
58 .get(format!("{}/people/{}", self.client.api_url, self.person_id));
59
60 let response: Response = self.client.request(request).await?;
61
62 let data: Person = response.response.json().await?;
63
64 Ok(data)
65 }
66}