Send status report

This commit is contained in:
Marko Jovanovic 2025-10-14 14:44:17 +02:00
parent 533c7f533e
commit d882308799

View File

@ -123,20 +123,22 @@ class ContactUncontactedCommand extends Command
} }
} }
try { if ($this->status_number) {
$responseStatus = $this->httpClient->request('POST', self::$apiEndpoint, [ $io->info('Sending status message...');
'headers' => [ try {
'X-CM-PRODUCTTOKEN' => $this->sms_gateway_api_key, $this->httpClient->request('POST', self::$apiEndpoint, [
'Accept' => 'application/json', 'headers' => [
'Content-Type' => 'application/json' 'X-CM-PRODUCTTOKEN' => $this->sms_gateway_api_key,
], 'Accept' => 'application/json',
'Content-Type' => 'application/json'
],
'body' => "{ 'body' => "{
'messages': { 'msg': [{ 'messages': { 'msg': [{
'allowedChannels': ['SMS'], 'allowedChannels': ['SMS'],
'from': 'UKB', 'from': 'UKB',
'to': [ 'to': [
{ 'number': '004917672121270' } { 'number': '{$this->status_number}' }
], ],
'body': { 'body': {
'type': 'auto', 'type': 'auto',
@ -147,12 +149,12 @@ class ContactUncontactedCommand extends Command
'reference': 'UKB' 'reference': 'UKB'
}] }}" }] }}"
]); ]);
} catch (Exception $e) { } catch (Exception $e) {
$io->error(sprintf('An error occurred contacting the API for number %s: %s', '004917672121270', $e->getMessage())); $io->error(sprintf('An error occurred contacting the API for number %s: %s', $this->status_number, $e->getMessage()));
}
} }
// Finalize all database changes // Finalize all database changes
$this->entityManager->flush(); $this->entityManager->flush();
$io->progressFinish(); $io->progressFinish();