Skip to main content

coinpaprika_api/people/
mod.rs

1use 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)]
8/// Position of a person
9pub struct Position {
10    pub coin_id: String,
11    pub coin_name: String,
12    pub position: String,
13}
14
15#[derive(Debug, Serialize, Deserialize)]
16/// Information about a person
17pub struct Person {
18    /// ID of person
19    pub id: String,
20
21    /// Name of person
22    pub name: String,
23
24    /// Description regarding who the person is
25    pub description: String,
26
27    /// Number of teams where person is a member
28    pub teams_count: i32,
29
30    /// Social media links
31    pub links: Value,
32
33    /// Positions the person holds in various projects
34    pub positions: Vec<Position>,
35}
36
37/// Request for getting information about a person with the specified ID, related to the
38/// cryptocurrency market. Using this endpoint you can get a description of the person, social
39/// media links, number of teams she or he is involved in and the positions in those teams.
40/// [/people/{person_id}](https://api.coinpaprika.com/#tag/People/operation/getPeopleById)
41pub 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}