queryUserByProtocol method

Future<List<ThirdPartyUser>> queryUserByProtocol(
  1. String protocol, {
  2. String? fields,
})
inherited

Retrieve a SDN User ID linked to a user on the third party service, given a set of user parameters.

protocol The name of the protocol.

fields One or more custom fields that are passed to the AS to help identify the user.

Implementation

Future<List<ThirdPartyUser>> queryUserByProtocol(String protocol,
    {String? fields}) async {
  final requestUri = Uri(
      path: '_api/client/v3/thirdparty/user/${Uri.encodeComponent(protocol)}',
      queryParameters: {
        if (fields != null) 'fields...': fields,
      });
  final request = Request('GET', baseUri!.resolveUri(requestUri));
  request.headers['authorization'] = 'Bearer ${bearerToken!}';
  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 (json as List)
      .map((v) => ThirdPartyUser.fromJson(v as Map<String, Object?>))
      .toList();
}