| @@ -0,0 +1,28 @@ | |||||
| using System.Collections.Generic; | |||||
| namespace Discord; | |||||
| public class RoleConnection | |||||
| { | |||||
| /// <summary> | |||||
| /// Gets the vanity name of the platform a bot has connected. | |||||
| /// </summary> | |||||
| public string PlatformName { get; } | |||||
| /// <summary> | |||||
| /// Gets the username on the platform a bot has connected. | |||||
| /// </summary> | |||||
| public string PlatformUsername { get; } | |||||
| /// <summary> | |||||
| /// | |||||
| /// </summary> | |||||
| public IReadOnlyDictionary<string, object> Metadata { get; } | |||||
| internal RoleConnection(string platformName, string platformUsername, IReadOnlyDictionary<string, object> metadata) | |||||
| { | |||||
| PlatformName = platformName; | |||||
| PlatformUsername = platformUsername; | |||||
| Metadata = metadata; | |||||
| } | |||||
| } | |||||
| @@ -1,4 +1,5 @@ | |||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | |||||
| namespace Discord; | namespace Discord; | ||||
| @@ -10,11 +11,11 @@ public class RoleConnectionMetadata | |||||
| public string Name{ get; } | public string Name{ get; } | ||||
| public Optional<Dictionary<string, string>> NameLocalizations { get; } | |||||
| public Optional<IReadOnlyDictionary<string, string>> NameLocalizations { get; } | |||||
| public string Description { get; } | public string Description { get; } | ||||
| public Optional<Dictionary<string, string>> DescriptionLocalizations { get; } | |||||
| public Optional<IReadOnlyDictionary<string, string>> DescriptionLocalizations { get; } | |||||
| internal RoleConnectionMetadata(RoleConnectionMetadataType type, string key, string name, string description, | internal RoleConnectionMetadata(RoleConnectionMetadataType type, string key, string name, string description, | ||||
| Dictionary<string, string> nameLocalizations = null, Dictionary<string, string> descriptionLocalizations = null) | Dictionary<string, string> nameLocalizations = null, Dictionary<string, string> descriptionLocalizations = null) | ||||
| @@ -23,7 +24,7 @@ public class RoleConnectionMetadata | |||||
| Key = key; | Key = key; | ||||
| Name = name; | Name = name; | ||||
| Description = description; | Description = description; | ||||
| NameLocalizations = nameLocalizations; | |||||
| DescriptionLocalizations = descriptionLocalizations; | |||||
| NameLocalizations = nameLocalizations.ToImmutableDictionary(); | |||||
| DescriptionLocalizations = descriptionLocalizations.ToImmutableDictionary(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,16 @@ | |||||
| using Newtonsoft.Json; | |||||
| using System.Collections.Generic; | |||||
| namespace Discord.API; | |||||
| public class RoleConnection | |||||
| { | |||||
| [JsonProperty("platform_name")] | |||||
| public Optional<string> PlatformName { get; set; } | |||||
| [JsonProperty("platform_username")] | |||||
| public Optional<string> PlatformUsername { get; set; } | |||||
| [JsonProperty("metadata")] | |||||
| public Optional<Dictionary<string, string>> Metadata { get; set; } | |||||
| } | |||||
| @@ -18,8 +18,8 @@ public class RoleConnectionMetadata | |||||
| public string Description { get; set; } | public string Description { get; set; } | ||||
| [JsonProperty("name_localizations")] | [JsonProperty("name_localizations")] | ||||
| public Optional<IEnumerable<KeyValuePair<string, string>>> NameLocalizations { get; set; } | |||||
| public Optional<IReadOnlyCollection<KeyValuePair<string, string>>> NameLocalizations { get; set; } | |||||
| [JsonProperty("description_localizations")] | [JsonProperty("description_localizations")] | ||||
| public Optional<IEnumerable<KeyValuePair<string, string>>> DescriptionLocalizations { get; set; } | |||||
| public Optional<IReadOnlyCollection<KeyValuePair<string, string>>> DescriptionLocalizations { get; set; } | |||||
| } | } | ||||
| @@ -2490,6 +2490,16 @@ namespace Discord.API | |||||
| return await SendJsonAsync<IEnumerable<RoleConnectionMetadata>>("PUT", $"/applications/{CurrentApplicationId}/role-connections/metadata", roleConnections, options: options).ConfigureAwait(false); | return await SendJsonAsync<IEnumerable<RoleConnectionMetadata>>("PUT", $"/applications/{CurrentApplicationId}/role-connections/metadata", roleConnections, options: options).ConfigureAwait(false); | ||||
| } | } | ||||
| public async Task<RoleConnection> GetUserApplicationRoleConnection(RequestOptions options = null) | |||||
| { | |||||
| return await SendAsync<RoleConnection>("GET", $"/users/@me/applications/{CurrentApplicationId}/role-connection", options: options); | |||||
| } | |||||
| public async Task<RoleConnection> GetUserApplicationRoleConnection(RoleConnection connection, RequestOptions options = null) | |||||
| { | |||||
| return await SendJsonAsync<RoleConnection>("PUT", $"/users/@me/applications/{CurrentApplicationId}/role-connection", connection, options: options); | |||||
| } | |||||
| #endregion | #endregion | ||||
| } | } | ||||
| } | } | ||||