1 | /****************************************************************************** |
2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
3 | */ |
4 | |
5 | #pragma once |
6 | |
7 | #include <Quotient/events/roomevent.h> |
8 | #include <Quotient/jobs/basejob.h> |
9 | |
10 | namespace Quotient { |
11 | |
12 | /*! \brief Listen on the event stream of a particular room. |
13 | * |
14 | * This will listen for new events related to a particular room and return |
15 | * them to the caller. This will block until an event is received, or until |
16 | * the `timeout` is reached. |
17 | * |
18 | * This API is the same as the normal `/events` endpoint, but can be |
19 | * called by users who have not joined the room. |
20 | * |
21 | * Note that the normal `/events` endpoint has been deprecated. This |
22 | * API will also be deprecated at some point, but its replacement is not |
23 | * yet known. |
24 | */ |
25 | class QUOTIENT_API PeekEventsJob : public BaseJob { |
26 | public: |
27 | /*! \brief Listen on the event stream of a particular room. |
28 | * |
29 | * \param from |
30 | * The token to stream from. This token is either from a previous |
31 | * request to this API or from the initial sync API. |
32 | * |
33 | * \param timeout |
34 | * The maximum time in milliseconds to wait for an event. |
35 | * |
36 | * \param roomId |
37 | * The room ID for which events should be returned. |
38 | */ |
39 | explicit PeekEventsJob(const QString& from = {}, |
40 | Omittable<int> timeout = none, |
41 | const QString& roomId = {}); |
42 | |
43 | /*! \brief Construct a URL without creating a full-fledged job object |
44 | * |
45 | * This function can be used when a URL for PeekEventsJob |
46 | * is necessary but the job itself isn't. |
47 | */ |
48 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& from = {}, |
49 | Omittable<int> timeout = none, |
50 | const QString& roomId = {}); |
51 | |
52 | // Result properties |
53 | |
54 | /// A token which correlates to the first value in `chunk`. This |
55 | /// is usually the same token supplied to `from=`. |
56 | QString begin() const { return loadFromJson<QString>(keyName: "start"_ls ); } |
57 | |
58 | /// A token which correlates to the last value in `chunk`. This |
59 | /// token should be used in the next request to `/events`. |
60 | QString end() const { return loadFromJson<QString>(keyName: "end"_ls ); } |
61 | |
62 | /// An array of events. |
63 | RoomEvents chunk() { return takeFromJson<RoomEvents>(key: "chunk"_ls ); } |
64 | }; |
65 | |
66 | } // namespace Quotient |
67 | |