feat: 添加自动化任务(automation_jobs)功能模块
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import 'package:social_app/core/api/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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user