libkazv
client_device.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 Device
13 {
14 
16  std::string deviceId;
17 
20  std::optional<std::string> displayName;
21 
24  std::optional<std::string> lastSeenIp;
25 
29  std::optional<std::int_fast64_t> lastSeenTs;
30 };
31 
32 }
33 namespace nlohmann
34 {
35 using namespace Kazv;
36 using namespace Kazv::Api;
37 template<>
38 struct adl_serializer<Device> {
39  static void to_json(json& jo, const Device &pod)
40  {
41  if (! jo.is_object()) { jo = json::object(); }
42 
43 
44  jo["device_id"s] = pod.deviceId;
45 
46 
47  addToJsonIfNeeded(jo, "display_name"s, pod.displayName);
48 
49  addToJsonIfNeeded(jo, "last_seen_ip"s, pod.lastSeenIp);
50 
51  addToJsonIfNeeded(jo, "last_seen_ts"s, pod.lastSeenTs);
52  }
53  static void from_json(const json &jo, Device& result)
54  {
55 
56  if (jo.contains("device_id"s)) {
57  result.deviceId = jo.at("device_id"s);
58  }
59  if (jo.contains("display_name"s)) {
60  result.displayName = jo.at("display_name"s);
61  }
62  if (jo.contains("last_seen_ip"s)) {
63  result.lastSeenIp = jo.at("last_seen_ip"s);
64  }
65  if (jo.contains("last_seen_ts"s)) {
66  result.lastSeenTs = jo.at("last_seen_ts"s);
67  }
68 
69  }
70 };
71  }
72 
73  namespace Kazv::Api
74  {
75 } // namespace Kazv::Api
Kazv::Api::Device::lastSeenIp
std::optional< std::string > lastSeenIp
The IP address where this device was last seen.
Definition: client_device.hpp:28
types.hpp
nlohmann
Definition: location.hpp:26
nlohmann::adl_serializer< Device >::from_json
static void from_json(const json &jo, Device &result)
Definition: client_device.hpp:53
Kazv
Definition: location.hpp:10
Kazv::Api::Device::deviceId
std::string deviceId
Identifier of this device.
Definition: client_device.hpp:20
nlohmann::adl_serializer< Device >::to_json
static void to_json(json &jo, const Device &pod)
Definition: client_device.hpp:39
Kazv::json
nlohmann::json json
Definition: jsonwrap.hpp:20
Kazv::Api
Definition: location.hpp:10
Kazv::Api::Device
A client device.
Definition: client_device.hpp:14
Kazv::addToJsonIfNeeded
void addToJsonIfNeeded(json &j, std::string name, T &&arg)
Definition: types.hpp:80
Kazv::Api::Device::displayName
std::optional< std::string > displayName
Display name set by the user for this device.
Definition: client_device.hpp:24
Kazv::Api::Device::lastSeenTs
std::optional< std::int_fast64_t > lastSeenTs
The timestamp (in milliseconds since the unix epoch) when this devices was last seen.
Definition: client_device.hpp:33