1 | #pragma once |
2 | |
3 | /// @file |
4 | /// @brief device related endpoints. |
5 | |
6 | #if __has_include(<nlohmann/json_fwd.hpp>) |
7 | #include <nlohmann/json_fwd.hpp> |
8 | #else |
9 | #include <nlohmann/json.hpp> |
10 | #endif |
11 | |
12 | #include "mtx/common.hpp" |
13 | #include "mtx/lightweight_error.hpp" |
14 | |
15 | #include <string> |
16 | #include <vector> |
17 | |
18 | namespace mtx { |
19 | namespace responses { |
20 | |
21 | //! Information about one of your devices. |
22 | struct Device |
23 | { |
24 | //! **Required.** Identifier of this device. |
25 | std::string device_id; |
26 | |
27 | //! Display name set by the user for this device. Absent if no name has been set. |
28 | std::string display_name; |
29 | |
30 | //! The IP address where this device was last seen. (May be a few minutes out of date, for |
31 | //! efficiency reasons). |
32 | std::string last_seen_ip; |
33 | |
34 | //! The timestamp (in milliseconds since the unix epoch) when this devices was last seen. (May |
35 | //! be a few minutes out of date, for efficiency reasons). |
36 | size_t last_seen_ts; |
37 | |
38 | friend void from_json(const nlohmann::json &obj, Device &res); |
39 | }; |
40 | |
41 | //! Response from the `GET /_matrix/client/r0/devices` endpoint. |
42 | struct QueryDevices |
43 | { |
44 | //! Gets information about all devices for the current user. |
45 | //! A list of all registered devices for this user. |
46 | // |
47 | std::vector<Device> devices; |
48 | |
49 | friend void from_json(const nlohmann::json &obj, QueryDevices &response); |
50 | }; |
51 | |
52 | } |
53 | } |
54 | |