getChallengeResponse method

Future<ChallengeResponse> getChallengeResponse(
  1. String accountId, [
  2. int? memo,
  3. String? homeDomain,
  4. String? clientDomain,
])

Implementation

Future<ChallengeResponse> getChallengeResponse(String accountId,
    [int? memo, String? homeDomain, String? clientDomain]) async {
  if (memo != null && accountId.startsWith("M")) {
    throw NoMemoForMuxedAccountsException();
  }

  Uri serverURI = Uri.parse(_authEndpoint);
  try {
    _ChallengeRequestBuilder requestBuilder =
        new _ChallengeRequestBuilder(httpClient, serverURI);
    ChallengeResponse response = await requestBuilder
        .forAccountId(accountId)
        .forHomeDomain(homeDomain)
        .forClientDomain(clientDomain)
        .forMemo(memo)
        .execute();
    return response;
  } catch (e) {
    if (e is ErrorResponse) {
      throw new ChallengeRequestErrorResponse(e.code, e.body);
    } else {
      throw e;
    }
  }
}