public function SimpleGateway::processIncoming in SMS simple gateway 8
Process an incoming message POST request.
This callback expects a 'messages' POST value containing JSON.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
\Drupal\sms\Entity\SmsGatewayInterface $sms_gateway: The gateway instance.
Return value
\Drupal\sms\SmsProcessingResponse A SMS processing response task.
File
- src/
Plugin/ SmsGateway/ SimpleGateway.php, line 415
Class
- SimpleGateway
- This plugin handles sending SMSes through most GET & POST based SMS Gateways.
Namespace
Drupal\sms_simplegateway\Plugin\SmsGatewayCode
public function processIncoming(Request $request, SmsGatewayInterface $sms_gateway) {
$number = $request
->get($this->configuration['receive_number_field']);
$text = $request
->get($this->configuration['receive_message_field']);
$gwnumber = $request
->get($this->configuration['receive_gwnumber_field']);
$report = (new SmsDeliveryReport())
->setRecipient($gwnumber)
->setTimeDelivered(\Drupal::time()
->getRequestTime());
$result = (new SmsMessageResult())
->setReports([
$report,
]);
$message = (new SmsMessage())
->addRecipient($gwnumber)
->setMessage($text)
->setSender($number)
->setResult($result)
->setGateway($sms_gateway)
->setDirection(Direction::INCOMING);
$response = new Response('', 200);
$task = (new SmsProcessingResponse())
->setResponse($response)
->setMessages([
$message,
]);
return $task;
}