updateTicketWithSingleLicense method
Update ticket with SINGLE driving license file PUBLIC method - called by JobService
Implementation
Future<Map<String, dynamic>> updateTicketWithSingleLicense({
required String ticketID,
required int numberOfPeople,
required File licenseFile,
required String employeeFieldID,
required String licenseFieldID,
}) async {
try {
print(' Updating ticket with single license');
print(' Ticket ID: $ticketID');
print(' Number of People: $numberOfPeople');
print(' License File: ${licenseFile.path}');
const mutation = r'''
mutation UpdateTicket($input: UpdateProjectTicketInput!) {
updateProjectTicket(input: $input) {
success
message
projectTicket {
id
ticketNumber
customValues
documentFiles {
url
filename
type
label
size
}
updatedAt
}
}
}
''';
final Map<String, dynamic> input = {
'id': ticketID,
'customValues': jsonEncode({
'cf_$employeeFieldID': numberOfPeople,
}),
'customFiles': [
{
'fieldID': licenseFieldID,
'file': null, // File will be added via multipart
}
],
};
final variables = {'input': input};
// Use BaasApi to upload the document
final result = await _api.uploadTicketWithDocument(
mutation: mutation,
variables: variables,
filePath: licenseFile.path,
fieldID: licenseFieldID,
);
final ticketResponse = result['updateProjectTicket'];
if (ticketResponse != null) {
print('Ticket updated with single license successfully');
return ticketResponse;
}
return {'success': false, 'message': 'Unknown error - no response data'};
} catch (e) {
print('Error updating ticket with single license: $e');
return {'success': false, 'message': e.toString()};
}
}