amalfra / supportbee
A PHP library for interacting with SupportBee API
Requires
- php: >=7.4.0
- rmccue/requests: ^2.0
Requires (Dev)
- phpunit/phpunit: ~9.5.7
- squizlabs/php_codesniffer: 3.*
README
A PHP wrapper for the SupportBee REST API.
You can find your API token in Settings > API Token screen. See https://developers.supportbee.com/api for more.
Installation
In your project root, run the following:
composer require amalfra/supportbee
This will create a vendor
directory (if you dont already have one), and set up the autoloading classmap.
Usage
Once everything is installed, you should be able to load the composer autoloader in your code.
You can load the wrapper classes using namespace as:
require __DIR__ . '/vendor/autoload.php'; use \Amalfra\SupportBee\Client as SupportBee;
Now create a new object
$supportbee = new SupportBee();
At this stage you can also supply the configuration parameter token, company
which is used throughout the API. These can be passed directly as array:
$config = array( 'token' => 'your token', 'company' => 'your company name' ); $supportbee = new SupportBee($config);
Now the available API calls can be done using the instance. All the result from API will be returned as associative array. If any status code other than 200 is returned an exception would be thrown.
Available API methods
Please refer to https://developers.supportbee.com/api for avaialble parameter details.
Incase of multiple paramters : Pass as an associative array. All method names follow Camel Casing.
Tickets
- tickets - Returns 15 tickets of the company in the order of their last activity. Only tickets that are not archived are returned (please see optional parameters to get archived tickets).
- ticket - Retrieves the ticket specified by the id.
- searchTickets - Returns 15 tickets of the company in the order of their last activity matching the search query.
- createTicket - Creates a ticket for the company. Pass the information for ticket as associative array.
- deleteTicket - Deletes a trashed ticket. Only Admins can delete a trashed ticket.
- archiveTicket - Archives an unarchived ticket.
- unarchiveTicket - Un-archives an archived ticket.
- assignTicket - Assign a ticket to a User or Group. The first paramter is the ticket id. The second paramter is an associative arry with index as user_id if the ticket is to be assigned to an user and group_id if the ticket is to be assigned to a group.
- starTicket - Stars an un-starred ticket.
- unstarTicket - Un-stars a starred ticket.
- spamTicket - Spam's an un-spammed ticket.
- unspamTicket - Un-spam a spammed ticket.
- trashTicket - Trashes an un-trashed ticket.
- untrashTicket - Un-trashes a trashed ticket.
- addLabelToTicket - Adds label to ticket. You can pass the ticket_id and label name as parameters.
- removeLabelFromTicket - Removes label from ticket. You can pass the ticket_id and label name as parameters.
Replies
- replies - Retrieves all the replies of the ticket with id ticket_id.
- reply - Retrieves the reply for ticket specified by the ticket_id with id.
Comments
- comments - Retrieves all the comments of the ticket with id ticket_id.
- createComment - Create a comment to the ticket with id ticket_id. Pass the information for comment as associative array in second parameter.
Agents
- agents - Retrieves all confirmed agents of the company.
- agent - Retrieves the agent for company specified by the id.
Labels
- labels - Retrieves all the custom labels of a company.
Groups
- groups - Retrieves all the groups of the company.
Snippets
- snippets - Returns all the snippets of the company.
WebHooks
- webhooks - Returns all the web hooks of the company.
Reports
- avgFirstResponseTimeReport - Returns data points for average first response time.
- ticketsCountReport - Returns data points for tickets count.
- repliesCountReport - Returns data points for replies count.
Emails
- emails - Returns all the emails of the company.
- createEmail - Creates an email for the company. Pass the information for email as associative array in second parameter.
Development
Questions, problems or suggestions? Please post them on the issue tracker.
You can contribute changes by forking the project and submitting a pull request. You can ensure the tests are passing by running vendor/bin/phpunit
. Feel free to contribute 😍
UNDER MIT LICENSE
The MIT License (MIT)
Copyright (c) 2014 Amal Francis
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.