refreshToken method

Future<Session> refreshToken({
  1. required String sessionId,
  2. required String refreshToken,
})

Implementation

Future<Session> refreshToken({
  required String sessionId,
  required String refreshToken,
}) async {
  final body = <String, dynamic>{
    'refreshToken': refreshToken,
  };

  final response = await _post(
    path: '/sessions/$sessionId/refresh',
    body: body,
  );

  final json = jsonDecode(response.body);

  if (response.statusCode >= 400) {
    return Future.error(ApiError.fromJson(json));
  }

  return Session.fromJson(json);
}