PHP code example of helpscout / api-laravel

1. Go to this page and download the library: Download helpscout/api-laravel 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/ */

    

helpscout / api-laravel example snippets


    $app->register(HelpScout\Laravel\HelpScoutServiceProvider::class);

    'providers' => [
        // ...
        HelpScout\Laravel\HelpScoutServiceProvider::class,
    ]

    'aliases' => [
        // ...
        'HelpScout' => HelpScout\Laravel\HelpScoutFacade::class,
    ]

$client = app('helpscout');
$client->useClientCredentials($appId, $appSecret);

$webhooks = $client->webhooks()->list();

$client = app(\HelpScout\Api\ApiClient::class);
$webhooks = $client->webhooks()->list();

$client = app('helpscout');
$webhooks = $client->webhooks()->list();

use HelpScout\Api\ApiClient;
use HelpScout\Api\Entity\PagedCollection;

class Foo
{
    private $api;
    
    public function __construct(ApiClient $api)
    {
        $this->api = $api;
    }
    
    public function getWebhooks(): PagedCollection
    {
        return $this->api->webhooks()->list();
    }
}

use HelpScout\Api\Webhooks\WebhooksEndpoint;
use HelpScout\Api\Entity\PagedCollection;

class Foo
{
    private $endpoint;
    
    public function __construct(WebhooksEndpoint $endpoint) 
    {
        $this->endpoint = $endpoint;
    }
    
    public function getHsWebhooks(): PagedCollection
    {
        return $this->endpoint->list();
    }
}

// usage
$foo = app(Foo::class);
$webhooks = $foo->getHsWebhooks();

// using the endpoints registered alias...
$webhookEndpoint = app('hs.webhooks');
$webhooks = $webhookEndpoint->list();

$webhooks = HelpScout::webhooks()->list();
sh
php composer.phar update
sh
php artisan vendor:publish  --provider="HelpScout\Laravel\HelpScoutServiceProvider"

// or
php artisan vendor:publish  --tag="helpscout"