getMyTicketChats method
Fetch all ticket chats using myTicketChats query with FULL ticket details including profile images
Implementation
Future<Map<String, dynamic>> getMyTicketChats({
required String tenantProductID,
required String projectID,
}) async {
const query = r'''
query MyTicketChats($tenantProductID: UUID!, $projectID: UUID!) {
myTicketChats(tenantProductID: $tenantProductID, projectID: $projectID) {
success
message
tickets {
ticket {
id
ticketNumber
subject
description
doneRatio
estimatedHours
isPrivate
startDate
dueDate
updatedAt
createdAt
status {
id
name
}
priority {
id
name
}
tracker {
id
name
}
project {
id
name
}
assignee {
id
firstName
lastName
username
email
phoneNumber
location
profile_Photo
}
tenantAuthor {
id
firstName
lastName
username
email
phoneNumber
profile_Photo
}
customValues
}
participants {
name
phoneNumber
location
unreadCount
lastMessageAt
lastMessageContent
isTicketCreator
}
totalUnread
}
}
}
''';
final variables = {
'tenantProductID': tenantProductID,
'projectID': projectID,
};
print('Fetching ticket chats with full details including images: $variables');
try {
final result = await _api.graphql(query, variables);
final response = result['myTicketChats'];
if (response != null) {
print('✅ Ticket chats fetched: ${response['tickets']?.length ?? 0} tickets');
return response;
}
return {
'success': false,
'message': 'Unknown error - no response data',
'tickets': []
};
} catch (e) {
print('❌ Error fetching ticket chats: $e');
return {
'success': false,
'message': e.toString(),
'tickets': []
};
}
}