| 1 | #include "mtx/responses/profile.hpp" |
|---|---|
| 2 | |
| 3 | #include <nlohmann/json.hpp> |
| 4 | |
| 5 | using json = nlohmann::json; |
| 6 | |
| 7 | namespace mtx { |
| 8 | namespace responses { |
| 9 | |
| 10 | void |
| 11 | from_json(const json &obj, Profile &profile) |
| 12 | { |
| 13 | if (obj.count(key: "avatar_url") != 0 && !obj.at(key: "avatar_url").is_null()) |
| 14 | profile.avatar_url = obj.at(key: "avatar_url").get<std::string>(); |
| 15 | |
| 16 | if (obj.count(key: "displayname") != 0 && !obj.at(key: "displayname").is_null()) |
| 17 | profile.display_name = obj.at(key: "displayname").get<std::string>(); |
| 18 | } |
| 19 | |
| 20 | void |
| 21 | from_json(const json &obj, AvatarUrl &avatar) |
| 22 | { |
| 23 | if (obj.count(key: "avatar_url") != 0 && !obj.at(key: "avatar_url").is_null()) |
| 24 | avatar.avatar_url = obj.at(key: "avatar_url").get<std::string>(); |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 |