Skip to content

feat: add Vonage Messages API adapter - #127

Open
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:fix/111-vonage-messages-api
Open

feat: add Vonage Messages API adapter#127
deepshekhardas wants to merge 2 commits into
utopia-php:mainfrom
deepshekhardas:fix/111-vonage-messages-api

Conversation

@deepshekhardas

Copy link
Copy Markdown

Port of PR #111 by bhardwajparth51.

Renames the existing Vonage adapter to VonageLegacy and adds a new VonageMessages adapter using the modern Vonage Messages API (V1) which is more cost-effective and versatile.

Changes:

  • Rename Vonage -> VonageLegacy (backward compat note)
  • Add VonageMessages adapter using Messages API v1
  • Add corresponding tests

@greptile-apps

greptile-apps Bot commented Jun 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR renames the existing Vonage SMS adapter to VonageLegacy and introduces a new VonageMessages adapter targeting the modern Vonage Messages API v1.

  • VonageLegacy: Renames VonageVonageLegacy with minor code style changes, but incorrectly removes the parent::__construct() call that was previously present and that every other SMS adapter in the codebase retains.
  • VonageMessages: New adapter implementing the Vonage Messages API v1 with Basic-auth, JSON body, and HTTP 202 success detection — but also omits parent::__construct(), leaving Adapter::$clientFactory and Adapter::$sendCounter as uninitialized typed properties that will throw a fatal PHP Error on the first send() call.
  • Tests: Both test files unconditionally call markTestSkipped with the real assertions in a block comment, giving no live coverage.

Confidence Score: 3/5

  • Both new adapters will throw a fatal PHP Error on every send attempt due to missing parent constructor calls.
  • Both VonageLegacy and VonageMessages omit parent::__construct(), leaving Adapter::$clientFactory (used in every request()) and Adapter::$sendCounter (accessed after every process()) as uninitialized typed properties. Every other SMS adapter (14 of them) calls parent::__construct() for exactly this reason. The original Vonage.php also called it — VonageLegacy explicitly removed it in this diff. As written, neither adapter can successfully deliver a message.
  • src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php and src/Utopia/Messaging/Adapter/SMS/VonageMessages.php both need parent::__construct() added to their constructors before either adapter can function.

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php Renamed from Vonage.php; incorrectly removed the parent::__construct() call that every other adapter in the codebase has, breaking all send operations. Also retains a stale TextMagic reference URL.
src/Utopia/Messaging/Adapter/SMS/VonageMessages.php New adapter using Vonage Messages API v1; missing parent::__construct() means $clientFactory and $sendCounter are uninitialized, so every send() call will throw a fatal PHP Error.
tests/Messaging/Adapter/SMS/VonageLegacyTest.php Test unconditionally skips with real assertions commented out; the test body (commented code) still references the old Vonage class name rather than VonageLegacy.
tests/Messaging/Adapter/SMS/VonageMessagesTest.php New test file that unconditionally skips via markTestSkipped with real assertions commented out; already flagged in a previous review thread.

Reviews (6): Last reviewed commit: "chore: remove old Vonage files after ren..." | Re-trigger Greptile

use Utopia\Messaging\Response;

class Vonage extends SMSAdapter
class VonageLegacy extends SMSAdapter

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Breaking rename with no backward-compatibility alias

Renaming VonageVonageLegacy drops the original class name entirely. Any downstream code using new \Utopia\Messaging\Adapter\SMS\Vonage(...) or use Utopia\Messaging\Adapter\SMS\Vonage will throw a fatal Class not found error after upgrading this library. The PR description mentions a "backward compat note" but no alias or deprecation shim is present in the diff. Consider adding class_alias(VonageLegacy::class, 'Utopia\\Messaging\\Adapter\\SMS\\Vonage'); at the bottom of this file (or in a dedicated compat file), or coordinate a semver-major release.

Comment on lines +14 to +35
public function testSendSMS(): void
{
$this->markTestSkipped('Vonage Messages credentials are not available.');

/*
$apiKey = \getenv('VONAGE_MESSAGES_API_KEY');
$apiSecret = \getenv('VONAGE_MESSAGES_API_SECRET');

$sender = new VonageMessages($apiKey, $apiSecret);

$message = new SMS(
to: [\getenv('VONAGE_MESSAGES_TO')],
content: 'Test Content',
from: \getenv('VONAGE_MESSAGES_FROM'),
);

$response = $sender->send($message);

$this->assertNotEmpty($response['results']);
$this->assertNotEmpty($response['results'][0]['success']);
*/
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Entire test body is dead code

The test immediately calls markTestSkipped and the real assertions are in a block comment rather than an if (! $creds) { markTestSkipped(); } guard pattern. Tests for other adapters (e.g., VonageLegacyTest) use live credentials gated by env vars. If VONAGE_MESSAGES_API_KEY etc. are simply not available in CI, the existing skip-unless-env-var pattern should be used here too, so the test actually executes when credentials are configured.

@deepshekhardas

Copy link
Copy Markdown
Author

Following up - this PR has been waiting for review. Happy to address any feedback or make changes.

deepshekhardas added 2 commits August 4, 2026 15:02
Renames the existing Vonage adapter to VonageLegacy and adds a new VonageMessages adapter using the modern Vonage Messages API (V1). Based on PR utopia-php#111 by bhardwajparth51.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant