Skip to content

Commit

Permalink
Changes in create tickets api :uvdesk#63
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhi12-gupta committed Jun 27, 2023
1 parent 047e0e7 commit 0152f3f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions API/Tickets.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,15 @@ public function createTicket(Request $request, ContainerInterface $container)
}

if (!$error) {
$name = explode(' ',$data['name']);
$name = explode(' ',trim($data['name']));
$ticketData['firstName'] = $name[0];
$ticketData['lastName'] = isset($name[1]) ? $name[1] : '';
$ticketData['role'] = 4;

if ((array_key_exists('actAsType', $data)) && strtolower($data['actAsType']) == 'customer') {
$actAsType = strtolower($data['actAsType']);
} else if((array_key_exists('actAsEmail', $data)) && strtolower($data['actAsType']) == 'agent') {
$user = $entityManager->getRepository(User::class)->findOneByEmail($data['actAsEmail']);

if ((array_key_exists('actAsType', $data)) && strtolower(trim($data['actAsType'])) == 'customer') {
$actAsType = strtolower(trim($data['actAsType']));
} else if((array_key_exists('actAsEmail', $data)) && strtolower(trim($data['actAsType'])) == 'agent') {
$user = $entityManager->getRepository(User::class)->findOneByEmail(trim($data['actAsEmail']));

if ($user) {
$actAsType = 'agent';
} else {
Expand Down Expand Up @@ -269,8 +268,8 @@ public function createTicket(Request $request, ContainerInterface $container)
}

$ticketData['user'] = $data['user'];
$ticketData['subject'] = $data['subject'];
$ticketData['message'] = $data['message'];
$ticketData['subject'] = trim($data['subject']);
$ticketData['message'] = trim($data['message']);
$ticketData['customer'] = $customer;
$ticketData['source'] = 'api';
$ticketData['threadType'] = 'create';
Expand Down

0 comments on commit 0152f3f

Please sign in to comment.