getAttribute('credentials'); return match ($record->getAttribute('provider')) { 'twilio' => new Twilio($credentials['accountSid'], $credentials['authToken']), 'text-magic' => new TextMagic($credentials['username'], $credentials['apiKey']), 'telesign' => new Telesign($credentials['username'], $credentials['password']), 'msg91' => new Msg91($credentials['senderId'], $credentials['authKey']), 'vonage' => new Vonage($credentials['apiKey'], $credentials['apiSecret']), default => null }; } function push($record): ?PushAdapter { $credentials = $record->getAttribute('credentials'); return match ($record->getAttribute('provider')) { 'apns' => new APNS( $credentials['authKey'], $credentials['authKeyId'], $credentials['teamId'], $credentials['bundleId'], $credentials['endpoint'] ), 'fcm' => new FCM($credentials['serverKey']), default => null }; } public function email($record): ?EmailAdapter { $credentials = $record->getAttribute('credentials'); return match ($record->getAttribute('provider')) { 'mailgun' => new Mailgun($credentials['apiKey'], $credentials['domain']), 'sendgrid' => new SendGrid($credentials['apiKey']), default => null }; } public function init(): void { } public function run(): void { $providerId = $this->args['providerId']; $providerRecord = $this ->getConsoleDB() ->getDocument('providers', $providerId); $provider = match ($providerRecord->getAttribute('type')) {//stubbbbbbed. 'sms' => $this->sms($providerRecord), 'push' => $this->push($providerRecord), 'email' => $this->email($providerRecord), default => null }; // Query for the provider // switch on provider name // call function passing needed credentials returns required provider. $messageId = $this->args['messageId']; $message = $this ->getConsoleDB() ->getDocument('messages', $messageId); // Contrust Message Object according to each provider type. // Send the message using respective adapter } function shutdown(): void { } }