Debian Codegraph @

mtxclient/lib/structs/responses/login.cpp

raw symbols SCIP
1 #include "mtx/responses/login.hpp"
2
3 #include <nlohmann/json.hpp>
4
5 namespace mtx {
6 namespace responses {
7
8 void
9 from_json(const nlohmann::json &obj, Login &response)
10 {
11 using namespace mtx::identifiers;
12 response.user_id = obj.at("user_id").get<User>();
13
14 response.access_token = obj.at("access_token").get<std::string>();
15
16 if (obj.count("device_id") != 0)
17 response.device_id = obj.at("device_id").get<std::string>();
18
19 if (obj.count("well_known") != 0 && obj.at("well_known").is_object())
20 response.well_known = obj.at("well_known").get<WellKnown>();
21 }
22
23 void
24 from_json(const nlohmann::json &obj, IdentityProvider &response)
25 {
26 response.brand = obj.value("brand", "");
27 response.icon = obj.value("icon", "");
28 response.id = obj.at("id").get<std::string>();
29 response.name = obj.at("name").get<std::string>();
30 }
31
32 void
33 from_json(const nlohmann::json &obj, LoginFlow &response)
34 {
35 response.type = obj.at("type").get<std::string>();
36 response.identity_providers = obj.value("identity_providers", std::vector<IdentityProvider>{});
37 }
38 void
39 from_json(const nlohmann::json &obj, LoginFlows &response)
40 {
41 response.flows = obj.at("flows").get<std::vector<LoginFlow>>();
42 }
43 }
44 }