1. Why is this change necessary?
There's a bug, so when you try to follow the API instructions, in order to fetch tickets,
you can't fetch tickets based on a particular customer email.
2. What does this change do, exactly?
The code below has some problems, I guess:
$customer = $entityManager->getRepository('UVDeskCoreFrameworkBundle:User')->findOneByEmail($data['actAsEmail']);
if ($customer) {
$json = $repository->getAllCustomerTickets($request->query, $this->container, $customer);
}
The first line:
$customer = $entityManager->getRepository('UVDeskCoreFrameworkBundle:User')->findOneByEmail($data['actAsEmail']);
Should be:
$email = $request->query->get('actAsEmail');
$customer = $entityManager->getRepository('UVDeskCoreFrameworkBundle:User')->findOneByEmail($email);
Because the API should be expecting the get query params.
The third line:
$json = $repository->getAllCustomerTickets($request->query, $this->container, $customer);
Should be:
$json = $ticketRepository->getAllCustomerTickets($request->query, $this->container, $customer);
because $repository is not defined. I guess we want to access the $ticketRepository to get the customers.
3. Please link to the relevant issues (if any).
I opened a issue here: https://github.com/uvdesk/api-bundle/issues/16
It should be mentioned that if you try to filter by agent, that is still not working.
If you try this endpoint: {my_localhost_url}/api/v1/tickets?actAsEmail={[email protected]}&actAsType=agent
The API returns:
{
"status": false,
"message": "An unexpected error occurred. Please try again later."
}
So I guess there's a problem with this line:
$user = $entityManager->getRepository('UVDeskCoreFrameworkBundle:User')->findOneByEmail($data['actAsEmail']);
You could change $data['actAsEmail'] by $request->query->get('actAsEmail') and the error disappear.
The problem is that after that, if we try to filter by agent email the API returns all the tickets everytime.