extendSession method

Future<ExtendSuccessResponse> extendSession(
  1. String userName,
  2. String refreshToken
)

Extends a session.

Uses the refresh token provided upon logging in.

Implementation

Future<ExtendSuccessResponse> extendSession(
    String userName, String refreshToken) async {
  final uri = _urlBase.getPath(_loginEndpoint);

  final body = await JsonIsolate().encodeJson({
    'user_name': userName,
    'refreshtoken': refreshToken,
  });

  final resp = await post(uri, body: body);
  final bodyResp = await JsonIsolate().decodeJson(resp.body);
  if (resp.statusCode != 200) {
    if (bodyResp['error_code'] == 101017) {
      throw BadRefreshTokenException();
    }
    throw bodyResp['description'];
  }
  return ExtendSuccessResponse.fromJson(bodyResp);
}