• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

huddledigital/zendesk-laravel: Laravel wrapper for zendesk/zendesk_api_client_ph ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

huddledigital/zendesk-laravel

开源软件地址(OpenSource Url):

https://github.com/huddledigital/zendesk-laravel

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource 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

You can install this package via Composer using:

composer require huddledigital/zendesk-laravel

You must also install the service provider.

Laravel 5.5+ users: this step may be skipped, as the package supports auto discovery.

// config/app.php
'providers' => [
    ...
    Huddle\Zendesk\Providers\ZendeskServiceProvider::class,
    ...
];

If you want to make use of the facade you must install it as well.

// config/app.php
'aliases' => [
    ..
    'Zendesk' => Huddle\Zendesk\Facades\Zendesk::class,
];

Configuration

To publish the config file to app/config/zendesk-laravel.php run:

php artisan vendor:publish --provider="Huddle\Zendesk\Providers\ZendeskServiceProvider"

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. http://huddledigital.zendesk.com use huddledigital

  • ZENDESK_USERNAME

The username for the authenticating account.

  • ZENDESK_TOKEN

The API access token. You can create one at: https://SUBDOMAIN.zendesk.com/agent/admin/api/settings

  • ZENDESK_DRIVER (Optional)

Set this to null or log to prevent calling the Zendesk API directly from your environment.

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.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap