2022-08-26 19:28:01 +00:00
|
|
|
part of 'server.dart';
|
|
|
|
|
|
|
|
mixin JobsApi on ApiMap {
|
|
|
|
Future<List<ServerJob>> getServerJobs() async {
|
2022-09-08 19:58:45 +00:00
|
|
|
QueryResult<Query$GetApiJobs> response;
|
|
|
|
List<ServerJob> jobsList = [];
|
2022-08-26 19:28:01 +00:00
|
|
|
|
|
|
|
try {
|
|
|
|
final GraphQLClient client = await getClient();
|
|
|
|
response = await client.query$GetApiJobs();
|
|
|
|
if (response.hasException) {
|
|
|
|
print(response.exception.toString());
|
|
|
|
}
|
2022-09-08 19:58:45 +00:00
|
|
|
jobsList = jobsList = response.parsedData?.jobs.getJobs
|
|
|
|
.map<ServerJob>((final job) => ServerJob.fromGraphQL(job))
|
|
|
|
.toList() ??
|
|
|
|
[];
|
2022-08-26 19:28:01 +00:00
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
|
2022-09-08 19:58:45 +00:00
|
|
|
return jobsList;
|
2022-08-26 19:28:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> removeApiJob(final String uid) async {
|
|
|
|
try {
|
|
|
|
final GraphQLClient client = await getClient();
|
|
|
|
final variables = Variables$Mutation$RemoveJob(jobId: uid);
|
|
|
|
final mutation = Options$Mutation$RemoveJob(variables: variables);
|
|
|
|
await client.mutate$RemoveJob(mutation);
|
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|