Concrete class prototype

This commit is contained in:
RogueException
2016-09-22 21:15:37 -03:00
parent ab42129eb9
commit 6319933ed0
394 changed files with 3648 additions and 3224 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Threading.Tasks;
using Model = Discord.API.Application;
namespace Discord.Rest
{
public class RestApplication : RestEntity<ulong>, IApplication
{
protected string _iconId;
public string Name { get; private set; }
public string Description { get; private set; }
public string[] RPCOrigins { get; private set; }
public ulong Flags { get; private set; }
public IUser Owner { get; private set; }
public string IconUrl => API.CDN.GetApplicationIconUrl(Id, _iconId);
internal RestApplication(DiscordRestClient discord, ulong id)
: base(discord, id)
{
}
internal static RestApplication Create(DiscordRestClient discord, Model model)
{
var entity = new RestApplication(discord, model.Id);
entity.Update(model);
return entity;
}
internal void Update(Model model)
{
Description = model.Description;
RPCOrigins = model.RPCOrigins;
Name = model.Name;
Flags = model.Flags;
Owner = RestUser.Create(Discord, model.Owner);
_iconId = model.Icon;
}
public async Task UpdateAsync()
{
var response = await Discord.ApiClient.GetMyApplicationAsync().ConfigureAwait(false);
if (response.Id != Id)
throw new InvalidOperationException("Unable to update this object from a different application token.");
Update(response);
}
}
}