Git Product home page Git Product logo

zendesk-laravel's Introduction

Laravel Zendesk

This package provides integration with the Zendesk API. It supports creating tickets, retrieving and updating tickets, deleting tickets, etc.

The package simply provides a Zendesk facade that acts as a wrapper to the zendesk/zendesk_api_client_php package.

NB: Currently only supports token-based authentication.

Installation

Install via composer by adding the following to your composer.json:

    ...
    "require": {
        "huddledigital/zendesk-laravel": "~2.0"
    }
    ...

Add service provider to config/app.php:

    ...
    'Huddle\Zendesk\Providers\ZendeskServiceProvider',
    ...

Add alias to config/app.php:

    ...
    'Zendesk' => 'Huddle\Zendesk\Facades\Zendesk',
    ...

Configuration

Set your configuration using environment variables, either in your .env file or on your server's control panel:

  • ZENDESK_SUBDOMAIN - the subdomain part of your Zendesk organisation URL e.g. if your URL is http://huddledigital.zendesk.com use huddledigital
  • ZENDESK_USERNAME - the username for the authenticating account.
  • ZENDESK_TOKEN - the access token. To generate an access token within Zendesk, click on Settings, API, enable Token Access and click 'add new token'.

Usage

Facade

The Zendesk facade acts as a wrapper for an instance of the Zendesk\API\Client class. Any methods available on this class (documentation here) are available through the facade. for example:

// Get all tickets
Zendesk::tickets()->findAll();

// Create a new ticket
Zendesk::tickets()->create([
  'subject' => 'Subject',
  'comment' => [
      'body' => 'Ticket content.'
  ],
  'priority' => 'normal'
]);

// Update multiple tickets
Zendesk::ticket([123, 456])->update([
  'status' => 'urgent'
]);

// Delete a ticket
Zendesk::ticket(123)->delete();

Dependency injection

If you'd prefer not to use the facade, you can skip adding the alias to config/app.php and instead inject Huddle\Zendesk\Services\ZendeskService into your class. You can then use all of the same methods on this object as you would on the facade.

<?php

use Huddle\Zendesk\Services\ZendeskService;

class MyClass {
    
    public function __construct(ZendeskService $zendesk_service) {
        $this->zendesk_service = $zendesk_service;
    }
    
    public function addTicket() {
        $this->zendesk_service->tickets()->create([
              'subject' => 'Subject',
              'comment' => [
                    'body' => 'Ticket content.'
              ],
              'priority' => 'normal'
        ]);
    }
    
}

This package is available under the MIT license.

zendesk-laravel's People

Contributors

pieterscheffers avatar tom-huddle avatar tomparson avatar webaction avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.