| 1 | /****************************************************************************** |
| 2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
| 3 | */ |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | #include <Quotient/jobs/basejob.h> |
| 8 | |
| 9 | namespace Quotient { |
| 10 | |
| 11 | /*! \brief Gets the current pushers for the authenticated user |
| 12 | * |
| 13 | * Gets all currently active pushers for the authenticated user. |
| 14 | */ |
| 15 | class QUOTIENT_API GetPushersJob : public BaseJob { |
| 16 | public: |
| 17 | // Inner data structures |
| 18 | |
| 19 | /// A dictionary of information for the pusher implementation |
| 20 | /// itself. |
| 21 | struct PusherData { |
| 22 | /// Required if `kind` is `http`. The URL to use to send |
| 23 | /// notifications to. |
| 24 | QUrl url{}; |
| 25 | /// The format to use when sending notifications to the Push |
| 26 | /// Gateway. |
| 27 | QString format{}; |
| 28 | }; |
| 29 | |
| 30 | /// Gets all currently active pushers for the authenticated user. |
| 31 | struct Pusher { |
| 32 | /// This is a unique identifier for this pusher. See `/set` for |
| 33 | /// more detail. |
| 34 | /// Max length, 512 bytes. |
| 35 | QString pushkey; |
| 36 | /// The kind of pusher. `"http"` is a pusher that |
| 37 | /// sends HTTP pokes. |
| 38 | QString kind; |
| 39 | /// This is a reverse-DNS style identifier for the application. |
| 40 | /// Max length, 64 chars. |
| 41 | QString appId; |
| 42 | /// A string that will allow the user to identify what application |
| 43 | /// owns this pusher. |
| 44 | QString appDisplayName; |
| 45 | /// A string that will allow the user to identify what device owns |
| 46 | /// this pusher. |
| 47 | QString deviceDisplayName; |
| 48 | /// The preferred language for receiving notifications (e.g. 'en' |
| 49 | /// or 'en-US') |
| 50 | QString lang; |
| 51 | /// A dictionary of information for the pusher implementation |
| 52 | /// itself. |
| 53 | PusherData data; |
| 54 | /// This string determines which set of device specific rules this |
| 55 | /// pusher executes. |
| 56 | QString profileTag{}; |
| 57 | }; |
| 58 | |
| 59 | // Construction/destruction |
| 60 | |
| 61 | /// Gets the current pushers for the authenticated user |
| 62 | explicit GetPushersJob(); |
| 63 | |
| 64 | /*! \brief Construct a URL without creating a full-fledged job object |
| 65 | * |
| 66 | * This function can be used when a URL for GetPushersJob |
| 67 | * is necessary but the job itself isn't. |
| 68 | */ |
| 69 | static QUrl makeRequestUrl(QUrl baseUrl); |
| 70 | |
| 71 | // Result properties |
| 72 | |
| 73 | /// An array containing the current pushers for the user |
| 74 | QVector<Pusher> pushers() const |
| 75 | { |
| 76 | return loadFromJson<QVector<Pusher>>(keyName: "pushers"_ls ); |
| 77 | } |
| 78 | }; |
| 79 | |
| 80 | template <> |
| 81 | struct JsonObjectConverter<GetPushersJob::PusherData> { |
| 82 | static void fillFrom(const QJsonObject& jo, |
| 83 | GetPushersJob::PusherData& result) |
| 84 | { |
| 85 | fillFromJson(jv: jo.value(key: "url"_ls ), pod&: result.url); |
| 86 | fillFromJson(jv: jo.value(key: "format"_ls ), pod&: result.format); |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | template <> |
| 91 | struct JsonObjectConverter<GetPushersJob::Pusher> { |
| 92 | static void fillFrom(const QJsonObject& jo, GetPushersJob::Pusher& result) |
| 93 | { |
| 94 | fillFromJson(jv: jo.value(key: "pushkey"_ls ), pod&: result.pushkey); |
| 95 | fillFromJson(jv: jo.value(key: "kind"_ls ), pod&: result.kind); |
| 96 | fillFromJson(jv: jo.value(key: "app_id"_ls ), pod&: result.appId); |
| 97 | fillFromJson(jv: jo.value(key: "app_display_name"_ls ), pod&: result.appDisplayName); |
| 98 | fillFromJson(jv: jo.value(key: "device_display_name"_ls ), |
| 99 | pod&: result.deviceDisplayName); |
| 100 | fillFromJson(jv: jo.value(key: "lang"_ls ), pod&: result.lang); |
| 101 | fillFromJson(jv: jo.value(key: "data"_ls ), pod&: result.data); |
| 102 | fillFromJson(jv: jo.value(key: "profile_tag"_ls ), pod&: result.profileTag); |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | /*! \brief Modify a pusher for this user on the homeserver. |
| 107 | * |
| 108 | * This endpoint allows the creation, modification and deletion of |
| 109 | * [pushers](/client-server-api/#push-notifications) for this user ID. The |
| 110 | * behaviour of this endpoint varies depending on the values in the JSON body. |
| 111 | * |
| 112 | * If `kind` is not `null`, the pusher with this `app_id` and `pushkey` |
| 113 | * for this user is updated, or it is created if it doesn't exist. If |
| 114 | * `kind` is `null`, the pusher with this `app_id` and `pushkey` for this |
| 115 | * user is deleted. |
| 116 | */ |
| 117 | class QUOTIENT_API PostPusherJob : public BaseJob { |
| 118 | public: |
| 119 | // Inner data structures |
| 120 | |
| 121 | /// Required if `kind` is not `null`. A dictionary of information |
| 122 | /// for the pusher implementation itself. If `kind` is `http`, |
| 123 | /// this should contain `url` which is the URL to use to send |
| 124 | /// notifications to. |
| 125 | struct PusherData { |
| 126 | /// Required if `kind` is `http`. The URL to use to send |
| 127 | /// notifications to. MUST be an HTTPS URL with a path of |
| 128 | /// `/_matrix/push/v1/notify`. |
| 129 | QUrl url{}; |
| 130 | /// The format to send notifications in to Push Gateways if the |
| 131 | /// `kind` is `http`. The details about what fields the |
| 132 | /// homeserver should send to the push gateway are defined in the |
| 133 | /// [Push Gateway Specification](/push-gateway-api/). Currently the only |
| 134 | /// format available is 'event_id_only'. |
| 135 | QString format{}; |
| 136 | }; |
| 137 | |
| 138 | // Construction/destruction |
| 139 | |
| 140 | /*! \brief Modify a pusher for this user on the homeserver. |
| 141 | * |
| 142 | * \param pushkey |
| 143 | * This is a unique identifier for this pusher. The value you |
| 144 | * should use for this is the routing or destination address |
| 145 | * information for the notification, for example, the APNS token |
| 146 | * for APNS or the Registration ID for GCM. If your notification |
| 147 | * client has no such concept, use any unique identifier. |
| 148 | * Max length, 512 bytes. |
| 149 | * |
| 150 | * If the `kind` is `"email"`, this is the email address to |
| 151 | * send notifications to. |
| 152 | * |
| 153 | * \param kind |
| 154 | * The kind of pusher to configure. `"http"` makes a pusher that |
| 155 | * sends HTTP pokes. `"email"` makes a pusher that emails the |
| 156 | * user with unread notifications. `null` deletes the pusher. |
| 157 | * |
| 158 | * \param appId |
| 159 | * This is a reverse-DNS style identifier for the application. |
| 160 | * It is recommended that this end with the platform, such that |
| 161 | * different platform versions get different app identifiers. |
| 162 | * Max length, 64 chars. |
| 163 | * |
| 164 | * If the `kind` is `"email"`, this is `"m.email"`. |
| 165 | * |
| 166 | * \param appDisplayName |
| 167 | * Required if `kind` is not `null`. A string that will allow the |
| 168 | * user to identify what application owns this pusher. |
| 169 | * |
| 170 | * \param deviceDisplayName |
| 171 | * Required if `kind` is not `null`. A string that will allow the |
| 172 | * user to identify what device owns this pusher. |
| 173 | * |
| 174 | * \param profileTag |
| 175 | * This string determines which set of device specific rules this |
| 176 | * pusher executes. |
| 177 | * |
| 178 | * \param lang |
| 179 | * Required if `kind` is not `null`. The preferred language for |
| 180 | * receiving notifications (e.g. 'en' or 'en-US'). |
| 181 | * |
| 182 | * \param data |
| 183 | * Required if `kind` is not `null`. A dictionary of information |
| 184 | * for the pusher implementation itself. If `kind` is `http`, |
| 185 | * this should contain `url` which is the URL to use to send |
| 186 | * notifications to. |
| 187 | * |
| 188 | * \param append |
| 189 | * If true, the homeserver should add another pusher with the |
| 190 | * given pushkey and App ID in addition to any others with |
| 191 | * different user IDs. Otherwise, the homeserver must remove any |
| 192 | * other pushers with the same App ID and pushkey for different |
| 193 | * users. The default is `false`. |
| 194 | */ |
| 195 | explicit PostPusherJob(const QString& pushkey, const QString& kind, |
| 196 | const QString& appId, |
| 197 | const QString& appDisplayName = {}, |
| 198 | const QString& deviceDisplayName = {}, |
| 199 | const QString& profileTag = {}, |
| 200 | const QString& lang = {}, |
| 201 | const Omittable<PusherData>& data = none, |
| 202 | Omittable<bool> append = none); |
| 203 | }; |
| 204 | |
| 205 | template <> |
| 206 | struct JsonObjectConverter<PostPusherJob::PusherData> { |
| 207 | static void dumpTo(QJsonObject& jo, const PostPusherJob::PusherData& pod) |
| 208 | { |
| 209 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("url" ), value: pod.url); |
| 210 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("format" ), value: pod.format); |
| 211 | } |
| 212 | }; |
| 213 | |
| 214 | } // namespace Quotient |
| 215 | |