Parse responses from package API call

Only positive responses so far. Error handling is not implemented yet.

Contributes to issue CURA-8556.
This commit is contained in:
Ghostkeeper 2021-10-21 16:02:46 +02:00
parent 3138452f94
commit 6415a2649e
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
2 changed files with 22 additions and 5 deletions

View file

@ -76,7 +76,14 @@ class PackageList(ListModel):
This converts that response into PackageModels, and triggers the ListModel to update.
:param reply: A reply containing information about a number of packages.
"""
pass # TODO: Parse reply dictionary.
response_data = HttpRequestManager.readJSON(reply)
if "data" not in response_data:
return # TODO: Handle invalid response.
for package_data in response_data["data"]:
package = PackageModel(package_data, parent = self)
self._packages.append(package)
self._update()
def _onError(self, reply: "QNetworkReply", error: Optional["QNetworkReply.NetworkError"]) -> None:
"""