Browse Source

Removed REST endpoints that are not part of the API.

pull/2168/head
FeroxFoxxo 3 years ago
parent
commit
98fa344524
7 changed files with 58 additions and 76 deletions
  1. +3
    -5
      src/Discord.Net.Core/Entities/Guilds/IGuild.cs
  2. +39
    -13
      src/Discord.Net.Core/Entities/Users/IConnection.cs
  3. +3
    -36
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  4. +4
    -8
      src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs
  5. +4
    -4
      src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs
  6. +1
    -6
      src/Discord.Net.Rest/Entities/Integrations/RestIntegration.cs
  7. +4
    -4
      src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs

+ 3
- 5
src/Discord.Net.Core/Entities/Guilds/IGuild.cs View File

@@ -729,16 +729,14 @@ namespace Discord
Task<IReadOnlyCollection<IIntegration>> GetIntegrationsAsync(RequestOptions options = null);

/// <summary>
/// Creates a new integration.
/// Deletes an integration.
/// </summary>
/// <param name="id">The id for the integration.</param>
/// <param name="type">The type of integration.</param>
/// <param name="options">The options to be used when sending the request.</param>
/// <returns>
/// A task that represents the asynchronous creation operation. The task result contains the newly created
/// integration.
/// A task that represents the asynchronous removal operation.
/// </returns>
Task<IIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null);
Task DeleteIntegrationAsync(ulong id, RequestOptions options = null);

/// <summary>
/// Gets a collection of all invites in this guild.


+ 39
- 13
src/Discord.Net.Core/Entities/Users/IConnection.cs View File

@@ -4,27 +4,53 @@ namespace Discord
{
public interface IConnection
{
/// <summary> Gets the ID of the connection account. </summary>
/// <returns> A <see cref="string"/> representing the unique identifier value of this connection. </returns>
/// <summary>
/// Gets the ID of the connection account.
/// </summary>
/// <returns>
/// A <see cref="string"/> representing the unique identifier value of this connection.
/// </returns>
string Id { get; }
/// <summary> Gets the username of the connection account. </summary>
/// <returns> A string containing the name of this connection. </returns>
/// <summary>
/// Gets the username of the connection account.
/// </summary>
/// <returns>
/// A string containing the name of this connection.
/// </returns>
string Name { get; }
/// <summary> Gets the service of the connection (twitch, youtube). </summary>
/// <returns> A string containing the name of this type of connection. </returns>
/// <summary>
/// Gets the service of the connection (twitch, youtube).
/// </summary>
/// <returns>
/// A string containing the name of this type of connection.
/// </returns>
string Type { get; }
/// <summary> Gets whether the connection is revoked. </summary>
/// <returns> A value which if true indicates that this connection has been revoked, otherwise false. </returns>
/// <summary>
/// Gets whether the connection is revoked.
/// </summary>
/// <returns>
/// A value which if true indicates that this connection has been revoked, otherwise false.
/// </returns>
bool? IsRevoked { get; }
/// <summary> Gets a <see cref="IReadOnlyCollection{T}"/> of integration parials. </summary>
/// <summary>
/// Gets a <see cref="IReadOnlyCollection{T}"/> of integration parials.
/// </summary>
IReadOnlyCollection<IIntegration> Integrations { get; }
/// <summary> Gets whether the connection is verified. </summary>
/// <summary>
/// Gets whether the connection is verified.
/// </summary>
bool Verified { get; }
/// <summary> Gets whether friend sync is enabled for this connection. </summary>
/// <summary>
/// Gets whether friend sync is enabled for this connection.
/// </summary>
bool FriendSync { get; }
/// <summary> Gets whether activities related to this connection will be shown in presence updates. </summary>
/// <summary>
/// Gets whether activities related to this connection will be shown in presence updates.
/// </summary>
bool ShowActivity { get; }
/// <summary> Visibility of this connection. </summary>
/// <summary>
/// Visibility of this connection.
/// </summary>
ConnectionVisibility Visibility { get; }
}
}

+ 3
- 36
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -1626,7 +1626,7 @@ namespace Discord.API

#region Guild Integrations
/// <exception cref="ArgumentException"><paramref name="guildId"/> must not be equal to zero.</exception>
public async Task<IReadOnlyCollection<Integration>> GetGuildIntegrationsAsync(ulong guildId, RequestOptions options = null)
public async Task<IReadOnlyCollection<Integration>> GetIntegrationsAsync(ulong guildId, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
options = RequestOptions.CreateOrClone(options);
@@ -1634,47 +1634,14 @@ namespace Discord.API
var ids = new BucketIds(guildId: guildId);
return await SendAsync<IReadOnlyCollection<Integration>>("GET", () => $"guilds/{guildId}/integrations", ids, options: options).ConfigureAwait(false);
}
/// <exception cref="ArgumentException"><paramref name="guildId"/> and <paramref name="args.Id"/> must not be equal to zero.</exception>
/// <exception cref="ArgumentNullException"><paramref name="args"/> must not be <see langword="null"/>.</exception>
public async Task<Integration> CreateGuildIntegrationAsync(ulong guildId, CreateGuildIntegrationParams args, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
Preconditions.NotNull(args, nameof(args));
Preconditions.NotEqual(args.Id, 0, nameof(args.Id));
options = RequestOptions.CreateOrClone(options);

var ids = new BucketIds(guildId: guildId);
return await SendAsync<Integration>("POST", () => $"guilds/{guildId}/integrations", ids, options: options).ConfigureAwait(false);
}
public async Task<Integration> DeleteGuildIntegrationAsync(ulong guildId, ulong integrationId, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
Preconditions.NotEqual(integrationId, 0, nameof(integrationId));
options = RequestOptions.CreateOrClone(options);

var ids = new BucketIds(guildId: guildId);
return await SendAsync<Integration>("DELETE", () => $"guilds/{guildId}/integrations/{integrationId}", ids, options: options).ConfigureAwait(false);
}
public async Task<Integration> ModifyGuildIntegrationAsync(ulong guildId, ulong integrationId, Rest.ModifyGuildIntegrationParams args, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
Preconditions.NotEqual(integrationId, 0, nameof(integrationId));
Preconditions.NotNull(args, nameof(args));
Preconditions.AtLeast(args.ExpireBehavior, 0, nameof(args.ExpireBehavior));
Preconditions.AtLeast(args.ExpireGracePeriod, 0, nameof(args.ExpireGracePeriod));
options = RequestOptions.CreateOrClone(options);

var ids = new BucketIds(guildId: guildId);
return await SendJsonAsync<Integration>("PATCH", () => $"guilds/{guildId}/integrations/{integrationId}", args, ids, options: options).ConfigureAwait(false);
}
public async Task<Integration> SyncGuildIntegrationAsync(ulong guildId, ulong integrationId, RequestOptions options = null)
public async Task DeleteIntegrationAsync(ulong guildId, ulong integrationId, RequestOptions options = null)
{
Preconditions.NotEqual(guildId, 0, nameof(guildId));
Preconditions.NotEqual(integrationId, 0, nameof(integrationId));
options = RequestOptions.CreateOrClone(options);

var ids = new BucketIds(guildId: guildId);
return await SendAsync<Integration>("POST", () => $"guilds/{guildId}/integrations/{integrationId}/sync", ids, options: options).ConfigureAwait(false);
await SendAsync("DELETE", () => $"guilds/{guildId}/integrations/{integrationId}", ids, options: options).ConfigureAwait(false);
}
#endregion



+ 4
- 8
src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs View File

@@ -308,16 +308,12 @@ namespace Discord.Rest
public static async Task<IReadOnlyCollection<RestIntegration>> GetIntegrationsAsync(IGuild guild, BaseDiscordClient client,
RequestOptions options)
{
var models = await client.ApiClient.GetGuildIntegrationsAsync(guild.Id, options).ConfigureAwait(false);
var models = await client.ApiClient.GetIntegrationsAsync(guild.Id, options).ConfigureAwait(false);
return models.Select(x => RestIntegration.Create(client, guild, x)).ToImmutableArray();
}
public static async Task<RestIntegration> CreateIntegrationAsync(IGuild guild, BaseDiscordClient client,
ulong id, string type, RequestOptions options)
{
var args = new CreateGuildIntegrationParams(id, type);
var model = await client.ApiClient.CreateGuildIntegrationAsync(guild.Id, args, options).ConfigureAwait(false);
return RestIntegration.Create(client, guild, model);
}
public static async Task DeleteIntegrationAsync(IGuild guild, BaseDiscordClient client, ulong id,
RequestOptions options) =>
await client.ApiClient.DeleteIntegrationAsync(guild.Id, id, options).ConfigureAwait(false);
#endregion

#region Interactions


+ 4
- 4
src/Discord.Net.Rest/Entities/Guilds/RestGuild.cs View File

@@ -722,8 +722,8 @@ namespace Discord.Rest
#region Integrations
public Task<IReadOnlyCollection<RestIntegration>> GetIntegrationsAsync(RequestOptions options = null)
=> GuildHelper.GetIntegrationsAsync(this, Discord, options);
public Task<RestIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null)
=> GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options);
public Task DeleteIntegrationAsync(ulong id, RequestOptions options = null)
=> GuildHelper.DeleteIntegrationAsync(this, Discord, id, options);
#endregion

#region Invites
@@ -1378,8 +1378,8 @@ namespace Discord.Rest
async Task<IReadOnlyCollection<IIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options)
=> await CreateIntegrationAsync(id, type, options).ConfigureAwait(false);
async Task IGuild.DeleteIntegrationAsync(ulong id, RequestOptions options)
=> await DeleteIntegrationAsync(id, options).ConfigureAwait(false);

/// <inheritdoc />
async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options)


+ 1
- 6
src/Discord.Net.Rest/Entities/Integrations/RestIntegration.cs View File

@@ -76,12 +76,7 @@ namespace Discord.Rest
public async Task DeleteAsync()
{
await Discord.ApiClient.DeleteGuildIntegrationAsync(GuildId, Id).ConfigureAwait(false);
}

public async Task SyncAsync()
{
await Discord.ApiClient.SyncGuildIntegrationAsync(GuildId, Id).ConfigureAwait(false);
await Discord.ApiClient.DeleteIntegrationAsync(GuildId, Id).ConfigureAwait(false);
}

public override string ToString() => Name;


+ 4
- 4
src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs View File

@@ -849,8 +849,8 @@ namespace Discord.WebSocket
#region Integrations
public Task<IReadOnlyCollection<RestIntegration>> GetIntegrationsAsync(RequestOptions options = null)
=> GuildHelper.GetIntegrationsAsync(this, Discord, options);
public Task<RestIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null)
=> GuildHelper.CreateIntegrationAsync(this, Discord, id, type, options);
public Task DeleteIntegrationAsync(ulong id, RequestOptions options = null)
=> GuildHelper.DeleteIntegrationAsync(this, Discord, id, options);
#endregion

#region Interactions
@@ -1895,8 +1895,8 @@ namespace Discord.WebSocket
async Task<IReadOnlyCollection<IIntegration>> IGuild.GetIntegrationsAsync(RequestOptions options)
=> await GetIntegrationsAsync(options).ConfigureAwait(false);
/// <inheritdoc />
async Task<IIntegration> IGuild.CreateIntegrationAsync(ulong id, string type, RequestOptions options)
=> await CreateIntegrationAsync(id, type, options).ConfigureAwait(false);
async Task IGuild.DeleteIntegrationAsync(ulong id, RequestOptions options)
=> await DeleteIntegrationAsync(id, options).ConfigureAwait(false);

/// <inheritdoc />
async Task<IReadOnlyCollection<IInviteMetadata>> IGuild.GetInvitesAsync(RequestOptions options)


Loading…
Cancel
Save