libkazv
device_keys.hpp
Go to the documentation of this file.
1 /******************************************************************************
2  * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
3  */
4 
5 #pragma once
6 
7 #include "types.hpp"
8 
9 
10 namespace Kazv::Api {
12 struct DeviceKeys
13 {
14 
17  std::string userId;
18 
21  std::string deviceId;
22 
24  immer::array<std::string> algorithms;
25 
29  immer::map<std::string, std::string> keys;
30 
35  immer::map<std::string, immer::map<std::string, std::string>> signatures;
36 };
37 
38 }
39 namespace nlohmann
40 {
41 using namespace Kazv;
42 using namespace Kazv::Api;
43 template<>
44 struct adl_serializer<DeviceKeys> {
45  static void to_json(json& jo, const DeviceKeys &pod)
46  {
47  if (! jo.is_object()) { jo = json::object(); }
48 
49 
50  jo["user_id"s] = pod.userId;
51 
52  jo["device_id"s] = pod.deviceId;
53 
54  jo["algorithms"s] = pod.algorithms;
55 
56  jo["keys"s] = pod.keys;
57 
58  jo["signatures"s] = pod.signatures;
59 
60  }
61  static void from_json(const json &jo, DeviceKeys& result)
62  {
63 
64  if (jo.contains("user_id"s)) {
65  result.userId = jo.at("user_id"s);
66  }
67  if (jo.contains("device_id"s)) {
68  result.deviceId = jo.at("device_id"s);
69  }
70  if (jo.contains("algorithms"s)) {
71  result.algorithms = jo.at("algorithms"s);
72  }
73  if (jo.contains("keys"s)) {
74  result.keys = jo.at("keys"s);
75  }
76  if (jo.contains("signatures"s)) {
77  result.signatures = jo.at("signatures"s);
78  }
79 
80  }
81 };
82  }
83 
84  namespace Kazv::Api
85  {
86 } // namespace Kazv::Api
Definition: location.hpp:10
Definition: location.hpp:10
nlohmann::json json
Definition: jsonwrap.hpp:20
Definition: location.hpp:27
Device identity keys.
Definition: device_keys.hpp:13
std::string deviceId
The ID of the device these keys belong to.
Definition: device_keys.hpp:21
immer::map< std::string, immer::map< std::string, std::string > > signatures
Signatures for the device key object.
Definition: device_keys.hpp:35
std::string userId
The ID of the user the device belongs to.
Definition: device_keys.hpp:17
immer::map< std::string, std::string > keys
Public identity keys.
Definition: device_keys.hpp:29
immer::array< std::string > algorithms
The encryption algorithms supported by this device.
Definition: device_keys.hpp:24
static void from_json(const json &jo, DeviceKeys &result)
Definition: device_keys.hpp:61
static void to_json(json &jo, const DeviceKeys &pod)
Definition: device_keys.hpp:45