}
        // If nickname not provided
        if (!isset($item['nickname'])) {
            // If this is message to visitor or message to operator
            if (in_array($item['kind'], ['MessageToOperator', 'OfflineMessage'])) {
                // ~> Nick name is visitor full name
                $item['nickname'] = $data['visitor']['fullName'];
            } else {
                // Else
                // ~> Nick name is operator (Operator always has nick name)
                $item['nickname'] = 'Operator';
            }
        }
        $conversionMessages .= $item['nickname'] . ": " . $item['body'] . PHP_EOL;
    }
    $data['conversionMessages'] = $conversionMessages;
    // If only offline message and this is not offline
    if ($app['offline_only'] && !$offline) {
        // ~> return false
        return new JsonResponse(['success' => false, 'error' => 'Not an offline message']);
    }
    $url = 'https://' . $app['freshdesk_api_key'] . ':X@' . $app['freshdesk_subdomain'] . '.freshdesk.com';
    $conf = new Connection($url);
    $t = new Ticket($conf);
    //create new ticket
    $model = new TicketM(array('subject' => buildMessage($app['ticket_subject'], $data), 'description' => buildMessage($app['ticket_description'], $data), 'email' => $data['visitor']['emailAddress']));
    //create new ticket, basic example
    $result = $t->createNewTicket($model);
    return new JsonResponse(['success' => $result != false]);
});
$app->run();
Esempio n. 2
0
<?php

require 'vendor/autoload.php';
include 'config.php';
use Freshdesk\Config\Connection, Freshdesk\Rest, Freshdesk\Ticket, Freshdesk\Model\Contact, Freshdesk\Model\Ticket as TicketM, Freshdesk\Tool\ModelGenerator;
$url = 'https://' . $KEY . ':X@chester.freshdesk.com';
$conf = new Connection($url);
//basic/general rest calls
$fd = new Rest($conf);
//get ticket, this call will be removed from Rest class & moved to Ticket class
//$json = $fd->getSingleTicket(1701);
//print_r($json);
//for ticket-calls:
$t = new Ticket($conf);
//create new ticket
$model = new TicketM(array('description' => 'Operating System: ' . $_POST['os'] . "\n" . 'Location: ' . $_POST['location'] . "\n\n" . $_POST['description'], 'subject' => $_POST['subject'], 'email' => $_POST['email']));
//create new ticket, basic example
$t->createNewTicket($model);
//Redirect to initial page
// header( "refresh:2;url=index.php" );
?>

<html>
  <head>
    <title>RIT CIS Ticketing System</title>
  </head>
  <body>
    <p>Thanks for the ticket.</p>
 </body>
</html>
Esempio n. 3
0
$model = new TicketM(array('display_id' => 12345));
$t = new Ticket($conf);
//get all data associated with this id
$model = $t->getFullTicket($model);
//close a ticket
$ticket = $t->updateTicket($model->setStatus(4));
//fire up the generator
$gen = new ModelGenerator($conf);
//generate class, extending from the TicketM class
//will create properties, setters and getters for all
//properties not present in base class
echo $gen->generateTicketClass($model, 'YourTicket', '/home/user/abs/path/to/YourTicket.php');
//basic/general rest calls
$fd = new Rest($conf);
//get ticket, this call will be removed from Rest class & moved to Ticket class
$json = $fd->getSingleTicket(1701);
print_r($json);
//for ticket-calls:
$t = new Ticket($conf);
//create new ticket
$model = new TicketM(array('description' => 'Ignore this ticket, it is a test', 'subject' => 'API-test', 'email' => '*****@*****.**'));
//create new ticket, basic example
$t->createNewTicket($model);
//Assign a ticket to an agent/responder:
$responderId = 123456;
$t->assignTicket($model, $responderId);
//delete a ticket:
$t->deleteTicket($model);
//pass true as second argument to force a reload of the ticket
//restore a ticket that was deleted via the api:
$t->restoreTicket($model);