-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbadgereply.cpp
43 lines (37 loc) · 1.27 KB
/
badgereply.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
SPDX-FileCopyrightText: 2018 Kamil Jakubus
SPDX-FileCopyrightText: 2022 George Florea Bănuș <georgefb899@gmail.com>
SPDX-License-Identifier: MIT
*/
#include "badgereply.hpp"
#include <QJsonArray>
namespace Twitch
{
void GlobalBadgesReply::parseData(const QJsonObject &json)
{
Twitch::Badges badges;
if (json.find(u"data"_qs) != json.end()) {
const auto &data = json[u"data"_qs].toArray();
for (const auto &badge : data) {
QList<Badge::Version> versions;
const auto &badgeVersions = badge.toObject()[u"versions"_qs].toArray();
for (const auto &versionObject : badgeVersions) {
const auto &version = versionObject.toObject();
versions.append(Badge::Version{
version[u"id"_qs].toString(),
version[u"image_url_1x"_qs].toString(),
version[u"image_url_2x"_qs].toString(),
version[u"image_url_4x"_qs].toString(),
});
}
badges.push_back(Twitch::Badge{badge[u"set_id"_qs].toString(), versions});
}
}
m_data.setValue(badges);
}
Twitch::Badges Twitch::GlobalBadgesReply::badges()
{
return m_data.value<Twitch::Badges>();
}
}
#include "moc_badgereply.cpp"