PHP code example of digitalequation / teamwork

1. Go to this page and download the library: Download digitalequation/teamwork library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

digitalequation / teamwork example snippets


return [
    'desk' => [
        /*
        |--------------------------------------------------------------------------
        | Teamwork Desk Key
        |--------------------------------------------------------------------------
        |
        | The Teamwork Desk API Key can be generated at:
        | https://your-domain.teamwork.com/desk/#myprofile/apikeys
        |
        */
        'key' => env('TEAMWORK_DESK_KEY'),

        /*
        |--------------------------------------------------------------------------
        | Teamwork Desk Domain Name
        |--------------------------------------------------------------------------
        |
        | The domain is the site address you have set on the Teamwork account.
        | To find the domain name just login to http://teamwork.com.
        | Then you will see the browser URL changing to:
        | https://your-domain.teamwork.com/launchpad/welcome
        |
        */
        'domain' => env('TEAMWORK_DESK_DOMAIN'),
    ],
];

use Teamwork;

$response = Teamwork::desk()->me();



namespace App\Http\Controllers;

use Illuminate\Http\Request;
use DigitalEquation\Teamwork\Teamwork;

class TeamworkController extends Controller
{
    protected $teamwork;

    public function __construct(Teamwork $teamwork)
    {
        $this->teamwork = $teamwork;
    }
    
    public function getMe()
    {
        try {
            $response = $this->teamwork->desk()->me();
            
            // do something with the response data...
        } catch (\Exception $e) {
            // do something with the error...
        }
    }
    
    // other methods

$response = Teamwork::desk()->me();

$response = Teamwork::desk()->inboxes();

$response = Teamwork::desk()->inbox('Inbox Name');

$teamworkUser = Teamwork::desk()->me();

$response = Teamwork::desk()->upload($teamworkUser['id'], $request->file);

[
    'id'        => 1312, // the uploaded file id on Teamwork
    'url'       => 'http://...', // the URL of the image
    'extension' => 'jpg',
    'name'      => 'Some File Name',
    'size'      => '42342', // the image size in kb
]

$response = Teamwork::tickets()->priorities();

$response = Teamwork::tickets()->ticket($ticketId);

$response = Teamwork::tickets()->customer($customerId);

$data = [
    'assignedTo'          => 5465, // the id of the assigned user on ticket
    'inboxId'             => 5545, // the inbox id where the ticket will be sent
    'tags'                => 'Test ticket',
    'priority'            => 'low',
    'status'              => 'active',
    'source'              => 'Email (Manual)',
    'customerFirstName'   => 'Test', // sender's first name
    'customerLastName'    => 'User', // sender's last name
    'customerEmail'       => '[email protected]', // sender's email
    'customerPhoneNumber' => '', // sender's phone number
    'subject'             => 'Ticket Subject',
    'previewTest'         => 'Ticket excerpt.',
    'message'             => 'The ticket body...',
];

$response = Teamwork::tickets()->post($data);

$data = [
    'ticketId'   => 2201568, // the ticket id where the reply will be sent
    'body'       => 'Reply TEST on ticket.',
    'customerId' => 65465,
];

$response = Teamwork::tickets()->reply($data);

$response = Teamwork::helpDesk()->getSites();

$response = Teamwork::helpDesk()->getSite($siteId);

$response = Teamwork::helpDesk()->getSitesCategories($siteId);

$response = Teamwork::helpDesk()->getCategoryArticles($categoryId, $pageId);

$response = Teamwork::helpDesk()->getSiteArticles($siteId, $pageId);

$response = Teamwork::helpDesk()->getArticle($articleId);

$response = Teamwork::helpDesk()->getArticles($articleIDs);
bash
php artisan teamwork:install
bash
php artisan teamwork:publish