1 | <?php |
||
11 | class Twilio |
||
12 | { |
||
13 | /** @var TwilioService */ |
||
14 | protected $twilioService; |
||
15 | |||
16 | /** @var TwilioConfig */ |
||
17 | private $config; |
||
18 | |||
19 | 14 | public function __construct(TwilioService $twilioService, TwilioConfig $config) |
|
24 | |||
25 | /** |
||
26 | * Send a TwilioMessage to the a phone number. |
||
27 | * |
||
28 | * @param TwilioMessage $message |
||
29 | * @param string|null $to |
||
30 | * @param bool $useAlphanumericSender |
||
31 | * |
||
32 | * @return mixed |
||
33 | * @throws TwilioException |
||
34 | * @throws CouldNotSendNotification |
||
35 | */ |
||
36 | 12 | public function sendMessage(TwilioMessage $message, ?string $to, bool $useAlphanumericSender = false) |
|
60 | |||
61 | /** |
||
62 | * Send an sms message using the Twilio Service. |
||
63 | * |
||
64 | * @param TwilioSmsMessage $message |
||
65 | * @param string|null $to |
||
66 | * |
||
67 | * @return MessageInstance |
||
68 | * @throws CouldNotSendNotification |
||
69 | * @throws TwilioException |
||
70 | */ |
||
71 | 9 | protected function sendSmsMessage(TwilioSmsMessage $message, ?string $to): MessageInstance |
|
113 | |||
114 | /** |
||
115 | * Make a call using the Twilio Service. |
||
116 | * |
||
117 | * @param TwilioCallMessage $message |
||
118 | * @param string|null $to |
||
119 | * |
||
120 | * @return CallInstance |
||
121 | * @throws TwilioException |
||
122 | * @throws CouldNotSendNotification |
||
123 | */ |
||
124 | 2 | protected function makeCall(TwilioCallMessage $message, ?string $to): CallInstance |
|
149 | |||
150 | /** |
||
151 | * Get the from address from message, or config. |
||
152 | * |
||
153 | * @param TwilioMessage $message |
||
154 | * @return string|null |
||
155 | */ |
||
156 | 11 | protected function getFrom(TwilioMessage $message): ?string |
|
160 | |||
161 | /** |
||
162 | * Get the messaging service SID from message, or config. |
||
163 | * |
||
164 | * @param TwilioSmsMessage $message |
||
165 | * @return string|null |
||
166 | */ |
||
167 | 9 | protected function getMessagingServiceSid(TwilioSmsMessage $message): ?string |
|
171 | |||
172 | /** |
||
173 | * Get the alphanumeric sender from config, if one exists. |
||
174 | * |
||
175 | * @return string|null |
||
176 | */ |
||
177 | 2 | protected function getAlphanumericSender(): ?string |
|
181 | |||
182 | /** |
||
183 | * @param array $params |
||
184 | * @param TwilioMessage $message |
||
185 | * @param array $optionalParams |
||
186 | * @return Twilio |
||
187 | */ |
||
188 | 10 | protected function fillOptionalParams(&$params, $message, $optionalParams): self |
|
198 | } |
||
199 |