wearesho-team / alphasms-message-delivery
Message Delivery AlphaSMS integration
2.4.0
2022-12-01 12:51 UTC
Requires
- php: ^7.4 | ^8.0
- ext-json: *
- ext-simplexml: *
- guzzlehttp/guzzle: ^6.5.8 || ^7.4.5
- horat1us/environment-config: ^1.5
- wearesho-team/base-collection: ^1.0.2
- wearesho-team/message-delivery: ^1.7.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-11-29 05:32:51 UTC
README
wearesho-team/message-delivery implementation of Delivery\ServiceInterface
Installation
composer require wearsho-team/alphasms-message-delivery:^2.4.0
Usage
Configuration
ConfigInterface have to be used to configure requests. Available implementations:
- Config - simple implementation using class properties
- EnvironmentConfig - loads configuration values from environment using getenv
Additional methods
Besides implementing Delivery\ServiceInterface Service provides
<?php use Wearesho\Delivery; $config = new Delivery\AlphaSms\Config; $config->login = '380000000000'; $config->password = 'qwerty123'; $service = new Delivery\AlphaSms\Service($config, new GuzzleHttp\Client);
- Check balance on current account
<?php use Wearesho\Delivery; /** @var Delivery\AlphaSms\Service $service */ $balance = $service->balance(); $balance->getAmount(); $balance->getCurrency(); $message = (string)$balance; // will output "{amount} {currency}"
- Get cost of sending messages on concrete phone numbers
<?php use Wearesho\Delivery; /** @var Delivery\AlphaSms\Service $service */ /** @var Delivery\AlphaSms\Response\CostCollection $costs */ $costs = $service->cost([ '380000000001', '380000000002' ]); // fetch costs of sending message on concrete phones $sum = $costs->sum(); /** @var Delivery\AlphaSms\Response\Cost $singleCost */ foreach ($costs as $singleCost) { $singleCost->getRecipient(); $singleCost->getAmount(); $singleCost->getCurrency(); $singleCost->jsonSerialize(); // serialize to json }