rive_http/platform_administration/
user_safety.rs1use crate::prelude::*;
2use rive_models::{
3 data::{CreateStrikeData, EditAccountStrikeData, EditReportData, ReportContentData},
4 report::Report,
5 snapshot::Snapshot,
6 strike::AccountStrike,
7};
8
9impl Client {
10 pub async fn edit_report(
12 &self,
13 report: impl Into<String>,
14 data: EditReportData,
15 ) -> Result<Report> {
16 Ok(self
17 .client
18 .patch(ep!(self, "/safety/reports/{}", report.into()))
19 .auth(&self.authentication)
20 .json(&data)
21 .send()
22 .await?
23 .process_error()
24 .await?
25 .json()
26 .await?)
27 }
28
29 pub async fn fetch_report(&self, id: impl Into<String>) -> Result<Report> {
31 Ok(self
32 .client
33 .get(ep!(self, "/safety/report/{}", id.into()))
34 .auth(&self.authentication)
35 .send()
36 .await?
37 .process_error()
38 .await?
39 .json()
40 .await?)
41 }
42
43 pub async fn fetch_reports(&self) -> Result<Vec<Report>> {
45 Ok(self
46 .client
47 .get(ep!(self, "/safety/reports"))
48 .auth(&self.authentication)
49 .send()
50 .await?
51 .process_error()
52 .await?
53 .json()
54 .await?)
55 }
56
57 pub async fn report_content(&self, data: ReportContentData) -> Result<()> {
59 self.client
60 .post(ep!(self, "/safety/report"))
61 .json(&data)
62 .auth(&self.authentication)
63 .send()
64 .await?
65 .process_error()
66 .await?;
67 Ok(())
68 }
69
70 pub async fn fetch_snapshot(&self, report_id: impl Into<String>) -> Result<Snapshot> {
72 Ok(self
73 .client
74 .get(ep!(self, "/safety/snapshot/{}", report_id.into()))
75 .auth(&self.authentication)
76 .send()
77 .await?
78 .process_error()
79 .await?
80 .json()
81 .await?)
82 }
83
84 pub async fn create_strike(&self, data: CreateStrikeData) -> Result<AccountStrike> {
86 Ok(self
87 .client
88 .post(ep!(self, "/safety/strikes"))
89 .auth(&self.authentication)
90 .json(&data)
91 .send()
92 .await?
93 .json()
94 .await?)
95 }
96
97 pub async fn fetch_strikes(&self, user_id: impl Into<String>) -> Result<AccountStrike> {
99 Ok(self
100 .client
101 .get(ep!(self, "/safety/strikes/{}", user_id.into()))
102 .auth(&self.authentication)
103 .send()
104 .await?
105 .json()
106 .await?)
107 }
108
109 pub async fn edit_strike(
111 &self,
112 strike_id: impl Into<String>,
113 data: EditAccountStrikeData,
114 ) -> Result<()> {
115 self.client
116 .patch(ep!(self, "/safety/strikes/{}", strike_id.into()))
117 .auth(&self.authentication)
118 .json(&data)
119 .send()
120 .await?
121 .json()
122 .await?;
123 Ok(())
124 }
125
126 pub async fn delete_strike(&self, strike_id: impl Into<String>) -> Result<()> {
128 self.client
129 .delete(ep!(self, "/safety/strikes/{}", strike_id.into()))
130 .auth(&self.authentication)
131 .send()
132 .await?
133 .json()
134 .await?;
135 Ok(())
136 }
137}