save method
Replaces venue venueId with body (.dome venue sections). With ifMatch = the ETag from get; without
it the venue is created (If-None-Match: *). A stale ETag (412) or a taken id (409) → ConflictException
whose latest is the current Versioned<Venue> (when it could be fetched).
Implementation
Future<Versioned<Venue>> save(
String venueId,
VenueInput body, {
String? ifMatch,
}) async {
try {
final res = await _api.call(
Operations.putVenue,
params: {'venueId': venueId},
body: body.toJson(),
headers: ifMatch == null
? {'if-none-match': '*'}
: {'if-match': ifMatch},
);
return Versioned(
ApiCaller.decodeBody(Operations.putVenue, res, Venue.fromJson),
res.headers['etag'],
);
} on ConflictException catch (e) {
Versioned<Venue>? latest;
try {
latest = await get(venueId);
} on FreedomeException {
latest = null;
}
throw ConflictException(
e.message,
latest: latest,
problem: e.problem,
code: e.code ?? 'conflict',
);
}
}