I have not finished using the HelpScout WebHook

1

I am trying to integrate a HelpScout WebHook, having already applied the same API in a PrestaShop module that I am creating. The issue is that I ask the HelpScout technical service and they can not help me, they tell me to look at the guides they have about this topic, but the truth is that I'm tired of seeing them and the WebHook still does not work.

public function getcontent()
{
    session_start();

    $tabs = $this->getTabs();

    $apiResponse = $this->getApi();
    $data = $apiResponse['data'];
    $result = $apiResponse['result'];
    $error = $apiResponse['error'];

    if ($_GET['webhook'] == 'reload') {
        $webhook = $this->getWebHook();
    }

    $this->smarty->assign(array(
        'data' => $data,
        'customer' => $result,
        'email' => $_SESSION['email'],
        'id_order' => $_SESSION['id_order'],
        'action' => $_SESSION['action'],
        'error' => $error,
        'test' => $webhook,
        'tabs' => $tabs,
    ));

    $this->context->controller->addJS($this->_path . 'views/js/functions.js');
    $this->context->controller->addCSS($this->_path . 'views/css/global.css');

    return $this->display(__FILE__, '/views/templates/admin/checkOrder.tpl');
}

public function getWebHook()
{
    $webhook = new \HelpScout\Webhook('clave de seguridad');
    $api = $this->getApi();
    $conversationApi = $api['data'];
    if ($webhook->isValid()) {
        $eventType = $webhook->getEventType();
        switch ($eventType)
        {
            case 'convo.closed':
                $conversation = $webhook->getConversation();
                foreach ($conversationApi as $converApi) {
                    if ($converApi['id'] == $conversation['id']) {
                        header("Refresh:0");
                    }
                }
                break;
        }
    }
}

Here I leave the code involved in the question to see if you can help me.

Thank you very much in advance!

    
asked by It's me 05.11.2018 в 07:43
source

0 answers