updateUser method

Future<void> updateUser({
  1. required String accessToken,
  2. String? firstName,
  3. String? lastName,
})

Implementation

Future<void> updateUser({
  required String accessToken,
  String? firstName,
  String? lastName,
}) async {
  final body = <String, dynamic>{};

  if (firstName != null) {
    body['firstName'] = firstName;
  }

  if (lastName != null) {
    body['lastName'] = lastName;
  }

  final response = await _patch(
    path: '/users/me',
    body: body,
    accessToken: accessToken,
  );

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

  return;
}