Skip to content

Commit

Permalink
Update CurseForgeAPIHelper.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
laolarou726 committed Mar 2, 2025
1 parent 58e6952 commit cca4d98
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ProjBobcat/ProjBobcat/Class/Helper/CurseForgeAPIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ record FuzzyFingerPrintReqModel([property: JsonPropertyName("fingerprints")] IEn
[JsonSerializable(typeof(DataModel<CurseForgeAddonInfo>))]
[JsonSerializable(typeof(DataModel<CurseForgeAddonInfo[]>))]
[JsonSerializable(typeof(DataModel<CurseForgeLatestFileModel[]>))]
[JsonSerializable(typeof(DataModelWithPagination<CurseForgeLatestFileModel[]>))]
[JsonSerializable(typeof(DataModel<CurseForgeSearchCategoryModel[]>))]
[JsonSerializable(typeof(DataModel<CurseForgeFeaturedAddonModel>))]
[JsonSerializable(typeof(DataModel<CurseForgeFuzzySearchResponseModel>))]
Expand Down Expand Up @@ -102,17 +103,17 @@ public static void SetApiKey(string apiKey)
.DataModelCurseForgeAddonInfoArray))?.Data;
}

public static async Task<CurseForgeLatestFileModel[]?> GetAddonFiles(long addonId)
public static async Task<DataModelWithPagination<CurseForgeLatestFileModel[]>?> GetAddonFiles(long addonId, int index = 0, int pageSize = 50)
{
var reqUrl = $"{ApiBaseUrl ?? BaseUrl}/mods/{addonId}/files";
var reqUrl = $"{ApiBaseUrl ?? BaseUrl}/mods/{addonId}/files?index={index}&pageSize={pageSize}";

using var req = Req(HttpMethod.Get, reqUrl);
using var res = await Client.SendAsync(req);

res.EnsureSuccessStatusCode();

return (await res.Content.ReadFromJsonAsync(CurseForgeModelContext.Default
.DataModelCurseForgeLatestFileModelArray))?.Data;
return await res.Content.ReadFromJsonAsync(CurseForgeModelContext.Default
.DataModelWithPaginationCurseForgeLatestFileModelArray);
}

public static async Task<CurseForgeLatestFileModel[]?> GetFiles(IEnumerable<long> fileIds)
Expand Down

0 comments on commit cca4d98

Please sign in to comment.