forked from anlutro/php-bulk-sms
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
159 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,10 @@ | |
{ | ||
"name": "Andreas Lutro", | ||
"email": "[email protected]" | ||
}, | ||
{ | ||
"name": "Michael Nowag", | ||
"email": "<[email protected]>" | ||
} | ||
], | ||
"require": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/** | ||
* BulkSMS PHP implementation | ||
* | ||
* @author Andreas Lutro <[email protected]> | ||
* @license http://opensource.org/licenses/MIT | ||
* @package anlutro/bulk-sms | ||
*/ | ||
|
||
namespace anlutro\BulkSms\Sender; | ||
|
||
use anlutro\cURL\cURL; | ||
use anlutro\cURL\Response; | ||
use Respect\Validation\Validator as v; | ||
|
||
abstract class AbstractSender | ||
{ | ||
/** | ||
* BulkSMS username | ||
* | ||
* @var string | ||
*/ | ||
protected $username; | ||
|
||
/** | ||
* BulkSMS password | ||
* | ||
* @var string | ||
*/ | ||
protected $password; | ||
|
||
/** | ||
* The endpoint the call should go to. | ||
* | ||
* @var string | ||
*/ | ||
protected $endpoint; | ||
|
||
/** | ||
* The base URL of the API. | ||
* | ||
* @var string | ||
*/ | ||
protected $baseUrl; | ||
|
||
/** | ||
* The cURL instance. | ||
* | ||
* @var cURL | ||
*/ | ||
protected $curl; | ||
|
||
/** | ||
* @param string $username BulkSMS username | ||
* @param string $password BulkSMS password | ||
* @param $baseUrl | ||
* @param cURL $curl | ||
*/ | ||
public function __construct($username, $password, $baseUrl, cURL $curl = null) | ||
{ | ||
v::url()->setName("Base Bulksms URL")->check($baseUrl); | ||
$this->baseUrl = $baseUrl; | ||
$this->username = $username; | ||
$this->password = $password; | ||
$this->curl = $curl ?: new cURL(); | ||
} | ||
|
||
/** | ||
* Extract response from Sender - depends on sender | ||
* | ||
* @param Response $response | ||
* | ||
* @return mixed | ||
*/ | ||
abstract public function extractResponse(Response $response); | ||
|
||
/** | ||
* Get the full URL for the request. | ||
* | ||
* @return string | ||
*/ | ||
protected function getUrl() | ||
{ | ||
return $this->baseUrl . $this->endpoint; | ||
} | ||
} |
Oops, something went wrong.