createBrokerEndpoint method
Creates a new endpoint (queue with the matching binding) in the S3I-Broker.
Use encrypted
to specify if the endpoint should indicate that decrypted
messages are expected.
Throws a NetworkAuthenticationException if
AuthenticationManager.getAccessToken fails. Throws a SocketException
if no internet connection is available. Throws a
NetworkResponseException if the received status code is not 201. Throws
a ResponseParsingException if something went wrong during the parsing
to an Endpoint.
Implementation
Future<Endpoint> createBrokerEndpoint(String thingId,
{bool encrypted = false}) async {
final Response response = await postConfig('/things/$thingId/broker',
jsonBody: <String, bool>{'encrypted': encrypted});
if (response.statusCode != 201) throw NetworkResponseException(response);
try {
return Endpoint((jsonDecode(response.body)
as Map<String, dynamic>)['queue_name'] as String);
} on TypeError catch (e) {
throw ResponseParsingException(
InvalidJsonSchemaException(e.stackTrace.toString(), response.body));
}
}