d_id/endpoints/resources/
credits.rs1use super::*;
5
6
7const CREDITS_PATH: &str = "/credits";
8
9#[derive(Serialize, Deserialize, Debug)]
10pub struct CreditResponse {
11 credits: Vec<Info>,
12 remaining: i64,
13 total: i64,
14}
15
16#[derive(Serialize, Deserialize, Debug)]
17pub struct Info {
18 owner_id: String,
19 expire_at: String,
20 created_at: String,
21 remaining: i64,
22 valid_from: String,
23 total: i64,
24 product_id: String,
25 modified_at: String,
26}
27
28pub async fn get_credits() -> Result<CreditResponse> {
29 let c = ClientBuilder::new()?
30 .method(GET)?
31 .path(CREDITS_PATH)?
32 .header(CONTENT_TYPE, APPLICATION_JSON)?
33 .build()?;
34
35 let resp = c.send_request(Empty::<Bytes>::new()).await?;
36
37 let credits = serde_json::from_slice::<CreditResponse>(&resp.as_ref())?;
38
39 Ok(credits)
40}