Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Extract interface and add docs for XivApiClient
Browse files Browse the repository at this point in the history
  • Loading branch information
Tawmy committed Feb 14, 2023
1 parent 88a2dce commit a957da1
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 2 deletions.
131 changes: 131 additions & 0 deletions xivapi-cs/Interfaces/IXivApiClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using System.Threading.Tasks;
using xivapi_cs.Enums;
using xivapi_cs.ViewModels.CharacterProfile;
using xivapi_cs.ViewModels.CharacterSearch;
using xivapi_cs.ViewModels.FreeCompanyProfile;
using xivapi_cs.ViewModels.FreeCompanySearch;
using xivapi_cs.ViewModels.LinkshellProfile;
using xivapi_cs.ViewModels.LinkshellSearch;

namespace xivapi_cs.Interfaces;

public interface IXivApiClient
{
/// <summary>
/// Get a Free Company Profile by Lodestone ID.
/// </summary>
/// <param name="id">Free Company Lodestone ID.</param>
/// <param name="fetchMembers">Whether to fetch all members of the FC. Takes more time.</param>
/// <returns>ViewModel for Free Company Profile.</returns>
Task<FreeCompanyProfile?> GetFreeCompanyProfileAsync(string id, bool fetchMembers);

/// <summary>
/// Search for a Linkshell.
/// </summary>
/// <param name="name">Name of the Linkshell.</param>
/// <returns>Search result for Linkshell search.</returns>
Task<LinkshellSearch?> SearchLinkshellRegularAsync(string name);

/// <inheritdoc cref="SearchLinkshellRegularAsync(string)" />
/// <param name="homeWorld">Home World of Linkshell.</param>
Task<LinkshellSearch?> SearchLinkshellRegularAsync(string name, HomeWorld homeWorld);

/// <inheritdoc cref="SearchLinkshellRegularAsync(string, HomeWorld)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<LinkshellSearch?> SearchLinkshellRegularAsync(string name, HomeWorld homeWorld, int page);

/// <inheritdoc cref="SearchLinkshellRegularAsync(string)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<LinkshellSearch?> SearchLinkshellRegularAsync(string name, int page);

/// <summary>
/// Search for a Cross-world Linkshell.
/// </summary>
/// <param name="name">Name of the Cross-world Linkshell.</param>
/// <returns></returns>
Task<CrossworldLinkshellSearch?> SearchLinkshellCrossworldAsync(string name);

/// <inheritdoc cref="SearchLinkshellCrossworldAsync(string)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<CrossworldLinkshellSearch?> SearchLinkshellCrossworldAsync(string name, int page);

/// <summary>
/// Get a Linkshell Profile by Lodestone ID.
/// </summary>
/// <param name="id">Linkshell Lodestone ID.</param>
/// <returns>ViewModel for Linkshell.</returns>
Task<Linkshell?> GetLinkshellProfileRegularAsync(string id);

/// <inheritdoc cref="GetLinkshellProfileRegularAsync(string)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<Linkshell?> GetLinkshellProfileRegularAsync(string id, int page);

/// <summary>
/// Get a Cross-world Linkshell Profile by Lodestone ID.
/// </summary>
/// <param name="id">Cross-world Linkshell Lodestone ID.</param>
/// <returns>ViewModel for Cross-world Linkshell.</returns>
Task<CrossworldLinkshell?> GetLinkshellProfileCrossworldAsync(string id);

/// <inheritdoc cref="GetLinkshellProfileCrossworldAsync(string)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<CrossworldLinkshell?> GetLinkshellProfileCrossworldAsync(string id, int page);

/// <summary>
/// Search for a Free Company.
/// </summary>
/// <param name="name">Name of the Free Company.</param>
/// <returns>Search result for Free Company search.</returns>
Task<FreeCompanySearch?> SearchFreeCompanyAsync(string name);

/// <inheritdoc cref="SearchFreeCompanyAsync(string)" />
/// <param name="homeWorld">Home World of Free Company.</param>
Task<FreeCompanySearch?> SearchFreeCompanyAsync(string name, HomeWorld homeWorld);

/// <inheritdoc cref="SearchFreeCompanyAsync(string, HomeWorld)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<FreeCompanySearch?> SearchFreeCompanyAsync(string name, HomeWorld homeWorld, int page);

/// <inheritdoc cref="SearchFreeCompanyAsync(string)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<FreeCompanySearch?> SearchFreeCompanyAsync(string name, int page);

/// <summary>
/// Search for a Character.
/// </summary>
/// <param name="name">Name of the Character.</param>
/// <returns>Search result for Character search.</returns>
Task<CharacterSearch?> SearchCharacterAsync(string name);

/// <inheritdoc cref="SearchCharacterAsync(string)" />
/// <param name="homeWorld">Character's Home World.</param>
Task<CharacterSearch?> SearchCharacterAsync(string name, HomeWorld homeWorld);

/// <inheritdoc cref="SearchCharacterAsync(string, HomeWorld)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<CharacterSearch?> SearchCharacterAsync(string name, HomeWorld homeWorld, int page);

/// <inheritdoc cref="SearchCharacterAsync(string)" />
/// <param name="page">Which page to show. Lodestone always returns 50 results, which makes this necessary.</param>
Task<CharacterSearch?> SearchCharacterAsync(string name, int page);

/// <summary>
/// Get a Character Profile by Lodestone ID.
/// </summary>
/// <param name="id">Character Lodestone ID.</param>
/// <param name="options">Flags enum for additional data. Each makes the request take longer.</param>
/// <returns>ViewModel for Character Profile.</returns>
Task<CharacterProfile?> GetCharacterProfileAsync(int id, CharacterProfileOptions options);

/// <summary>
/// Get an Extended Character Profile by Lodestone ID.
/// </summary>
/// <remarks>
/// This shows more information than the regular character profile, but takes notably longer.
/// </remarks>
/// <param name="id">Character Lodestone ID.</param>
/// <param name="options">Flags enum for additional data. Each makes the request take longer.</param>
/// <returns>ViewModel for Extended Character Profile.</returns>
Task<CharacterProfileExtended?> GetCharacterProfileExtendedAsync(int id,
CharacterProfileOptions options);
}
5 changes: 3 additions & 2 deletions xivapi-cs/XivApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using RestSharp;
using RestSharp.Serializers.SystemTextJson;
using xivapi_cs.Enums;
using xivapi_cs.Interfaces;
using xivapi_cs.ViewModels.CharacterProfile;
using xivapi_cs.ViewModels.CharacterSearch;
using xivapi_cs.ViewModels.FreeCompanyProfile;
Expand All @@ -13,7 +14,7 @@

namespace xivapi_cs;

public class XivApiClient
public class XivApiClient : IXivApiClient
{
private readonly RestClient _client;

Expand Down Expand Up @@ -83,7 +84,7 @@ public XivApiClient()

public async Task<CrossworldLinkshellSearch?> SearchLinkshellCrossworldAsync(string name, int page)
{
return await SearchLinkshellCrossworldInternalAsync(name, null);
return await SearchLinkshellCrossworldInternalAsync(name, page);
}

private async Task<CrossworldLinkshellSearch?> SearchLinkshellCrossworldInternalAsync(string name, int? page)
Expand Down

0 comments on commit a957da1

Please sign in to comment.