wearesho-team/alphasms-message-delivery

Message Delivery AlphaSMS integration

2.4.0 2022-12-01 12:51 UTC

README

Test & Lint Latest Stable Version Total Downloads codecov

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:

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
}

Authors

License

MIT