updateTicket method
Update existing ticket (basic - no file upload)
Implementation
Future<Map<String, dynamic>> updateTicket({
required String ticketID,
required String projectID,
required String tenantProductID,
Map<String, dynamic>? customValues,
String? subject,
String? description,
String? statusID,
String? priorityID,
String? assigneeID,
int? doneRatio,
}) async {
const mutation = r'''
mutation UpdateTicket($input: UpdateProjectTicketInput!) {
updateProjectTicket(input: $input) {
success
message
projectTicket {
id
ticketNumber
subject
description
doneRatio
customValues
updatedAt
}
}
}
''';
final Map<String, dynamic> input = {
'id': ticketID,
if (subject != null) 'subject': subject,
if (description != null) 'description': description,
if (statusID != null) 'statusID': statusID,
if (priorityID != null) 'priorityID': priorityID,
if (assigneeID != null) 'assigneeID': assigneeID,
if (doneRatio != null) 'doneRatio': doneRatio,
};
// Format custom values as JSON string with cf_ prefix
if (customValues != null && customValues.isNotEmpty) {
input['customValues'] = jsonEncode(_prepareCustomValuesForBackend(customValues));
}
final variables = {'input': input};
print("Updating ticket with input: $input");
final result = await _api.graphql(mutation, variables);
final ticketResponse = result['updateProjectTicket'];
if (ticketResponse != null) {
print("Ticket update service returning: $ticketResponse");
return ticketResponse;
}
return {'success': false, 'message': 'Unknown error - no response data'};
}