39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import 'package:social_app/data/network/i_api_client.dart';
|
|
import '../models/automation_job_model.dart';
|
|
|
|
class AutomationJobsApi {
|
|
final IApiClient _client;
|
|
static const _prefix = '/api/v1/automation-jobs';
|
|
|
|
AutomationJobsApi(this._client);
|
|
|
|
Future<List<AutomationJobModel>> list() async {
|
|
final response = await _client.get(_prefix);
|
|
final parsed = AutomationJobListResponse.fromJson(response.data);
|
|
return parsed.items;
|
|
}
|
|
|
|
Future<AutomationJobModel> get(String id) async {
|
|
final response = await _client.get('$_prefix/$id');
|
|
return AutomationJobModel.fromJson(response.data);
|
|
}
|
|
|
|
Future<AutomationJobModel> create(AutomationJobCreateRequest request) async {
|
|
final response = await _client.post(_prefix, data: request.toJson());
|
|
return AutomationJobModel.fromJson(response.data);
|
|
}
|
|
|
|
Future<AutomationJobModel> update(
|
|
String id,
|
|
AutomationJobUpdateRequest request,
|
|
) async {
|
|
final data = request.toJson();
|
|
final response = await _client.patch('$_prefix/$id', data: data);
|
|
return AutomationJobModel.fromJson(response.data);
|
|
}
|
|
|
|
Future<void> delete(String id) async {
|
|
await _client.delete('$_prefix/$id');
|
|
}
|
|
}
|