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 adds a new VonageMessages adapter targeting the modern Vonage Messages API v1, and renames the existing Vonage adapter to VonageLegacy for backward context.

  • VonageMessages (new): Authenticates with HTTP Basic auth, posts to https://api.vonage.com/v1/messages, strips + from to/from, enforces a non-empty from, and maps a 202 response to success.
  • VonageLegacy (renamed): Functionally unchanged aside from the class/constant name update and the removal of parent::__construct(), which is a regression shared by both adapters in this PR.

Confidence Score: 3/5

Both adapters will throw a fatal PHP Error on every send call due to an uninitialized typed property in the base class.

The base Adapter class initializes a typed private Counter $sendCounter in its constructor. VonageMessages never calls parent::__construct(), and this PR also removes the existing call from VonageLegacy. Any send() invocation will reach recordSend() and crash with a fatal Error about the uninitialized typed property. Both adapters are broken in the same way.

Both VonageMessages.php and VonageLegacy.php need parent::__construct() restored before merging.

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/VonageMessages.php New Vonage Messages API v1 adapter — missing parent::__construct() causes a fatal PHP Error on every send() call due to uninitialized typed $sendCounter property in the base class.
src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php Renamed from Vonage.php; parent::__construct() was removed in this PR, breaking telemetry counter initialization and causing a fatal Error on any send.
tests/Messaging/Adapter/SMS/VonageLegacyTest.php Renamed from VonageTest.php; still references old Vonage class name in commented-out test body.
tests/Messaging/Adapter/SMS/VonageMessagesTest.php New test file; unconditionally skipped with assertions left in a block comment rather than gated behind an env-var check.

Reviews (2): 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 added 2 commits June 17, 2026 14:47
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.
@deepshekhardas deepshekhardas force-pushed the fix/111-vonage-messages-api branch from 66ece4c to c039ea6 Compare June 17, 2026 09:17
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