Skip to main content

onspring/models/
file.rs

1use bytes::Bytes;
2use chrono::{DateTime, Utc};
3use serde::Deserialize;
4
5/// Information about a file attachment.
6#[derive(Debug, Clone, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct FileInfo {
9  #[serde(rename = "type")]
10  pub file_type: Option<String>,
11  pub content_type: Option<String>,
12  pub name: Option<String>,
13  pub created_date: Option<DateTime<Utc>>,
14  pub modified_date: Option<DateTime<Utc>>,
15  pub owner: Option<String>,
16  pub notes: Option<String>,
17  pub file_href: Option<String>,
18}
19
20/// The content of a downloaded file.
21#[derive(Debug, Clone)]
22pub struct FileResponse {
23  pub content_type: Option<String>,
24  pub file_name: Option<String>,
25  pub data: Bytes,
26}
27
28/// Request to upload a file.
29#[derive(Debug, Clone)]
30pub struct SaveFileRequest {
31  pub record_id: i32,
32  pub field_id: i32,
33  pub notes: Option<String>,
34  pub modified_date: Option<DateTime<Utc>>,
35  pub file_name: String,
36  pub file_data: Vec<u8>,
37  pub content_type: String,
38}
39
40/// Response from creating a file, containing the new file ID.
41#[derive(Debug, Clone, Deserialize)]
42#[serde(rename_all = "camelCase")]
43pub struct CreatedWithIdResponse {
44  pub id: i32,
45}