| 1 | <?php |
||
| 8 | abstract class Request implements RequestInterface |
||
| 9 | { |
||
| 10 | const BASE_URL = 'https://lcab.smsintel.ru/API/XML/'; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var HttpInterface |
||
| 14 | */ |
||
| 15 | protected $client; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $login; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $password; |
||
| 26 | |||
| 27 | public function __construct(HttpInterface $http) |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @return array |
||
| 34 | */ |
||
| 35 | public static function getAllowedMethods() |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param string $login |
||
| 42 | * @param string $password |
||
| 43 | * @return $this |
||
| 44 | */ |
||
| 45 | public function setCredentials($login, $password) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Make the request to API |
||
| 55 | * |
||
| 56 | * @param string $action |
||
| 57 | * @param array $params |
||
| 58 | * @return array|null |
||
| 59 | */ |
||
| 60 | public function exec($action, $params = [ ]) |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @param string $action |
||
| 71 | * @return string |
||
| 72 | */ |
||
| 73 | abstract protected function makeEndPoint($action); |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @param array $params |
||
| 77 | * @return string |
||
| 78 | */ |
||
| 79 | protected function createRequestBody(array $params) |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @param array $requestBody |
||
| 93 | * @return mixed |
||
| 94 | */ |
||
| 95 | abstract protected function formatRequestBody(array $requestBody); |
||
| 96 | |||
| 97 | abstract protected function parseResponse($response); |
||
| 98 | } |