create method
Future<ResourceUpdated>
create(
- String type,
- String id, {
- Map<
String, Object?> attributes = const {}, - Map<
String, Identifier> one = const {}, - Map<
String, Iterable< many = const {},Identifier> > - Map<
String, Object?> meta = const {}, - Map<
String, Object?> documentMeta = const {}, - Map<
String, String> headers = const {}, - Iterable<
String> include = const [],
Creates a new resource with the given id on the server.
Implementation
Future<ResourceUpdated> create(
String type,
String id, {
Map<String, Object?> attributes = const {},
Map<String, Identifier> one = const {},
Map<String, Iterable<Identifier>> many = const {},
Map<String, Object?> meta = const {},
Map<String, Object?> documentMeta = const {},
Map<String, String> headers = const {},
Iterable<String> include = const [],
}) async {
final response = await send(
baseUri.collection(type),
Request.post(OutboundDataDocument.resource(Resource(type, id)
..attributes.addAll(attributes)
..relationships.addAll({
...one.map((key, value) => MapEntry(key, ToOne(value))),
...many.map((key, value) => MapEntry(key, ToMany(value))),
})
..meta.addAll(meta))
..meta.addAll(documentMeta))
..headers.addAll(headers)
..include(include));
return ResourceUpdated(response.http, response.document);
}