adrii/zendesk-api

Lightweight library that allows you to create, edit, delete and upload files to Zendesk. In a clean and standard way.

1.0 2021-11-11 19:53 UTC

This package is auto-updated.

Last update: 2024-11-12 02:31:35 UTC


README

By Adrii

Latest Stable Version Total Downloads License

Lightweight library that allows you to create, edit, delete and upload files to Zendesk Suppot. In a clean and standard way.

Installation

Use Composer to install the library.

composer require adrii/zendesk-api

Composer

use Adrii\ZendeskAPI;

Manual

require_once ROOT . 'ZendeskAPI.php';

Usage

    
    $data = array(
        "username" => "1234qwer",
        "type" => "problem",
        "tags" => "ios,test",
        "subject" => "Test",
        "body" => "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean tempor semper enim. Nam non semper ligula. Vestibulum sapien sapien, hendrerit pharetra elementum a, faucibus id nisl. Aenean ornare rhoncus ligula, eget efficitur augue suscipit vehicula. Fusce faucibus odio magna, sit amet aliquet ipsum sodales a.",
        "first_name" => "Adrii",
        "last_name" => "🍍",
        "email" => "adrian.villamayor@gmail.com",
    );
        
    for ($i = 0; $i < count($files); $i++) {
        $zendesk->upload($files[$i]['name'], $files[$i]['tmp_name']);
    }

    $comment = array(
        array(
            'type'          => $data['type'],
            'tags'          => explode(",", $data['tags']),
            'subject'       => $data['subject'],
            'comment'       => array(
                'body'      => $data['body'],
                'public'    => false,
                "uploads"   => $zendesk->getUpload()
            ),
            'requester'     => array(
                'locale_id' => '1',
                'name'      => $data['first_name'] . " " . $data['last_name'],
                'email'     => $data['email'],
            ),
            'priority'      => 'normal',
        )
    );

    $subdomain  = "{subdomain}";
    $user       = "{user}";
    $token      = "{token}";

    $zend = new ZendeskApi($subdomain, $user, $token);

    $zend->create($comment);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Thanks for your help! 🎉