use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize)]
pub struct Document<A> {
pub data: Resource<A>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ListDocument<A> {
pub data: Vec<Resource<A>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Resource<A> {
pub id: String,
#[serde(rename = "type")]
pub resource_type: String,
pub attributes: A,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub relationships: Option<serde_json::Value>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ResourceId {
#[serde(rename = "type")]
pub resource_type: &'static str,
pub id: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct ToOne {
pub data: ResourceId,
}
#[derive(Debug, Clone, Serialize)]
pub struct ToMany {
pub data: Vec<ResourceId>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateBody<A, R> {
pub data: CreateData<A, R>,
}
#[derive(Debug, Clone, Serialize)]
pub struct CreateData<A, R> {
#[serde(rename = "type")]
pub resource_type: &'static str,
pub attributes: A,
#[serde(skip_serializing_if = "Option::is_none")]
pub relationships: Option<R>,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateBody<A> {
pub data: UpdateData<A>,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateRelationshipsBody<R> {
pub data: UpdateRelationshipsData<R>,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateRelationshipsData<R> {
#[serde(rename = "type")]
pub resource_type: &'static str,
pub id: String,
pub relationships: R,
}
#[derive(Debug, Clone, Serialize)]
pub struct UpdateData<A> {
#[serde(rename = "type")]
pub resource_type: &'static str,
pub id: String,
pub attributes: A,
}
#[derive(Debug, Clone, Deserialize, Default)]
pub struct ErrorDocument {
#[serde(default)]
pub errors: Vec<ApiError>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ApiError {
pub status: String,
pub code: String,
pub title: String,
#[serde(default)]
pub detail: String,
}