diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba93dc5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.idea +composer.lock +vendor +bin +coverage +coverage.xml \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6343497 --- /dev/null +++ b/README.md @@ -0,0 +1,68 @@ +# laravel-zendesk + +A Laravel Zendesk library for integrating with the Zendesk API + +[![Author](http://img.shields.io/badge/author-@superbalist-blue.svg?style=flat-square)](https://twitter.com/superbalist) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Packagist Version](https://img.shields.io/packagist/v/superbalist/laravel-zendesk.svg?style=flat-square)](https://packagist.org/packages/superbalist/laravel-zendesk) +[![Total Downloads](https://img.shields.io/packagist/dt/superbalist/laravel-zendesk.svg?style=flat-square)](https://packagist.org/packages/superbalist/laravel-zendesk) + +This package provides a Laravel service provider and facade for the zendesk/zendesk_api_client_php package. + +## Installation + +```bash +composer require superbalist/laravel-zendesk +``` + +Register the service provider in app.php +```php +'providers' => array( + 'Superbalist\Zendesk\ZendeskServiceProvider', +) +``` + +Register the facade in app.php +```php +'aliases' => array( + 'Zendesk' => 'Superbalist\Zendesk\ZendeskFacade', +) +``` + +Create a services.php config file. +```php + array( + 'subdomain' => '[[your zendesk subdomain]]', + 'username' => '[[your zendesk username]]', + 'token' => '[[your zendesk api token]]', + ), + +); +``` + +## Usage + +Please see https://github.com/zendesk/zendesk_api_client_php for full documentation on the core API. + +All functions provided by the core API are available behind the `Zendesk` facade in Laravel. + +```php +use Zendesk; + +// get all tickets +$zendesk = Zendesk::tickets()->findAll(); + +// create a new ticket +$ticket = Zendesk::tickets()->create([ + 'subject' => 'The quick brown fox jumps over the lazy dog', + 'comment' => [ + 'body' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' . + 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' + ], + 'priority' => 'normal' +]); +``` \ No newline at end of file diff --git a/changelog.md b/changelog.md new file mode 100644 index 0000000..446a3db --- /dev/null +++ b/changelog.md @@ -0,0 +1,5 @@ +# Changelog + +## 1.0.0 - 2016-02-04 + +* Initial release \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..af42df5 --- /dev/null +++ b/composer.json @@ -0,0 +1,27 @@ +{ + "name": "superbalist/laravel-zendesk", + "description": "A Laravel Zendesk library for integrating with the Zendesk API", + "license": "MIT", + "authors": [ + { + "name": "Superbalist.com a division of Takealot Online (Pty) Ltd", + "email": "info@superbalist.com" + } + ], + "require": { + "php": ">=5.5.0", + "illuminate/support": ">=4.0.0", + "zendesk/zendesk_api_client_php": "~2.0" + + }, + "autoload": { + "psr-4": { + "Superbalist\\Zendesk\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + } +} diff --git a/src/ZendeskFacade.php b/src/ZendeskFacade.php new file mode 100644 index 0000000..469ed8c --- /dev/null +++ b/src/ZendeskFacade.php @@ -0,0 +1,18 @@ +app->bind('zendesk', function() { + $client = new ZendeskAPI( + $this->app['config']->get('services.zendesk.subdomain'), + $this->app['config']->get('services.zendesk.username') + ); + $client->setAuth( + 'basic', + array( + 'username' => $this->app['config']->get('services.zendesk.username'), + 'token' => $this->app['config']->get('services.zendesk.token'), + ) + ); + return $client; + }); + } +}