Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug. Allow to fetch tickets (of type actAsType:customer) using th… #17

Closed
wants to merge 1 commit into from
Closed

Fix bug. Allow to fetch tickets (of type actAsType:customer) using th… #17

wants to merge 1 commit into from

Conversation

ricardotormo
Copy link

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: #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={agent@agentemail.com}&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.

@papnoisanjeev
Copy link
Contributor

@ricardotormo

Thanks for your contribution and reporting this bug to us !!
We have added your updates on master branch here.

As your pull request exist with some extra updates so we manually updates your changes in our master directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants