1 | /****************************************************************************** |
2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
3 | */ |
4 | |
5 | #pragma once |
6 | |
7 | #include <Quotient/converters.h> |
8 | |
9 | namespace Quotient { |
10 | |
11 | struct RequestMsisdnValidation { |
12 | /// A unique string generated by the client, and used to identify the |
13 | /// validation attempt. It must be a string consisting of the characters |
14 | /// `[0-9a-zA-Z.=_-]`. Its length must not exceed 255 characters and it |
15 | /// must not be empty. |
16 | QString clientSecret; |
17 | |
18 | /// The two-letter uppercase ISO-3166-1 alpha-2 country code that the |
19 | /// number in `phone_number` should be parsed as if it were dialled from. |
20 | QString country; |
21 | |
22 | /// The phone number to validate. |
23 | QString phoneNumber; |
24 | |
25 | /// The server will only send an SMS if the `send_attempt` is a |
26 | /// number greater than the most recent one which it has seen, |
27 | /// scoped to that `country` + `phone_number` + `client_secret` |
28 | /// triple. This is to avoid repeatedly sending the same SMS in |
29 | /// the case of request retries between the POSTing user and the |
30 | /// identity server. The client should increment this value if |
31 | /// they desire a new SMS (e.g. a reminder) to be sent. |
32 | int sendAttempt; |
33 | |
34 | /// Optional. When the validation is completed, the identity server will |
35 | /// redirect the user to this URL. This option is ignored when submitting |
36 | /// 3PID validation information through a POST request. |
37 | QString nextLink{}; |
38 | }; |
39 | |
40 | template <> |
41 | struct JsonObjectConverter<RequestMsisdnValidation> { |
42 | static void dumpTo(QJsonObject& jo, const RequestMsisdnValidation& pod) |
43 | { |
44 | addParam<>(container&: jo, QStringLiteral("client_secret" ), value: pod.clientSecret); |
45 | addParam<>(container&: jo, QStringLiteral("country" ), value: pod.country); |
46 | addParam<>(container&: jo, QStringLiteral("phone_number" ), value: pod.phoneNumber); |
47 | addParam<>(container&: jo, QStringLiteral("send_attempt" ), value: pod.sendAttempt); |
48 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("next_link" ), value: pod.nextLink); |
49 | } |
50 | static void fillFrom(const QJsonObject& jo, RequestMsisdnValidation& pod) |
51 | { |
52 | fillFromJson(jv: jo.value(key: "client_secret"_ls ), pod&: pod.clientSecret); |
53 | fillFromJson(jv: jo.value(key: "country"_ls ), pod&: pod.country); |
54 | fillFromJson(jv: jo.value(key: "phone_number"_ls ), pod&: pod.phoneNumber); |
55 | fillFromJson(jv: jo.value(key: "send_attempt"_ls ), pod&: pod.sendAttempt); |
56 | fillFromJson(jv: jo.value(key: "next_link"_ls ), pod&: pod.nextLink); |
57 | } |
58 | }; |
59 | |
60 | } // namespace Quotient |
61 | |