This repository was archived by the owner on Mar 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathCallCodeResponse.php
More file actions
50 lines (38 loc) · 1.72 KB
/
Copy pathCallCodeResponse.php
File metadata and controls
50 lines (38 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Zelenin\SmsRu\Response;
class CallCodeResponse extends AbstractResponse
{
/** @var int|null */
public $checkCode;
/** @var float|null */
public $balance;
/** @var float|null */
public $cost;
/** @var string|null */
public $callId;
protected $availableDescriptions = [
'100' => 'Запрос выполнен.',
'200' => 'Неправильный api_id.',
'210' => 'Используется GET, где необходимо использовать POST.',
'211' => 'Метод не найден.',
'220' => 'Сервис временно недоступен, попробуйте чуть позже.',
'300' => 'Неправильный token (возможно истек срок действия, либо ваш IP изменился).',
'301' => 'Неправильный пароль, либо пользователь не найден.',
'302' => 'Пользователь авторизован, но аккаунт не подтвержден (пользователь не ввел код, присланный в регистрационной смс).',
];
public static function makeByJson(array $json)
{
if ($json['status'] == 'ERROR') {
$code = '400';
$response = new CallCodeResponse($code);
$response->availableDescriptions[$code] = $json['status_text'];
return $response;
}
$response = new CallCodeResponse('100');
$response->checkCode = $json['code'];
$response->balance = $json['balance'];
$response->cost = $json['cost'];
$response->callId = $json['call_id'];
return $response;
}
}