Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the Character Soulbinds API #165

Merged
merged 1 commit into from
Nov 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private static IServiceCollection AddProfileApiServices(this IServiceCollection
.AddTransientUsingServiceProvider<ICharacterPvpApi, IProfileApi>()
.AddTransientUsingServiceProvider<ICharacterQuestsApi, IProfileApi>()
.AddTransientUsingServiceProvider<ICharacterReputationsApi, IProfileApi>()
.AddTransientUsingServiceProvider<ICharacterSoulbindsApi, IProfileApi>()
.AddTransientUsingServiceProvider<ICharacterSpecializationsApi, IProfileApi>()
.AddTransientUsingServiceProvider<ICharacterStatisticsApi, IProfileApi>()
.AddTransientUsingServiceProvider<ICharacterTitlesApi, IProfileApi>()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Threading.Tasks;

namespace ArgentPonyWarcraftClient
{
public partial class WarcraftClient
{
/// <inheritdoc />
public async Task<RequestResult<CharacterSoulbinds>> GetCharacterSoulbindsAsync(string realmSlug, string characterName, string @namespace)
{
return await GetCharacterSoulbindsAsync(realmSlug, characterName, @namespace, _region, _locale);
}

/// <inheritdoc />
public async Task<RequestResult<CharacterSoulbinds>> GetCharacterSoulbindsAsync(string realmSlug, string characterName, string @namespace, Region region, Locale locale)
{
string host = GetHost(region);
return await GetAsync<CharacterSoulbinds>($"{host}/profile/wow/character/{realmSlug}/{characterName?.ToLowerInvariant()}/soulbinds?namespace={@namespace}&locale={locale}");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Threading.Tasks;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A client for the World of Warcraft Character Soulbinds API.
/// </summary>
public interface ICharacterSoulbindsApi
{
/// <summary>
/// Get a character's soulbinds.
/// </summary>
/// <param name="realmSlug">The slug of the realm.</param>
/// <param name="characterName">The name of the character.</param>
/// <param name="namespace">The namespace to use to locate this document.</param>
/// <returns>
/// A character's soulbinds.
/// </returns>
Task<RequestResult<CharacterSoulbinds>> GetCharacterSoulbindsAsync(string realmSlug, string characterName, string @namespace);

/// <summary>
/// Get a character's soulbinds.
/// </summary>
/// <param name="realmSlug">The slug of the realm.</param>
/// <param name="characterName">The name of the character.</param>
/// <param name="namespace">The namespace to use to locate this document.</param>
/// <param name="region">Specifies the region that the API will retrieve its data from.</param>
/// <param name="locale">Specifies the language that the result will be in.</param>
/// <returns>
/// A character's soulbinds.
/// </returns>
Task<RequestResult<CharacterSoulbinds>> GetCharacterSoulbindsAsync(string realmSlug, string characterName, string @namespace, Region region, Locale locale);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public interface IProfileApi :
ICharacterPvpApi,
ICharacterQuestsApi,
ICharacterReputationsApi,
ICharacterSoulbindsApi,
ICharacterSpecializationsApi,
ICharacterStatisticsApi,
ICharacterTitlesApi,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A reference to a conduit.
/// </summary>
public class ConduitReference
{
/// <summary>
/// Gets the key for the conduit.
/// </summary>
[JsonPropertyName("key")]
public Self Key { get; set; }

/// <summary>
/// Gets the name of the conduit.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }

/// <summary>
/// Gets the ID of the conduit.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A reference to a covenant.
/// </summary>
public class CovenantReference
{
/// <summary>
/// Gets the key for the covenant.
/// </summary>
[JsonPropertyName("key")]
public Self Key { get; set; }

/// <summary>
/// Gets the name of the covenant.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }

/// <summary>
/// Gets the ID of the covenant.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A reference to a soulbind.
/// </summary>
public class SoulbindReference
{
/// <summary>
/// Gets the key for the soulbind.
/// </summary>
[JsonPropertyName("key")]
public Self Key { get; set; }

/// <summary>
/// Gets the name of the soulbind.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }

/// <summary>
/// Gets the ID of the soulbind.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A reference to a tech talent.
/// </summary>
public class TechTalentReference
{
/// <summary>
/// Gets the key for the tech talent.
/// </summary>
[JsonPropertyName("key")]
public Self Key { get; set; }

/// <summary>
/// Gets the name of the tech talent.
/// </summary>
[JsonPropertyName("name")]
public string Name { get; set; }

/// <summary>
/// Gets the ID of the tech talent.
/// </summary>
[JsonPropertyName("id")]
public int Id { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A character's soulbinds.
/// </summary>
public class CharacterSoulbinds
{
/// <summary>
/// Gets links for the character's soulbinds.
/// </summary>
[JsonPropertyName("_links")]
public Links Links { get; set; }

/// <summary>
/// Gets a reference to the character.
/// </summary>
[JsonPropertyName("character")]
public CharacterReference Character { get; set; }

/// <summary>
/// Gets a reference to the character's chosen covenant.
/// </summary>
[JsonPropertyName("chosen_covenant")]
public CovenantReference ChosenCovenant { get; set; }

/// <summary>
/// Gets the renown level for the character with the chosen covenant.
/// </summary>
[JsonPropertyName("renown_level")]
public long RenownLevel { get; set; }

/// <summary>
/// Gets the soulbinds for the character.
/// </summary>
[JsonPropertyName("soulbinds")]
public SoulbindSelection[] Soulbinds { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// Rank details for a conduit socket.
/// </summary>
public class ConduitRank
{
/// <summary>
/// Gets a reference to the conduit.
/// </summary>
[JsonPropertyName("conduit")]
public ConduitReference Conduit { get; set; }

/// <summary>
/// Gets the rank of the socket.
/// </summary>
[JsonPropertyName("rank")]
public long Rank { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A conduit socket trait for a character.
/// </summary>
public class ConduitSocketTrait
{
/// <summary>
/// Gets the type of conduit socket.
/// </summary>
[JsonPropertyName("type")]
public EnumType Type { get; set; }

/// <summary>
/// Gets the socket details for the conduit.
/// </summary>
[JsonPropertyName("socket")]
public ConduitRank Socket { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// A soulbind selection for a character.
/// </summary>
public class SoulbindSelection
{
/// <summary>
/// Gets a reference to the soulbind.
/// </summary>
[JsonPropertyName("soulbind")]
public SoulbindReference Soulbind { get; set; }

/// <summary>
/// Gets the soulbinds and associated traits for the character.
/// </summary>
[JsonPropertyName("traits")]
public SoulbindTrait[] Traits { get; set; }

/// <summary>
/// Gets a value indicating whether the soulbind is active for this character.
/// </summary>
[JsonPropertyName("is_active")]
public bool IsActive { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Text.Json.Serialization;

namespace ArgentPonyWarcraftClient
{
/// <summary>
/// Character traits associated with a soulbind.
/// </summary>
public class SoulbindTrait
{
/// <summary>
/// Gets a reference to a tech talent selected as a trait for this character.
/// </summary>
[JsonPropertyName("trait")]
public TechTalentReference Trait { get; set; }

/// <summary>
/// Gets the tier for this trait.
/// </summary>
[JsonPropertyName("tier")]
public long Tier { get; set; }

/// <summary>
/// Gets the display order of this trait.
/// </summary>
[JsonPropertyName("display_order")]
public long DisplayOrder { get; set; }

/// <summary>
/// Gets a conduit socket for this character.
/// </summary>
[JsonPropertyName("conduit_socket")]
public ConduitSocketTrait ConduitSocket { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Threading.Tasks;
using Xunit;

namespace ArgentPonyWarcraftClient.Integration.Tests.ProfileApi
{
public class CharacterSoulbindsApiTests
{
[ResilientFact]
public async Task GetCharacterSoulbindsAsync_Gets_CharacterSoulbinds()
{
ICharacterSoulbindsApi warcraftClient = ClientFactory.BuildClient();
RequestResult<CharacterSoulbinds> result = await warcraftClient.GetCharacterSoulbindsAsync("ravencrest", "drizzy", "profile-us");
Assert.NotNull(result.Value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Threading.Tasks;
using ArgentPonyWarcraftClient.Tests.Properties;
using Xunit;

namespace ArgentPonyWarcraftClient.Tests.ProfileApi
{
public class CharacterSoulbindsApiTests
{
[Fact]
public async Task GetCharacterSoulbindsAsync_Gets_CharacterSoulbinds()
{
ICharacterSoulbindsApi warcraftClient = ClientFactory.BuildMockClient(
requestUri: "https://us.api.blizzard.com/profile/wow/character/ravencrest/drizzy/soulbinds?namespace=profile-us&locale=en_US",
responseContent: Resources.CharacterSoulbindsResponse);

RequestResult<CharacterSoulbinds> result = await warcraftClient.GetCharacterSoulbindsAsync("ravencrest", "drizzy", "profile-us");
Assert.NotNull(result.Value);
}
}
}
Loading