atmonshi/sender

View on GitHub
src/repositories/STag.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace atmonshi\sender\repositories;

use atmonshi\sender\STag\STagAPI;

class STag
{
    protected $api;

    public function __construct()
    {
        $this->api = new stagAPI;
    }

    public function getBalance($serviceVars = [])
    {
        $service = $this->api->callService('checkBalance', $serviceVars);

        return $service->balance;
    }

    public function getSenderNames()
    {
        $service = $this->api->callService('senderNames', ['getAll' => 1]);

        return $service->senderNames;
    }

    public function send($to, $msg)
    {
        $serviceVars               = [];
        $serviceVars['appName']    = config('app.name');
        $serviceVars['host']       = request()->getHost();
        $serviceVars['mobiles']    = $to;
        $serviceVars['text']       = $msg;

        $service = $this->api->callService('sendSms', $serviceVars);

        return $service;
    }
}