| Total Complexity | 7 |
| Total Lines | 78 |
| Duplicated Lines | 0 % |
| Coverage | 94.74% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class SMSDRRegisterCallbackRequest extends SMSClientRequest |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | protected $body; |
||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $senderAddress; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * RegisterSMSDRCallbackRequest constructor. |
||
| 21 | * |
||
| 22 | * @param $callbackUri |
||
| 23 | * @param $senderAddress |
||
| 24 | * @throws \Exception |
||
| 25 | */ |
||
| 26 | 2 | public function __construct($callbackUri, $senderAddress) |
|
| 27 | { |
||
| 28 | 2 | $this->enforceHttpSecureProtocol($callbackUri); |
|
| 29 | |||
| 30 | 1 | if (! $senderAddress) { |
|
| 31 | throw new Exception('Missing sender address'); |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | $this->senderAddress = 'tel:'.$this->normalizePhoneNumber($senderAddress); |
|
| 35 | |||
| 36 | 1 | $this->body = [ |
|
| 37 | "deliveryReceiptSubscription" => [ |
||
| 38 | "callbackReference" => [ |
||
| 39 | 1 | "notifyURL" => $callbackUri |
|
| 40 | ] |
||
| 41 | ] |
||
| 42 | ]; |
||
| 43 | 1 | } |
|
| 44 | |||
| 45 | /** |
||
| 46 | * Http request method. |
||
| 47 | * |
||
| 48 | * @return string |
||
| 49 | */ |
||
| 50 | 1 | public function method() |
|
| 51 | { |
||
| 52 | 1 | return 'POST'; |
|
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * The uri for the current request. |
||
| 57 | * |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | 1 | public function uri() |
|
| 61 | { |
||
| 62 | 1 | return static::BASE_URI.'/smsmessaging/v1/outbound/'.urlencode($this->senderAddress).'/subscriptions'; |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Http request options. |
||
| 67 | * |
||
| 68 | * @return array |
||
| 69 | */ |
||
| 70 | 1 | public function options() |
|
| 75 | ]; |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @param $callbackUri |
||
| 80 | */ |
||
| 81 | 2 | protected function enforceHttpSecureProtocol($callbackUri) |
|
| 86 | ); |
||
| 87 | } |
||
| 88 | 1 | } |
|
| 90 |