PHP code example of tompedals / helpscout-dynamic-app

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

    

tompedals / helpscout-dynamic-app example snippets


use TomPedals\HelpScoutApp\AppRequestFactory;
use Zend\Diactoros\ServerRequestFactory;

$factory = new AppRequestFactory('secret');
$request = $factory->create(ServerRequestFactory::fromGlobals());

/** @var TomPedals\HelpScoutApp\Model\Customer */
$customer = $request->getCustomer();

/** @var TomPedals\HelpScoutApp\Model\Mailbox */
$mailbox = $request->getMailbox();

/** @var TomPedals\HelpScoutApp\Model\Ticket */
$ticket = $request->getTicket();

/** @var TomPedals\HelpScoutApp\Model\User */
$user = $request->getUser();

use TomPedals\HelpScoutApp\AppResponse;
use Zend\Diactoros\Response\JsonResponse;

$response = new AppResponse('<h4>Test</h4>');
$jsonResponse = new JsonResponse($response->getData());

class AppHandler implements AppHandlerInterface
{
    public function handle(AppRequest $request)
    {
        // Find customer information
        // Render the template
        // Return the HTML response

        return '<h4>This customer is awesome</h4>';
    }
}

use TomPedals\HelpScoutApp\AppAction;
use TomPedals\HelpScoutApp\AppHandlerInterface;
use TomPedals\HelpScoutApp\AppRequestFactory;

// implements AppHandlerInterface
$handler = new AppHandler();

$action = new AppAction(new AppRequestFactory('secret'), $handler);
$response = $action($request, $response);