use serde::{Deserialize, Serialize};
#[cfg(any(feature = "web-sys"))]
use web_sys::{Blob, File, FormData};
#[derive(Deserialize, Debug, Serialize)]
pub struct Fields {
pub(crate) fields: Vec<String>,
}
impl Default for Fields {
fn default() -> Self {
let field_list = vec![
"from",
"id",
"message_tags",
"story",
"story_tags",
"permalink_url",
"message",
"shares",
"comments",
"likes",
"reactions",
];
let fields = field_list.iter().map(|&field| field.into()).collect();
Self { fields }
}
}
#[derive(Deserialize, Debug, Serialize)]
pub struct GetPostResponse {
pub id: String,
pub message: String,
pub from: From,
pub permalink_url: String,
}
#[derive(Deserialize, Debug, Default, Serialize)]
pub struct Id {
pub id: String,
}
#[derive(Deserialize, Debug, Serialize)]
pub struct From {
pub id: String,
pub name: String,
}
pub struct PostByLinkParams {
file_url: String,
}
#[derive(Clone, Deserialize, Debug, Serialize, Default)]
pub struct UploadingData {
pub file_path: String,
pub end_offset: u64,
pub start_offset: u64,
pub upload_phase: String,
pub upload_session_id: String,
}
impl UploadingData {
pub fn new(
file_path: String,
end_offset: u64,
start_offset: u64,
upload_phase: String,
upload_session_id: String,
) -> Self {
UploadingData {
file_path,
end_offset,
start_offset,
upload_phase,
upload_session_id,
}
}
}
#[derive(Deserialize, Debug, Serialize)]
pub struct PostResponse {
id: String,
}
#[derive(Deserialize, Clone, Serialize)]
pub struct ChunksUploadResponse {
pub start_offset: String, pub end_offset: String,
}
impl ChunksUploadResponse {
pub fn new(start_offset: String, end_offset: String) -> ChunksUploadResponse {
ChunksUploadResponse {
start_offset,
end_offset,
}
}
pub fn end_offset(self) -> String {
self.end_offset
}
pub fn start_offset(self) -> String {
self.start_offset
}
}