smbcloud_ascapi_core/
jsonapi.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Deserialize)]
10pub struct Document<A> {
11 pub data: Resource<A>,
12}
13
14#[derive(Debug, Clone, Deserialize)]
17pub struct ListDocument<A> {
18 pub data: Vec<Resource<A>>,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct Resource<A> {
27 pub id: String,
28 #[serde(rename = "type")]
29 pub resource_type: String,
30 pub attributes: A,
31 #[serde(default, skip_serializing_if = "Option::is_none")]
32 pub relationships: Option<serde_json::Value>,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize)]
38pub struct ResourceId {
39 #[serde(rename = "type")]
40 pub resource_type: &'static str,
41 pub id: String,
42}
43
44#[derive(Debug, Clone, Serialize)]
47pub struct ToOne {
48 pub data: ResourceId,
49}
50
51#[derive(Debug, Clone, Serialize)]
60pub struct ToMany {
61 pub data: Vec<ResourceId>,
62}
63
64#[derive(Debug, Clone, Serialize)]
65pub struct CreateBody<A, R> {
66 pub data: CreateData<A, R>,
67}
68
69#[derive(Debug, Clone, Serialize)]
70pub struct CreateData<A, R> {
71 #[serde(rename = "type")]
72 pub resource_type: &'static str,
73 pub attributes: A,
74 #[serde(skip_serializing_if = "Option::is_none")]
75 pub relationships: Option<R>,
76}
77
78#[derive(Debug, Clone, Serialize)]
79pub struct UpdateBody<A> {
80 pub data: UpdateData<A>,
81}
82
83#[derive(Debug, Clone, Serialize)]
86pub struct UpdateRelationshipsBody<R> {
87 pub data: UpdateRelationshipsData<R>,
88}
89
90#[derive(Debug, Clone, Serialize)]
91pub struct UpdateRelationshipsData<R> {
92 #[serde(rename = "type")]
93 pub resource_type: &'static str,
94 pub id: String,
95 pub relationships: R,
96}
97
98#[derive(Debug, Clone, Serialize)]
99pub struct UpdateData<A> {
100 #[serde(rename = "type")]
101 pub resource_type: &'static str,
102 pub id: String,
103 pub attributes: A,
104}
105
106#[derive(Debug, Clone, Deserialize, Default)]
108pub struct ErrorDocument {
109 #[serde(default)]
110 pub errors: Vec<ApiError>,
111}
112
113#[derive(Debug, Clone, Deserialize)]
114pub struct ApiError {
115 pub status: String,
116 pub code: String,
117 pub title: String,
118 #[serde(default)]
119 pub detail: String,
120}