2017 © Pedro Peláez
 

library buzzi-sdk-php

Buzzi PHP SDK

image

buzzi-io/buzzi-sdk-php

Buzzi PHP SDK

  • Monday, October 23, 2017
  • by zprisk
  • Repository
  • 2 Watchers
  • 0 Stars
  • 111 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 28 % Grown

The README.md

buzzi-sdk-php

Buzzi SDK for PHP, (*1)

Install

The recommended way to install buzzi-io/buzzi-sdk-php is through composer., (*2)

composer require buzzi-io/buzzi-sdk-php

Usage

Don't forget to autoload:, (*3)

<?php
require 'vendor/autoload.php';

Initialize Sdk object:

use Buzzi\Sdk;

$sdk = new Sdk([
    Sdk::CONFIG_AUTH_ID => '<your-buzzi-api-id-here>',
    Sdk::CONFIG_AUTH_SECRET => '<your-buzzi-api-secret-here>',

    // Optional parameters:
    //
    // Sdk::CONFIG_HOST => <buzzi-host>, if is not set will be used either production or sandbox predefined hosts depends on Sdk::CONFIG_SANDBOX
    // Sdk::CONFIG_SANDBOX => false,
    // Sdk::CONFIG_DEBUG => false,
    // Sdk::CONFIG_LOG_FILE_NAME => \Buzzi\Http::DEFAULT_LOG_FILE_NAME,
    // Sdk::CONFIG_LOG_LINE_FORMAT => \Buzzi\Http::DEFAULT_LOG_LINE_FORMAT,
    // Sdk::CONFIG_LOG_MESSAGE_FORMAT => \Buzzi\Http::DEFAULT_LOG_MESSAGE_FORMAT
]);

In order to verify credentials:

$supportService = $sdk->getSupportService();

try {

    $isAuthorized = $supportService->isAuthorized();

} catch (\Buzzi\Exception\HttpException $e) {

    $isAuthorized = false;
}

In order to send (publish) data:

$publishService = $sdk->getPublishService();

try {

    $eventId = $publishService->send('buzzi.generic.test', ["message" => "Hello, World", "timestamp" => date(DATE_ATOM)]);

} catch (\Buzzi\Exception\HttpException $e) {

    // The exceptions is thrown if http request is not successful

} catch (\RuntimeException $e) {

    // The exceptions is thrown if response does not contain event ID
}

In order to get count of deliveries:

$consumeService = $sdk->getConsumeService();

try {

    $countDeliveries = $consumeService->getCount();

} catch (\Buzzi\Exception\HttpException $e) {

    // The exceptions is thrown if http request is not successful

} catch (\RuntimeException $e) {

    // The exceptions is thrown if response does not contain count value
}

In order to fetch one delivery:

$consumeService = $sdk->getConsumeService();

try {

    $delivery = $consumeService->fetch();

} catch (\Buzzi\Exception\HttpException $e) {

    // The exceptions is thrown if http request is not successful
}

In order to fetch a batch of deliveries:

// fetchs all deliveries but not more then 100
list($deliveries, $exceptions) = $consumeService->batchFetch(100);

In order to confirm that delivery is processed:

try {

    $consumeService->confirmDelivery($delivery);
    // OR
    $consumeService->confirm($delivery->getReceipt());

} catch (\Buzzi\Exception\HttpException $e) {

    // The exceptions is thrown if http request is not successful
}

In order to submit error during delivery processing:

try {

    // $errorData could contain any information about the error
    $errorData = [
        'message' => 'reason for error'
    ];
    $consumeService->submitError($delivery->getReceipt(), $errorData);

} catch (\Buzzi\Exception\HttpException $e) {

    // The exceptions is thrown if http request is not successful
}

Information which could be taken from Buzzi\Exception\HttpException:

try {

// request

} catch (\Buzzi\Exception\HttpException $e) {
    // The exceptions is thrown if http request is not successful

    $e->getMessage();           // returns either grabbed message from response body or reason phrase
    $e->getStatusCode();        // returns http status code of the response
    $e->getResponse();          // returns \Psr\Http\Message\ResponseInterface|\GuzzleHttp\Psr7\Response
    $e->getResponseBody();      // returns decoded response body
    $e->getResponseBody(false); // returns response body as json string
}

The Versions

23/10 2017

dev-master

9999999-dev http://buzzi.io

Buzzi PHP SDK

  Sources   Download

proprietary

The Requires

 

The Development Requires

php sdk buzzi

23/10 2017

2.0.1

2.0.1.0 http://buzzi.io

Buzzi PHP SDK

  Sources   Download

proprietary

The Requires

 

php sdk buzzi

12/09 2017

2.0.0

2.0.0.0 http://buzzi.io

Buzzi PHP SDK

  Sources   Download

proprietary

The Requires

 

php sdk buzzi

22/05 2017

0.1.0

0.1.0.0 http://buzzi.io

Buzzi PHP SDK

  Sources   Download

proprietary

The Requires

 

The Development Requires

php sdk buzzi

16/05 2017

0.0.2

0.0.2.0 http://buzzi.io

Buzzi PHP SDK

  Sources   Download

proprietary

The Requires

 

The Development Requires

php sdk buzzi

06/04 2017

0.0.1

0.0.1.0 http://buzzi.io

Buzzi PHP SDK

  Sources   Download

proprietary

The Requires

 

The Development Requires

php sdk buzzi