Ruhrpottpatriot on ServiceClient
Remove superfluous compression … Add simple caching to Core proj… Move files into different folde… and 8 more (compare)
Ruhrpottpatriot on ServiceClient
Add fluent api to create HttpRe… Fix Stylecop errors Remove dead code and 3 more (compare)
Ruhrpottpatriot on NetCore2.0
Remove disabled and superseded … Delete unused leftover code fro… Move V1.Guild test to appropria… and 8 more (compare)
Ruhrpottpatriot on NetCore2.0
Update .gitignore to exclude St… Add Api builder class (compare)
Ruhrpottpatriot on master
Refactorize ServiceClient.GetHt… Merge pull request #57 from Kor… (compare)
when I was playing with the v2/account
endpoint I wrote a micro library to just pull minute details from it
using Newtonsoft.Json;
namespace DangerBot.GW2.V2.Account.Objects
{
/// <summary>This class describes a player account.</summary>
public class Account
{
/// <summary>Gets or sets the accounts id.</summary>
[JsonProperty("id")]
public string Id { get; set; }
/// <summary>Gets or sets the guild ids the character is in.</summary>
[JsonProperty("guilds")]
public string[] Guilds { get; set; }
}
}
when I wanted to pull information about it I did
using DangerBot.GW2.V2.Account.Rest;
using System.Threading.Tasks;
namespace DangerBot.GW2.V2.Account.Client
{
public partial class GW2ClientReduced
{
public async Task<Objects.Account> GetAccountAsync()
{
RestRequest restRequest = _client.Create("v2/account");
RestResponse<Objects.Account> restResponse = await restRequest.ExecuteGet<Objects.Account>().ConfigureAwait(false);
Objects.Account account = await restResponse.GetDataObject().ConfigureAwait(false);
return account;
}
}
}
in practice:
var service = GW2.V1.Guilds;
var guild = service.FindByName("The Zone of Danger");
// Too lazy to convert v2 responce to GUID...
var guildId = guild.GuildId.ToString().ToUpper();
var gw2CustomClient = new GW2ClientReduced(e.GetArg("api-key"));
var account = await gw2CustomClient.GetAccountAsync();
if (account.Guilds.Contains(guildId))
{
// blah
}
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"resource": [
"fakedata.json"
],
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Owin": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Nancy.Linker": "0.3.0"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"dependencies": {
"Nancy": "1.4.3",
"Nancy.Owin": "1.4.1"
}
}
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
var assembly = Assembly.GetExecutingAssembly();
var resourceStream = assembly.GetManifestResourceStream("MyNamespace.fakedata.json");
using (var reader = new StreamReader(resourceStream, Encoding.UTF8))
{
return reader.ReadToEnd();
}