FreshdeskBundle
, (*1)
This is a Symfony2-3 bundle to interact with the Freshdesk API v2 via
the freshdesk-php-sdk., (*2)
Requirements
- Symfony 2.8+
- PHP 5.5+
- A Freshdesk account
Installation
To add this bundle to your Symfony app, use Composer., (*3)
Add mpclarkson/freshdesk-bundle
to your composer.json file:, (*4)
{
"require": {
"mpclarkson/freshdesk-bundle": "dev-master"
}
}
Add the bundle to AppKernel.php
:, (*5)
public function registerBundles()
{
$bundles = array(
// ...
new Mpclarkson\FreshdeskBundle\FreshdeskBundle(),
// ...
);
}
Configure the bundle in config.yml
:, (*6)
freshdesk:
api_key: your_freshdesk__api_key
domain: your_freshdesk_domain
Then run composer update
., (*7)
Accessing the Freshdesk API
In a controller you can access the Freshdesk client and the API resources
as follows:, (*8)
$api = $this->get('freshdesk');
//Contacts
$contacts = $api->contacts->update($contactId, $data);
//Agents
$me = $api->agents->current();
//Companies
$company = $api->companies->create($data);
//Groups
$deleted = $api->groups->delete($groupId);
//Tickets
$ticket = $api->tickets->view($filters);
//Time Entries
$time = $api->timeEntries->all($ticket['id']);
//Conversations
$ticket = $api->conversations->note($ticketId, $data);
//Categories
$newCategory = $api->categories->create($data);
//Forums
$forum = $api->forums->create($categoryId, $data);
//Topics
$topics = $api->topics->monitor($topicId, $userId);
//Comments
$comment = $api->comments->create($forumId);
//Email Configs
$configs = $api->emailConfigs->all();
//Products
$product = $api->products->view($productId);
//Business Hours
$hours = $api->businessHours->all();
//SLA Policy
$policies = $api->slaPolicies-all();
Filtering
All GET
requests accept an optional array $query
parameter to filter
results. For example:, (*9)
//Page 2 with 50 results per page
$page2 = $this->forums->all(['page' => 2, 'per_page' => 50]);
//Tickets for a specific customer
$tickets = $this->tickets->view(['company_id' => $companyId]);
Please read the Freshdesk documentation for further information on
filtering GET
requests., (*10)
Contributing
This is a work in progress and PRs are welcome. Please read the
contributing guide., (*11)
Author
The library was written and maintained by Matthew Clarkson
from Hilenium., (*12)
References