mastodon_api\methods/
apps.rs1use crate::MastodonClient;
2use crate::error::Result;
3use serde::{Deserialize, Serialize};
4
5pub struct AppsHandler<'a> {
7 client: &'a MastodonClient,
8}
9
10#[derive(Serialize)]
12pub struct RegisterAppParams {
13 pub client_name: String,
15 pub redirect_uris: String,
17 pub scopes: String,
19 pub website: Option<String>,
21}
22
23#[derive(Deserialize)]
25pub struct AppRegistration {
26 pub id: String,
27 pub name: String,
28 pub website: Option<String>,
29 pub redirect_uri: String,
30 pub client_id: String,
31 pub client_secret: String,
32 pub vapid_key: Option<String>,
33}
34
35impl<'a> AppsHandler<'a> {
36 pub fn new(client: &'a MastodonClient) -> Self {
37 Self { client }
38 }
39
40 pub async fn register(&self, params: &RegisterAppParams) -> Result<AppRegistration> {
50 let url = format!("{}/api/v1/apps", self.client.base_url());
51 let req = self.client.http_client().post(&url).json(params);
52 self.client.send(req).await
53 }
54}