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. The core logic is sound, but both adapters omit the parent::__construct() call required by the base Adapter class.

  • VonageLegacy: the diff explicitly removes parent::__construct() that was present in the original Vonage adapter, leaving $this->sendCounter uninitialized and causing a fatal error on every send() call.
  • VonageMessages: new adapter also omits parent::__construct(), suffering the same fatal initialization error; every other SMS adapter in the repository (14 total) includes this call.
  • VonageMessagesTest: the actual test assertions are inside a block comment and the method is unconditionally skipped, so no behavior is verified by CI.

Confidence Score: 4/5

Both adapters will throw a fatal uninitialized typed-property error on every send() call — needs fixes before merge.

The removal of parent::__construct() from VonageLegacy is a regression, and VonageMessages was never given the call. Both adapters will throw a fatal error the moment send() is invoked. The issues are isolated to two files and the fix is mechanical, but the adapters are fully broken as-is.

src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php and src/Utopia/Messaging/Adapter/SMS/VonageMessages.php both need parent::__construct() restored/added.

Important Files Changed

Filename Overview
src/Utopia/Messaging/Adapter/SMS/VonageLegacy.php Renames Vonage → VonageLegacy; removes parent::__construct() which leaves the telemetry counter uninitialized and causes a fatal error on every send() call.
src/Utopia/Messaging/Adapter/SMS/VonageMessages.php New adapter for Vonage Messages API v1; omits parent::__construct(), causing the same fatal uninitialized-property error as VonageLegacy on every send() call.
tests/Messaging/Adapter/SMS/VonageLegacyTest.php Renamed from VonageTest; test body is fully skipped via markTestSkipped (matches pattern of the original file).
tests/Messaging/Adapter/SMS/VonageMessagesTest.php New test file; entire test body is dead code — actual assertions are in a block comment rather than gated by a credential env-var check.

Reviews (3): 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 deepshekhardas force-pushed the fix/111-vonage-messages-api branch from 66ece4c to c039ea6 Compare June 17, 2026 09:17
deepshekhardas added 2 commits July 10, 2026 10:31
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 c039ea6 to 19c976f Compare July 10, 2026 05:01
@deepshekhardas

Copy link
Copy Markdown
Author

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

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