2017 © Pedro Peláez
 

library jivochat-webhooks-api

Library for Jivochat (Jivosite) Webhooks API integration.

image

olegf13/jivochat-webhooks-api

Library for Jivochat (Jivosite) Webhooks API integration.

  • Thursday, April 27, 2017
  • by Olegf13
  • Repository
  • 1 Watchers
  • 1 Stars
  • 221 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 133 % Grown

The README.md

Jivochat Webhooks API

Latest Stable Version License, (*1)

Library for Jivochat (Jivosite) Webhooks API integration., (*2)

This library allows you to integrate with Jivosite Webhooks API and: * handle API calls in event-based manner; * convert API requests JSON data in particular event objects; * generate API responses; * save original request (and generated response) data into MySQL or MongoDB server, and log it via Monolog., (*3)

For Russian documentation see README-ru.md., (*4)

Requirements

The library requires PHP 7.0 or above for basic usage., (*5)

Optional requirements: * PDO extension allows logging of Webhooks request/response data to a MySQL server; * Monolog library allows logging of Webhooks request/response using Monolog; * MongoDB library allows logging of Webhooks request/response data to a MongoDB server., (*6)

It is strongly recommended to have at least one of above loggers installed to hold a "backup" of original requests sent via Webhooks API., (*7)

Installation

The preferred way to install this library is through Composer. To install the latest version, run:, (*8)

composer require olegf13/jivochat-webhooks-api

Basic usage

<?php
use Olegf13\Jivochat\Webhooks\Log\MySQLLog;
use Olegf13\Jivochat\Webhooks\Event\Event;

// create MySQL logger
$dbLogger = new MySQLLog(new PDO('mysql:dbname=test;host=127.0.0.1', 'root', 'root'));

// create Callback API event listener
$listener = new Olegf13\Jivochat\Webhooks\EventListener([$dbLogger]);

// bind listener for `chat_accepted` event
$listener->on(Event::EVENT_CHAT_ACCEPTED, function (Olegf13\Jivochat\Webhooks\Event\ChatAccepted $event) {
    // here you do your stuff - find user in your database, etc
    $user = User::getByEmail($event->visitor->email);

    // generate response on Callback API
    $response = new Olegf13\Jivochat\Webhooks\Response();
    $response->setCRMLink(...);
    $response->setContactInfo(...);
    $response->setCustomData(...);

    // event handler must return Response object
    return $response;
});

// bind listener for `chat_accepted` event
$listener->on(Event::EVENT_CHAT_FINISHED, function (Olegf13\Jivochat\Webhooks\Event\ChatFinished $event) {
    /** @var int Timestamp of the chat's first message. */
    $chatBeginAt = $event->chat->messages[0]->timestamp;
    // ...

    return new Olegf13\Jivochat\Webhooks\Response();
});

// execute event listener
$listener->listen();

Documentation

License

This library is licensed under the MIT License - see the LICENSE file for details., (*9)

Acknowledgements

Thanks to this Jivosite Webhook handler library., (*10)

The Versions

27/04 2017

dev-master

9999999-dev https://github.com/Olegf13/jivochat-webhooks-api

Library for Jivochat (Jivosite) Webhooks API integration.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

jivosite jivochat webhooks api

27/04 2017

1.1

1.1.0.0 https://github.com/Olegf13/jivochat-webhooks-api

Library for Jivochat (Jivosite) Webhooks API integration.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

jivosite jivochat webhooks api

26/04 2017

v1.0.x-dev

1.0.9999999.9999999-dev https://github.com/Olegf13/jivochat-webhooks-api

Library for Jivochat (Jivosite) Webhooks API integration.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

jivosite jivochat webhooks api

26/04 2017

1.0

1.0.0.0 https://github.com/Olegf13/jivochat-webhooks-api

Library for Jivochat (Jivosite) Webhooks API integration.

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

jivosite jivochat webhooks api