getCountryCode

This commit is contained in:
shimon 2024-05-08 14:23:11 +03:00
parent 17b9f136f1
commit 88e67c8d58
2 changed files with 555 additions and 204 deletions

734
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -441,31 +441,24 @@ class Messaging extends Action
try {
$adapter->send($data);
$countryCode = $sms->getCountryCode($payload['recipient']);
if (!empty($countryCode)) {
$queueForUsage
->addMetric(str_replace('{countryCode}', $countryCode, METRIC_MESSAGES_COUNTRY_CODE), 1);
}
$queueForUsage
->setProject($project)
->addMetric(METRIC_MESSAGES, 1)
->trigger();
} catch (\Exception $error) {
throw new Exception('Error sending message: ' . $error->getMessage(), 500);
}
$countryCode = $adapter->getCountryCode($message['to']);
if (!empty($countryCode)) {
$queueForUsage
->addMetric(str_replace('{countryCode}', $countryCode, METRIC_MESSAGES_COUNTRY_CODE), 1);
}
$queueForUsage
->addMetric(METRIC_MESSAGES, 1)
->setProject($project)
->trigger();
} catch (\Throwable $e) {
throw new \Exception('Failed sending to targets with error: ' . $e->getMessage());
} catch (\Throwable $th) {
throw new \Exception('Failed sending to targets with error: ' . $th->getMessage());
}
};
}, $batches));
}
private function getSmsAdapter(Document $provider): ?SMSAdapter
{
$credentials = $provider->getAttribute('credentials');