1 | <?php |
||
11 | class Twilio |
||
12 | { |
||
13 | /** @var TwilioService */ |
||
14 | protected $twilioService; |
||
15 | |||
16 | /** @var TwilioConfig */ |
||
17 | public $config; |
||
18 | |||
19 | 12 | 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) |
|
52 | |||
53 | /** |
||
54 | * Send an sms message using the Twilio Service. |
||
55 | * |
||
56 | * @param TwilioSmsMessage $message |
||
57 | * @param string|null $to |
||
58 | * |
||
59 | * @return MessageInstance |
||
60 | * @throws CouldNotSendNotification |
||
61 | * @throws TwilioException |
||
62 | */ |
||
63 | 9 | protected function sendSmsMessage(TwilioSmsMessage $message, ?string $to): MessageInstance |
|
105 | |||
106 | /** |
||
107 | * Make a call using the Twilio Service. |
||
108 | * |
||
109 | * @param TwilioCallMessage $message |
||
110 | * @param string|null $to |
||
111 | * |
||
112 | * @return CallInstance |
||
113 | * @throws TwilioException |
||
114 | * @throws CouldNotSendNotification |
||
115 | */ |
||
116 | 2 | protected function makeCall(TwilioCallMessage $message, ?string $to): CallInstance |
|
141 | |||
142 | /** |
||
143 | * Get the from address from message, or config. |
||
144 | * |
||
145 | * @param TwilioMessage $message |
||
146 | * @return string|null |
||
147 | */ |
||
148 | 11 | protected function getFrom(TwilioMessage $message): ?string |
|
152 | |||
153 | /** |
||
154 | * Get the messaging service SID from message, or config. |
||
155 | * |
||
156 | * @param TwilioSmsMessage $message |
||
157 | * @return string|null |
||
158 | */ |
||
159 | 9 | protected function getMessagingServiceSid(TwilioSmsMessage $message): ?string |
|
163 | |||
164 | /** |
||
165 | * Get the alphanumeric sender from config, if one exists. |
||
166 | * |
||
167 | * @return string|null |
||
168 | */ |
||
169 | 2 | protected function getAlphanumericSender(): ?string |
|
173 | |||
174 | /** |
||
175 | * @param array $params |
||
176 | * @param TwilioMessage $message |
||
177 | * @param array $optionalParams |
||
178 | * @return Twilio |
||
179 | */ |
||
180 | 10 | protected function fillOptionalParams(&$params, $message, $optionalParams): self |
|
190 | } |
||
191 |