Download the PHP package bradfeehan/desk-php without Composer
On this page you can find all versions of the php package bradfeehan/desk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bradfeehan/desk-php
More information about bradfeehan/desk-php
Files in bradfeehan/desk-php
Package desk-php
Short Description PHP client for Desk.com v2 API based on Guzzle
License MIT
Informations about the package desk-php
desk-php
PHP client for Desk.com v2 API, based on Guzzle
This project is still under development and things may change quickly. It'll attempt to adhere to Semantic Versioning to minimise any issues.
Here's a summary of what's implemented:
- Main resource operations (ListCases, etc)
- Sub-item operations (ListCaseNotes, etc)
- Data type filtering
Dates- Custom fields?
- Resource property lists (e.g. customer email addresses, etc)
- Resource relationships (links/embedding)
Links to other resources return commandsEmbedded resources return modelsEmbedded model data type filtering
Project Aims
- Support all API operations documented by Desk
- Consumption of the API's provided relationship
functionality
- Resources link to other related resources
- These can be embedded to reduce the number of requests
- PHP-friendly data types (dates represented using DateTime objects, etc)
- 100% unit test coverage (using PHPUnit)
- Additional "use-case" tests for every individual operation, which use documented responses as mock responses
Installation
To get this library in to an existing project, the best way is to use Composer.
-
Add
bradfeehan/desk-php
as a Composer dependency in your project'scomposer.json
file: -
If you haven't already, download and install Composer:
- Set up Composer's autoloader:
You're done! Now the Desk
namespace should exist and contain
everything you need to consume the Desk.com API.
"More on the composer.json format"
"More detailed installation instructions on the Composer site"
"More detailed instructions on the Composer site"
"More information about the autoloader on the Composer site"
Super Quick Run-down
Basic Usage
The main point of entry for your app will usually be the Desk\Client
class:
.. or with API keys:
Individual commands can be retrieved from the client and executed:
There are some shortcuts which can be taken. The above is equivalent to:
...which again is the same as:
Complex data types are (generally) converted to/from easier to use
formats. For example, dates are represented as strings over the wire
when communicating with the Desk API, but these will be converted to
PHP DateTime
objects upon retrieval:
Command names
The names of commands follow a strict naming convention. The type of operation is first; this is usually one of Show, List, Create, Update, Delete, or Search. This is combined with the resource name (CamelCase if it's more than one word) -- for example, Article, Company, CustomField etc. List and Search operations will have a pluralised version of the resource name (e.g. ListCompanies, SearchArticles, etc). while the other operations will have the singular form (e.g. ShowCompany, CreateArticle, etc). The complete list is in the service description file, desk.json, although it might be a bit hard to use for this purpose due to its length.
"View this file on GitHub"
Relationships
In version 2 of the Desk API, there exists the concept of relationships between resources. For example, a Case resource now links to the Customer resource which created the case. This is fully supported by this library.
Links
A link from one resource to another is represented by a pre-configured
command object which is ready to retrieve the target of the link. To
retrieve a command representing a link, call the getLink()
method on
the model:
Embedded Resources
The example above would require two requests -- one for the case, and another for the customer. If, at the time of the first request, you know that you will (or might) need to access a related resource, you can request that the related resource be embedded into the first response. As an example, to improve on the performance of the previous example:
The call to getEmbedded()
would throw an exception if we hadn't
requested the "customer" relation to be embedded at the time of the
original request to retrieve the case.
Contributing
Contributions are most welcome! At this early stage of development, I'm working hard on the items at the top of this README. At any time I'm probably halfway through implementing (or re-implementing) something on that list, so keep that in mind if you're planning to start working on something -- I may already be on it.
Here's a few guidelines when coding on this project:
- I'm trying to use best practices everywhere in this project. Hacky solutions are generally rejected in favor of "doing it right" (in general).
- Stick to PSR-2 coding style. This involves many things I wasn't aware of when starting out! (e.g. one argument per line in multi-line function definitions)
- Try and stick to 72/80 characters where possible (except in
.json
files if necessary).
With that being said, I feel like even if you have some code in a fork which doesn't adhere to these guidelines, it could certainly still be useful, so feel free to open a pull request anyway.
All versions of desk-php with dependencies
guzzle/guzzle Version ~3.9
bradfeehan/guzzle-modular-service-descriptions Version ~1.1,>=1.1.1