diff options
author | D. Scott Boggs <scott@tams.tech> | 2023-09-29 11:30:05 -0400 |
---|---|---|
committer | D. Scott Boggs <scott@tams.tech> | 2023-09-29 11:54:31 -0400 |
commit | d7f885f5885a5325ea6239864471a7ac8159aab4 (patch) | |
tree | 052ef9c7981c2707ea36ddc620364237eaa15d5e | |
parent | 1fca2d690bae4779d63775ec6154cd8ee57ba807 (diff) |
strip /api/v1 prefix from post routes
-rw-r--r-- | src/macros.rs | 2 | ||||
-rw-r--r-- | src/mastodon.rs | 18 |
2 files changed, 14 insertions, 6 deletions
diff --git a/src/macros.rs b/src/macros.rs index c4485e3..22da7ab 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -682,7 +682,7 @@ macro_rules! post_route { &self, post_body: $body_type, ) -> Result<$return_type> { - let url = self.route($route); + let url = self.route(concat!("/api/v1/", $route)); let response = self .client .$http_method(&url) diff --git a/src/mastodon.rs b/src/mastodon.rs index 795fabb..d74be65 100644 --- a/src/mastodon.rs +++ b/src/mastodon.rs @@ -186,13 +186,21 @@ impl Mastodon { post_route! { "Update the user credentials" - [patch] update_credentials(account::Credentials)@"/api/v1/accounts/update_credentials" -> Account, + [patch] update_credentials(account::Credentials)@"accounts/update_credentials" -> Account, "Post a new status to the account." - [post] new_status(NewStatus)@"/api/v1/statuses" -> Status, - "Revoke an access token to make it no longer valid for use." - [post] revoke_auth(forms::oauth::token::Revocation)@"/oauth/revoke" -> auth::RevocationResponse, + [post] new_status(NewStatus)@"statuses" -> Status, + "Creates a user and account records." + [post] create_account(forms::account::Creation)@"accounts" -> Token, + } + ///Revoke an access token to make it no longer valid for use. + pub async fn revoke_auth( + &self, + post_body: forms::oauth::token::Revocation, + ) -> Result<auth::RevocationResponse> { + let url = self.route("/oauth/revoke"); + let response = self.client.post(&url).json(&post_body).send().await?; + read_response(response).await } - /// Edit existing status pub async fn update_status(&self, id: &StatusId, status: NewStatus) -> Result<Status> { let url = self.route(format!("/api/v1/statuses/{id}")); |