getPublicNote method

Future<Map<String, Object>?> getPublicNote(
  1. String token, {
  2. String? password,
})

Fetch a publicly shared note.

Unauthenticated. The share token is the credential. For password-protected notes the password is supplied via the ?password= query param; the response distinguishes "no password supplied" from "wrong password" so the viewer can render the right prompt. Unknown tokens and disabled-share notes both return 404 to prevent token enumeration.

Parameters:

  • String token (required): Opaque public-share token.

  • String password: Optional viewer password.

Implementation

Future<Map<String, Object>?> getPublicNote(String token, { String? password, }) async {
  final response = await getPublicNoteWithHttpInfo(token,  password: password, );
  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 Map<String, Object>.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map<String, Object>'),);

  }
  return null;
}