updateProfile method

  1. @override
Future<AuthResult<UserModel>> updateProfile({
  1. String? displayName,
  2. String? photoUrl,
})
override

Implementation

@override
Future<AuthResult<UserModel>> updateProfile({String? displayName, String? photoUrl}) async {
  try {
    final body = <String, dynamic>{};
    if (displayName != null) body['displayName'] = displayName;
    if (photoUrl != null) body['photoUrl'] = photoUrl;

    final response = await _client.patch(
      Uri.parse('$baseUrl/auth/profile'),
      headers: _headers,
      body: jsonEncode(body),
    );
    return _handleResponse<UserModel>(response, UserModel.fromMap);
  } catch (e) {
    return AuthResult.failure(AuthException(e.toString(), code: 'network-error'));
  }
}