Isolated API definitions to their own library

This commit is contained in:
RogueException
2016-12-23 15:10:45 -04:00
parent ca6eb6aff4
commit 8326d01f62
200 changed files with 183 additions and 73 deletions

View File

@@ -32,10 +32,10 @@ namespace Discord.Rest
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
}
public static async Task<Model> ModifyAsync(ITextChannel channel, BaseDiscordClient client,
Action<ModifyTextChannelParams> func,
Action<TextChannelProperties> func,
RequestOptions options)
{
var args = new ModifyTextChannelParams();
var args = new TextChannelProperties();
func(args);
var apiArgs = new API.Rest.ModifyTextChannelParams
{
@@ -46,10 +46,10 @@ namespace Discord.Rest
return await client.ApiClient.ModifyGuildChannelAsync(channel.Id, apiArgs, options).ConfigureAwait(false);
}
public static async Task<Model> ModifyAsync(IVoiceChannel channel, BaseDiscordClient client,
Action<ModifyVoiceChannelParams> func,
Action<VoiceChannelProperties> func,
RequestOptions options)
{
var args = new ModifyVoiceChannelParams();
var args = new VoiceChannelProperties();
func(args);
var apiArgs = new API.Rest.ModifyVoiceChannelParams
{

View File

@@ -33,7 +33,7 @@ namespace Discord.Rest
Topic = model.Topic.Value;
}
public async Task ModifyAsync(Action<ModifyTextChannelParams> func, RequestOptions options = null)
public async Task ModifyAsync(Action<TextChannelProperties> func, RequestOptions options = null)
{
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model);

View File

@@ -33,7 +33,7 @@ namespace Discord.Rest
UserLimit = model.UserLimit.Value;
}
public async Task ModifyAsync(Action<ModifyVoiceChannelParams> func, RequestOptions options = null)
public async Task ModifyAsync(Action<VoiceChannelProperties> func, RequestOptions options = null)
{
var model = await ChannelHelper.ModifyAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model);

View File

@@ -27,9 +27,9 @@ namespace Discord.Rest
AfkChannelId = args.AfkChannelId,
AfkTimeout = args.AfkTimeout,
DefaultMessageNotifications = args.DefaultMessageNotifications,
Icon = args.Icon.IsSpecified ? ImageModel.Create(args.Icon.Value) : Optional.Create<ImageModel?>(),
Icon = args.Icon.IsSpecified ? args.Icon.Value?.ToModel() : Optional.Create<ImageModel?>(),
Name = args.Name,
Splash = args.Splash.IsSpecified ? ImageModel.Create(args.Splash.Value) : Optional.Create<ImageModel?>(),
Splash = args.Splash.IsSpecified ? args.Splash.Value?.ToModel() : Optional.Create<ImageModel?>(),
Username = args.Username,
VerificationLevel = args.VerificationLevel
};
@@ -76,7 +76,7 @@ namespace Discord.Rest
return await client.ApiClient.ModifyGuildEmbedAsync(guild.Id, apiArgs, options).ConfigureAwait(false);
}
public static async Task ModifyChannelsAsync(IGuild guild, BaseDiscordClient client,
IEnumerable<ModifyGuildChannelsParams> args, RequestOptions options)
IEnumerable<GuildChannelsProperties> args, RequestOptions options)
{
var apiArgs = args.Select(x => new API.Rest.ModifyGuildChannelsParams(x.Id, x.Position));
await client.ApiClient.ModifyGuildChannelsAsync(guild.Id, apiArgs, options).ConfigureAwait(false);

View File

@@ -35,8 +35,8 @@ namespace Discord.Rest
public DateTimeOffset CreatedAt => DateTimeUtils.FromSnowflake(Id);
public ulong DefaultChannelId => Id;
public string IconUrl => API.CDN.GetGuildIconUrl(Id, IconId);
public string SplashUrl => API.CDN.GetGuildSplashUrl(Id, SplashId);
public string IconUrl => CDN.GetGuildIconUrl(Id, IconId);
public string SplashUrl => CDN.GetGuildSplashUrl(Id, SplashId);
public RestRole EveryoneRole => GetRole(Id);
public IReadOnlyCollection<RestRole> Roles => _roles.ToReadOnlyCollection();
@@ -115,7 +115,7 @@ namespace Discord.Rest
var model = await GuildHelper.ModifyEmbedAsync(this, Discord, func, options).ConfigureAwait(false);
Update(model);
}
public async Task ModifyChannelsAsync(IEnumerable<ModifyGuildChannelsParams> args, RequestOptions options = null)
public async Task ModifyChannelsAsync(IEnumerable<GuildChannelsProperties> args, RequestOptions options = null)
{
var arr = args.ToArray();
await GuildHelper.ModifyChannelsAsync(this, Discord, arr, options);

View File

@@ -15,7 +15,7 @@ namespace Discord.Rest
public GuildPermissions Permissions { get; private set; }
public DateTimeOffset CreatedAt => DateTimeUtils.FromSnowflake(Id);
public string IconUrl => API.CDN.GetGuildIconUrl(Id, _iconId);
public string IconUrl => CDN.GetGuildIconUrl(Id, _iconId);
internal RestUserGuild(BaseDiscordClient discord, ulong id)
: base(discord, id)

View File

@@ -18,7 +18,7 @@ namespace Discord.Rest
public IUser Owner { get; private set; }
public DateTimeOffset CreatedAt => DateTimeUtils.FromSnowflake(Id);
public string IconUrl => API.CDN.GetApplicationIconUrl(Id, _iconId);
public string IconUrl => CDN.GetApplicationIconUrl(Id, _iconId);
internal RestApplication(BaseDiscordClient discord, ulong id)
: base(discord, id)

View File

@@ -13,7 +13,7 @@ namespace Discord.Rest
public ushort DiscriminatorValue { get; private set; }
public string AvatarId { get; private set; }
public string AvatarUrl => API.CDN.GetUserAvatarUrl(Id, AvatarId);
public string AvatarUrl => CDN.GetUserAvatarUrl(Id, AvatarId);
public DateTimeOffset CreatedAt => DateTimeUtils.FromSnowflake(Id);
public string Discriminator => DiscriminatorValue.ToString("D4");
public string Mention => MentionUtils.MentionUser(Id);

View File

@@ -16,7 +16,7 @@ namespace Discord.Rest
func(args);
var apiArgs = new API.Rest.ModifyCurrentUserParams
{
Avatar = args.Avatar.IsSpecified ? ImageModel.Create(args.Avatar.Value) : Optional.Create<ImageModel?>(),
Avatar = args.Avatar.IsSpecified ? args.Avatar.Value?.ToModel() : Optional.Create<ImageModel?>(),
Username = args.Username
};