phlib/messagebird-guzzle-client

A guzzle specific client implementation for the Message Bird API.

1.0.1 2022-03-30 08:28 UTC

This package is auto-updated.

Last update: 2024-03-29 02:50:30 UTC


README

Build Status Codecov Latest Stable Version Total Downloads Licence

MessageBird Guzzle HTTP client implementation.

Allows you to replace the Message Bird HTTP Client with an implementation that uses the Guzzle HTTP Client. This means there is a more control over certain options in the client.

Install

Via Composer

$ composer require phlib/messagebird-guzzle-client

Creating a HTTP Client

<?php
use Phlib\MbGuzzleClient\Http\Client;
use GuzzleHttp\Client as GuzzleClient;

$guzzleClient = new GuzzleClient($options = []);
$httpClient = new Client(MessageBird\Client::ENDPOINT, $guzzleClient);

Using the HTTP Client with MessageBird

$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY', $httpClient);

// OR

$messageBird = new \Phlib\MbGuzzleClient\Client('YOUR_ACCESS_KEY');
 
// Get you balance
$balance = $messageBird->balance->read();

Problems

HTTPClient injection through constructor is wrongfully reused

When constructing the MessageBird client with a custom HTTP client implementation, as is done here, the side effect is that the same client is used for API and Chat API endpoints.

License

This package is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.