michalwolinski / wbiztool-laravel
A WbizTool API Client Laravel integration
Requires
- php: ^7.4
- laravel/framework: ^6.0
- michalwolinski/wbiztool-php: ^1.0
This package is auto-updated.
Last update: 2024-05-30 00:41:59 UTC
README
A WbizTool API Client Laravel integration
Installation by Composer
-
Run
composer require michalwolinski/wbiztool-laravel
in console to install this library.
-
Run
php artisan vendor:publish --provider="Haxmedia\WbizToolLaravel\Providers\WbizToolServiceProvider"
in your console to publish default configuration files
-
Open .env and add your configuration:
WBIZTOOL_CLIENT_ID
- Your Client Id (Given on Dashboard in API Setting Section)WBIZTOOL_API_KEY
- Your Api Key (Given on Dashboard in API Setting Section)WBIZTOOL_WHATSAPP_CLIENT_ID
- Your WhatsApp Client Id (Given on Whatsapp Setting Page) (Given on Dashboard in API Setting Section)
Usage
I propose to use Dependency Injection to inject Client
class.
Example implementation in service class:
use Haxmedia\WbizTool\Client;
use Haxmedia\WbizTool\Dto\Receiver;
use Haxmedia\WbizTool\MessageType\Text;
use Haxmedia\WbizTool\Method\SendMessage;
class Service {
private Client $wbizToolClient;
public function __construct(Client $wbizToolClient)
{
$this->wbizToolClient = $client;
}
public sendMessage(int $phoneNumber, string $message): void
{
$receiver = new Receiver($phoneNumber);
$type = new Text('message content');
$this->wbizToolClient->push(
new SendMessage(),
$receiver,
$type
);
}
}
Usage examples are at library repository - WbizTool PHP
Authors
- Michal Wolinski - Haxmedia
License
This project is licensed under the MIT License.