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
|
|
|
}
|
|
|
|
|
2022-09-18 20:12:09 +00:00
|
|
|
Future<GenericMutationResult> removeApiJob(final String uid) async {
|
2022-08-26 19:28:01 +00:00
|
|
|
try {
|
|
|
|
final GraphQLClient client = await getClient();
|
|
|
|
final variables = Variables$Mutation$RemoveJob(jobId: uid);
|
|
|
|
final mutation = Options$Mutation$RemoveJob(variables: variables);
|
2022-09-18 20:12:09 +00:00
|
|
|
final response = await client.mutate$RemoveJob(mutation);
|
|
|
|
return GenericMutationResult(
|
|
|
|
success: response.parsedData?.removeJob.success ?? false,
|
|
|
|
code: response.parsedData?.removeJob.code ?? 0,
|
|
|
|
message: response.parsedData?.removeJob.message,
|
|
|
|
);
|
2022-08-26 19:28:01 +00:00
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
2022-09-18 20:12:09 +00:00
|
|
|
return GenericMutationResult(
|
|
|
|
success: false,
|
|
|
|
code: 0,
|
|
|
|
message: e.toString(),
|
|
|
|
);
|
2022-08-26 19:28:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|