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