Skip to content

Commit 0bad178

Browse files
committed
fix: incorrect API call and general cleanup
1 parent c29ddaf commit 0bad178

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/Classes/APIContractBuilds.lua

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ local EndpointType = {
3636
---@field buildId string
3737

3838
--- This data is saved internally for caching
39+
--- Save this to disk for temporary local caching if required/desired
3940
---@class BuildInfoCache
4041
---@field pobdata string
4142
---@field name string
@@ -48,11 +49,11 @@ local EndpointType = {
4849
---@field name string
4950
---@field fallbackVersion integer
5051
---@field endpointType EndpointType
51-
---@field baseAPIPath string
52-
---@field league_filter boolean
53-
---@field gem_filter boolean
52+
---@field baseAPIPath? string
53+
---@field league_filter? boolean
54+
---@field gem_filter? boolean
5455

55-
---This primarily exists for the lua language server
56+
--- This primarily exists for the lua language server
5657
---@param buildInfo BuildInfo
5758
---@param source APICapabilities
5859
---@return BuildInfoCache
@@ -81,15 +82,14 @@ local getBuildVersions = {
8182
[0] = function(...) return APIContractBuilds:GetBuildsVersion1(...) end,
8283
}
8384

84-
---comments
85-
---@param path string
85+
--- Gets the builds from the source
8686
---@param source APISourceInfo
87-
function APIContractBuilds:GetBuilds(path, source)
88-
local builds = getBuildVersions[source.fallbackVersion](path, source.endpointType)
87+
function APIContractBuilds:GetBuilds(source)
88+
getBuildVersions[source.fallbackVersion](source.endpointType)
8989
end
9090

9191
---@param source APISourceInfo
92-
function APIContractBuilds:GetAPICapabilities(source)
92+
function APIContractBuilds:UpdateAPICapabilities(source)
9393
-- TODO: Which features are supported?
9494
-- What is the latest version that is supported?
9595
-- Which endpoints are supported
@@ -103,6 +103,7 @@ function APIContractBuilds:GetAPICapabilities(source)
103103
function(...) return APIContractBuilds:APICapabilitiesCallback(source, ...) end, {})
104104
end
105105

106+
--- Updates the API capabilities for the source
106107
---@param response table
107108
---@param errMsg any
108109
---@param source APISourceInfo
@@ -119,6 +120,7 @@ function APIContractBuilds:APICapabilitiesCallback(source, response, errMsg)
119120
self.apiCapabilities[source.name] = parsedResponse
120121
end
121122

123+
--- Adds/Updates Builds for the source based on version 1
122124
---@param response table
123125
---@param errMsg any
124126
---@param source APICapabilities
@@ -132,15 +134,15 @@ function APIContractBuilds:BuildsVersion1Callback(source, response, errMsg)
132134
end
133135
end
134136

135-
---Version 1 of the API Contract for Builds
136-
---@param path string
137+
--- Version 1 of the API Contract for Builds
137138
---@param source APICapabilities
138-
function APIContractBuilds:GetBuildsVersion1(path, source)
139-
if source.endpointType ~= EndpointType.REST then
139+
function APIContractBuilds:GetBuildsVersion1(source)
140+
if source.endpointType == EndpointType.CSV then
141+
-- TODO: Implement CSV Parsing and Format
140142
return
141143
end
142144

143-
launch:DownloadPage(source.baseAPIPath + path, function(...)
145+
launch:DownloadPage(source.baseAPIPath + "/v1/builds", function(...)
144146
self:BuildsVersion1Callback(source, ...)
145147
end, {})
146148
end

0 commit comments

Comments
 (0)