patchModel<T extends Model> method

Future<T> patchModel<T extends Model>({
  1. required String type,
  2. required String id,
  3. ModelAttributes? attributes,
  4. Map<String, ModelRelationship>? relationships,
})

Implementation

Future<T> patchModel<T extends Model>({
  required String type,
  required String id,
  ModelAttributes? attributes,
  Map<String, ModelRelationship>? relationships,
}) async {
  final response = await patch('$type/$id', {
    'type': type,
    'id': id,
    if (attributes != null) //
      'attributes': attributes.toMap()..removeWhere((_, value) => value == null),
    if (relationships != null) //
      'relationships': relationships.map((key, value) => MapEntry(key, {'data': value.toMap()}))
  });
  return response.as<T>();
}