post3PIDs method
Adds contact information to the user's account.
This endpoint is deprecated in favour of the more specific /3pid/add
and /3pid/bind endpoints.
Note:
Previously this endpoint supported a bind parameter. This parameter
has been removed, making this endpoint behave as though it was false.
This results in this endpoint being an equivalent to /3pid/bind rather
than dual-purpose.
threePidCreds The third-party credentials to associate with the account.
returns submit_url:
An optional field containing a URL where the client must
submit the validation token to, with identical parameters
to the Identity Service API's POST /validate/email/submitToken endpoint (without the requirement
for an access token). The homeserver must send this token to the
user (if applicable), who should then be prompted to provide it
to the client.
If this field is not present, the client can assume that
verification will happen without the client's involvement
provided the homeserver advertises this specification version
in the /versions response (ie: r0.5.0).
Implementation
@deprecated
Future<Uri?> post3PIDs(ThreePidCredentials threePidCreds) async {
final requestUri = Uri(path: '_matrix/client/v3/account/3pid');
final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json';
request.bodyBytes = utf8.encode(
jsonEncode({
'three_pid_creds': threePidCreds.toJson(),
}),
);
final response = await httpClient.send(request);
final responseBody = await response.stream.toBytes();
if (response.statusCode != 200) unexpectedResponse(response, responseBody);
final responseString = utf8.decode(responseBody);
final json = jsonDecode(responseString);
return ((v) =>
v != null ? Uri.parse(v as String) : null)(json['submit_url']);
}