1use serde::Deserialize;
2
3#[derive(Debug, Clone, Deserialize)]
7pub struct FileObject {
8 pub id: String,
10 #[serde(default)]
12 pub object: Option<String>,
13 #[serde(default)]
15 pub bytes: Option<i64>,
16 #[serde(default)]
18 pub created_at: Option<i64>,
19 #[serde(default)]
21 pub filename: Option<String>,
22 #[serde(default)]
24 pub purpose: Option<String>,
25 #[serde(default)]
27 pub status: Option<String>,
28 #[serde(default)]
30 pub deleted: Option<bool>,
31}
32
33#[derive(Debug, Clone, Deserialize)]
35pub struct FileList {
36 #[serde(default)]
38 pub object: Option<String>,
39 #[serde(default)]
41 pub data: Vec<FileObject>,
42}
43
44#[derive(Debug, Clone)]
46pub struct FileUploadParams {
47 pub file: Vec<u8>,
49 pub filename: Option<String>,
51 pub purpose: String,
53}
54
55#[derive(Debug, Clone, Default)]
57pub struct FileListParams {
58 pub purpose: Option<String>,
60 pub limit: Option<u32>,
62 pub after: Option<String>,
64}
65
66impl FileListParams {
67 pub(crate) fn query(&self) -> Vec<(String, String)> {
68 let mut q = Vec::new();
69 if let Some(p) = &self.purpose {
70 q.push(("purpose".to_owned(), p.clone()));
71 }
72 if let Some(l) = self.limit {
73 q.push(("limit".to_owned(), l.to_string()));
74 }
75 if let Some(a) = &self.after {
76 q.push(("after".to_owned(), a.clone()));
77 }
78 q
79 }
80}