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 adds a new VonageMessages adapter that targets the modern Vonage Messages API v1 (HTTP 202 flow).

  • VonageLegacy is a near-direct rename of the old Vonage class with minor cosmetic refactors; it removes the parent::__construct() call that was present in the original, which is a breaking regression.
  • VonageMessages is a new adapter using Basic-auth over the https://api.vonage.com/v1/messages endpoint with proper JSON body and 202-accepted response handling.
  • Both test files immediately call markTestSkipped and place real assertions in block comments, so no assertions are exercised in CI.

Confidence Score: 3/5

Not safe to merge as-is — both new adapters will throw a fatal PHP error on every send attempt.

Both VonageLegacy and VonageMessages drop the parent::__construct() call that the Adapter base class requires to initialize $sendCounter (a non-nullable typed property) and the constructor-promoted readonly $clientFactory. The very first thing request() does is read $this->clientFactory, which is an uninitialized typed property — PHP 8 throws a fatal error there before any HTTP call is made.

Both VonageLegacy.php and VonageMessages.php need parent::__construct() restored in their constructors before either adapter can function.

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php Renamed from Vonage.php; drops parent::__construct() (breaking regression), retains stale TextMagic reference comment
src/Utopia/Messaging/Adapter/SMS/VonageMessages.php New Messages API v1 adapter; missing parent::__construct() makes all send operations crash with a fatal PHP error on first HTTP request
tests/Messaging/Adapter/SMS/VonageLegacyTest.php New test skeleton; all assertions are commented out; commented code references old Vonage class name and lacks import for VonageLegacy
tests/Messaging/Adapter/SMS/VonageMessagesTest.php New test skeleton; unconditionally calls markTestSkipped so the real assertions in the block comment are never exercised

Reviews (4): 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 July 24, 2026 13:04
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