romm_api/endpoints/
platforms.rs1use crate::types::Platform;
7
8use super::Endpoint;
9use serde_json::Value;
10
11#[derive(Debug, Default, Clone)]
13pub struct ListPlatforms;
14
15impl Endpoint for ListPlatforms {
16 type Output = Vec<Platform>;
17
18 fn method(&self) -> &'static str {
19 "GET"
20 }
21
22 fn path(&self) -> String {
23 "/api/platforms".into()
24 }
25}
26
27#[derive(Debug, Clone)]
29pub struct GetPlatform {
30 pub id: u64,
31}
32
33impl Endpoint for GetPlatform {
34 type Output = Platform;
35
36 fn method(&self) -> &'static str {
37 "GET"
38 }
39
40 fn path(&self) -> String {
41 format!("/api/platforms/{}", self.id)
42 }
43}
44
45#[derive(Debug, Default, Clone)]
47pub struct ListSupportedPlatforms;
48
49impl Endpoint for ListSupportedPlatforms {
50 type Output = Value;
51
52 fn method(&self) -> &'static str {
53 "GET"
54 }
55
56 fn path(&self) -> String {
57 "/api/platforms/supported".into()
58 }
59}
60
61#[derive(Debug, Clone)]
63pub struct PutPlatform {
64 pub id: u64,
65 pub body: Value,
66}
67
68impl Endpoint for PutPlatform {
69 type Output = Value;
70
71 fn method(&self) -> &'static str {
72 "PUT"
73 }
74
75 fn path(&self) -> String {
76 format!("/api/platforms/{}", self.id)
77 }
78
79 fn body(&self) -> Option<Value> {
80 Some(self.body.clone())
81 }
82}
83
84#[derive(Debug, Clone)]
86pub struct DeletePlatform {
87 pub id: u64,
88}
89
90impl Endpoint for DeletePlatform {
91 type Output = Value;
92
93 fn method(&self) -> &'static str {
94 "DELETE"
95 }
96
97 fn path(&self) -> String {
98 format!("/api/platforms/{}", self.id)
99 }
100}