refreshSession method

Future<SessionRefresh?> refreshSession(
  1. String sessionId, {
  2. RefreshSessionRequest? refreshSessionRequest,
})

Refresh a session

Refreshes a session by creating a new session token. A 401 is returned when there are validation errors, which signals the SDKs to fall back to the handshake flow.

Parameters:

Implementation

Future<SessionRefresh?> refreshSession(
  String sessionId, {
  RefreshSessionRequest? refreshSessionRequest,
}) async {
  final response = await refreshSessionWithHttpInfo(
    sessionId,
    refreshSessionRequest: refreshSessionRequest,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'SessionRefresh',
    ) as SessionRefresh;
  }
  return null;
}