summaryrefslogtreecommitdiffstats
path: root/src/registration.rs
diff options
context:
space:
mode:
authorTheBestJohn <john@thebestjohn.com>2018-02-10 13:22:30 -0500
committerAaron Power <Aaronepower@users.noreply.github.com>2018-02-10 18:22:30 +0000
commitab1e5f86f03d13d44541f2ccb444877346440392 (patch)
treeeed1e24daaa3ab14148f056a4b876c86b01ff490 /src/registration.rs
parent0b5441e52c655aa5ce409a31697b22a9939914e3 (diff)
Fixed the registration of new apps as well as url of statuses is now an Option<String> (#23)
* Changes IDs to Strings for compliance with APIv1 * - Changed Scope to Scopes to coencide with a quirk of the Mastodon API. Initial registration of the app asks for "Scopes" and authorization asks for "Scope" - Swapped spaces for urlencoded spaces in the scopes serde definition to prevent broken links - url of status is returned as a Map not a string" * Fixed tests and updated Version number * Fixed tests and verified now... learning experience
Diffstat (limited to 'src/registration.rs')
-rw-r--r--src/registration.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/registration.rs b/src/registration.rs
index 9c44326..3f3a8ea 100644
--- a/src/registration.rs
+++ b/src/registration.rs
@@ -1,7 +1,7 @@
use reqwest::Client;
use super::{Error, Mastodon, Result};
-use apps::{AppBuilder, Scope};
+use apps::{AppBuilder, Scopes};
/// Handles registering your mastodon app to your instance. It is recommended
/// you cache your data struct to avoid registering on every run.
@@ -11,7 +11,7 @@ pub struct Registration {
client_id: Option<String>,
client_secret: Option<String>,
redirect: Option<String>,
- scopes: Scope,
+ scopes: Scopes,
}
#[derive(Deserialize)]
@@ -38,7 +38,7 @@ impl Registration {
client_id: None,
client_secret: None,
redirect: None,
- scopes: Scope::Read,
+ scopes: Scopes::Read,
}
}
@@ -51,12 +51,12 @@ impl Registration {
/// # }
/// # fn try() -> mammut::Result<()> {
/// use mammut::Registration;
- /// use mammut::apps::{AppBuilder, Scope};
+ /// use mammut::apps::{AppBuilder, Scopes};
///
/// let app = AppBuilder {
/// client_name: "mammut_test",
/// redirect_uris: "urn:ietf:wg:oauth:2.0:oob",
- /// scopes: Scope::Read,
+ /// scopes: Scopes::Read,
/// website: None,
/// };
///
@@ -75,7 +75,6 @@ impl Registration {
pub fn register(&mut self, app_builder: AppBuilder) -> Result<()> {
let url = format!("{}/api/v1/apps", self.base);
self.scopes = app_builder.scopes;
-
let app: OAuth = self.client.post(&url).form(&app_builder).send()?.json()?;
self.client_id = Some(app.client_id);