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 pagination to EconItems#GetSchemaItemsForTF2Async() #105

Merged
merged 3 commits into from
Jul 10, 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
14 changes: 11 additions & 3 deletions src/Steam.UnitTests/EconItemsTeamFortress2Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ public EconItemsTeamFortress2Tests()
[Fact]
public async Task GetSchemaItemsForTF2Async_Should_Succeed()
{
var response = await steamInterface.GetSchemaItemsForTF2Async();
Assert.NotNull(response);
Assert.NotNull(response.Data);
uint? next = null;

do
{
var response = await steamInterface.GetSchemaItemsForTF2Async(start: next);
Assert.NotNull(response);
Assert.NotNull(response.Data);

next = response.Data.Result.Next;
}
while (next.HasValue);
}

[Fact]
Expand Down
3 changes: 2 additions & 1 deletion src/SteamWebAPI2/Interfaces/EconItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public async Task<ISteamWebResponse<EconItemResultModel>> GetPlayerItemsAsync(ul
/// </summary>
/// <param name="language"></param>
/// <returns></returns>
public async Task<ISteamWebResponse<SchemaItemsResultContainer>> GetSchemaItemsForTF2Async(string language = "en_us")
public async Task<ISteamWebResponse<SchemaItemsResultContainer>> GetSchemaItemsForTF2Async(string language = "en_us", uint? start = null)
{
if (appId != (int)AppId.TeamFortress2)
{
Expand All @@ -91,6 +91,7 @@ public async Task<ISteamWebResponse<SchemaItemsResultContainer>> GetSchemaItemsF
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();

parameters.AddIfHasValue(language, "language");
parameters.AddIfHasValue(start, "start");

var steamWebResponse = await steamWebInterface.GetAsync<SchemaItemsResultContainer>("GetSchemaItems", 1, parameters);

Expand Down
2 changes: 1 addition & 1 deletion src/SteamWebAPI2/Interfaces/IEconItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface IEconItems
{
Task<ISteamWebResponse<EconItemResultModel>> GetPlayerItemsAsync(ulong steamId);

Task<ISteamWebResponse<SteamWebAPI2.Models.GameEconomy.SchemaItemsResultContainer>> GetSchemaItemsForTF2Async(string language = "en_us");
Task<ISteamWebResponse<SteamWebAPI2.Models.GameEconomy.SchemaItemsResultContainer>> GetSchemaItemsForTF2Async(string language = "en_us", uint? start = null);

Task<ISteamWebResponse<SteamWebAPI2.Models.GameEconomy.SchemaOverviewResultContainer>> GetSchemaOverviewForTF2Async(string language = "en_us");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class SchemaItemsResult
public IList<SchemaItem> Items { get; set; }

[JsonProperty("next")]
public uint Next { get; set; }
public uint? Next { get; set; }
}

public class SchemaItemsResultContainer
Expand Down