authRefresh method

Future<RecordAuth> authRefresh({
  1. String? expand,
  2. String? fields,
  3. Map<String, dynamic> body = const {},
  4. Map<String, dynamic> query = const {},
  5. Map<String, String> headers = const {},
})

Refreshes the current authenticated auth record instance and returns a new token and record data.

On success this method automatically updates the client's AuthStore.

Implementation

Future<RecordAuth> authRefresh({
  String? expand,
  String? fields,
  Map<String, dynamic> body = const {},
  Map<String, dynamic> query = const {},
  Map<String, String> headers = const {},
}) {
  final enrichedQuery = Map<String, dynamic>.of(query);
  enrichedQuery["expand"] ??= expand;
  enrichedQuery["fields"] ??= fields;

  return client
      .send<Map<String, dynamic>>(
        "$baseCollectionPath/auth-refresh",
        method: "POST",
        body: body,
        query: enrichedQuery,
        headers: headers,
      )
      .then(_authResponse);
}