mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 10:47:25 +01:00
database: Unify work and recording API
This commit is contained in:
parent
c93ebf17a0
commit
0fc0c933ac
7 changed files with 116 additions and 201 deletions
|
|
@ -80,13 +80,13 @@ class MusicusClient {
|
|||
}
|
||||
|
||||
/// Create or update a work.
|
||||
///
|
||||
///
|
||||
/// The new or updated work is returned.
|
||||
Future<WorkInfo> putWork(WorkData data) async {
|
||||
Future<void> putWork(WorkInfo workInfo) async {
|
||||
final response = await _client.put(
|
||||
'$host/works/${data.data.work.id}',
|
||||
'$host/works/${workInfo.work.id}',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode(data.toJson()),
|
||||
body: jsonEncode(workInfo.toJson()),
|
||||
);
|
||||
|
||||
final json = jsonDecode(response.body);
|
||||
|
|
@ -124,17 +124,12 @@ class MusicusClient {
|
|||
}
|
||||
|
||||
/// Create or update a recording.
|
||||
///
|
||||
/// The new or updated recording is returned.
|
||||
Future<RecordingInfo> putRecording(RecordingData data) async {
|
||||
final response = await _client.put(
|
||||
'$host/recordings/${data.recording.id}',
|
||||
Future<void> putRecording(RecordingInfo recordingInfo) async {
|
||||
await _client.put(
|
||||
'$host/recordings/${recordingInfo.recording.id}',
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode(data.toJson()),
|
||||
body: jsonEncode(recordingInfo.toJson()),
|
||||
);
|
||||
|
||||
final json = jsonDecode(response.body);
|
||||
return RecordingInfo.fromJson(json);
|
||||
}
|
||||
|
||||
/// Close the internal http client.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue