diff options
| author | Austin Hellyer <[email protected]> | 2016-12-18 07:25:49 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-12-18 10:16:17 -0800 |
| commit | 2a743cedaf08f7eb532e3c4b795cfc5f85bc96af (patch) | |
| tree | 087dec90f8f943173c31a3dd34b7e1d9f25895e4 /src | |
| parent | Fix framework before check (diff) | |
| download | serenity-2a743cedaf08f7eb532e3c4b795cfc5f85bc96af.tar.xz serenity-2a743cedaf08f7eb532e3c4b795cfc5f85bc96af.zip | |
Fix current application decoding
The endpoint for retrieving the current application does not return a
`flags`, so don't try to decode it.
Additionally, rename `get_application_info` to
`get_current_application_info` and create a new `get_application_info`
for getting the current user's applications by Id.
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/rest/mod.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/client/rest/mod.rs b/src/client/rest/mod.rs index d44c4e2..5a03f37 100644 --- a/src/client/rest/mod.rs +++ b/src/client/rest/mod.rs @@ -896,13 +896,13 @@ pub fn get_active_maintenances() -> Result<Vec<Maintenance>> { } } -/// Gets information about an oauth2 application we own. +/// Gets information about an oauth2 application that the current user owns. /// /// **Note**: Only user accounts may use this endpoint. -pub fn get_application_info() -> Result<CurrentApplicationInfo> { - let response = request!(Route::None, get, "/oauth2/applications/@me"); +pub fn get_application_info(id: u64) -> Result<ApplicationInfo> { + let response = request!(Route::None, get, "/oauth2/applications/{}", id); - CurrentApplicationInfo::decode(serde_json::from_reader(response)?) + ApplicationInfo::decode(serde_json::from_reader(response)?) } /// Gets all oauth2 applications we've made. @@ -992,6 +992,15 @@ pub fn get_channels(guild_id: u64) -> Result<Vec<GuildChannel>> { GuildChannel::decode) } +/// Gets information about the current application. +/// +/// **Note**: Only applications may use this endpoint. +pub fn get_current_application_info() -> Result<CurrentApplicationInfo> { + let response = request!(Route::None, get, "/oauth2/applications/@me"); + + CurrentApplicationInfo::decode(serde_json::from_reader(response)?) +} + /// Gets information about the user we're connected with. pub fn get_current_user() -> Result<CurrentUser> { let response = request!(Route::UsersMe, get, "/users/@me"); |