Пример #1
0
<?php

/**
 * File: example.php
 * Project: freshdesk-solutions
 */
require 'vendor/autoload.php';
//use the classes
use Freshdesk\Config\Connection, Freshdesk\Rest, Freshdesk\Ticket, Freshdesk\Model\Contact, Freshdesk\Model\Ticket as TicketM, Freshdesk\Tool\ModelGenerator;
$url = 'http://*****:*****@domain.freshdesk.com';
$conf = new Connection($url);
$t = new Ticket($conf);
$m = new Contact(array('email' => '*****@*****.**'));
//get an assoc array of tickets
//keys are statusName values
$tickets = $t->getGroupedTickets($m);
//same as before, status values (1,2,3...) are the keys now
$tickets = $t->getGroupedTickets('*****@*****.**', false);
//choose a ticket
$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');