pinpayments/resources/
file.rs

1use time::{OffsetDateTime};
2use serde::{Deserialize};
3
4use crate::client::{Client, Response, StatusOnlyResponse};
5use crate::ids::{FileId};
6use crate::params::{unpack_contained};
7
8#[derive(Debug, Default, Deserialize)]
9pub struct File {
10    pub token: FileId,
11    pub original_filename: String,
12    pub presigned_url: String,
13
14    #[serde(with = "time::serde::iso8601::option")]
15    pub presigned_url_expires_at: Option<OffsetDateTime>,
16
17    pub purpose: String, 
18    pub size: u32,
19    pub mime_type: String,
20
21    #[serde(with = "time::serde::iso8601::option")]
22    pub uploaded_at: Option<OffsetDateTime>,
23}
24
25
26impl File {
27    pub fn retrieve(client: &Client, token: &FileId) -> Response<File> {
28        unpack_contained(client.get(&format!("/files/{}", token)))
29    }
30
31    pub fn delete(client: &Client, token: &FileId) -> StatusOnlyResponse {
32        client.delete_status_only(&format!("/files/{}", token))
33    }
34}