Skip to content

VAPI-2823 Implement BRTC Endpoints API with models, controllers, and tests#87

Open
smoghe-bw wants to merge 29 commits intomainfrom
brtc-sdks
Open

VAPI-2823 Implement BRTC Endpoints API with models, controllers, and tests#87
smoghe-bw wants to merge 29 commits intomainfrom
brtc-sdks

Conversation

@smoghe-bw
Copy link
Copy Markdown

No description provided.

@smoghe-bw smoghe-bw requested review from a team as code owners March 11, 2026 16:43
@smoghe-bw smoghe-bw changed the title Implement BRTC Endpoints API with models, controllers, and tests VAPI-2823 Implement BRTC Endpoints API with models, controllers, and tests Mar 11, 2026
@bwappsec
Copy link
Copy Markdown

bwappsec commented Mar 11, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

…pointsController and update tests accordingly
… update APIController to use new auth method
…eController; update APIController to use generic auth method
…o implement configureBrtcAuth for BRTC endpoints
…uth to prevent interference with API requests
*/
protected function configureAuth(&$headers, $authType)
{
if (!empty($this->config->getAccessToken()) &&
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is all of this deleted? removing this is essentially removing OAuth support from every endpoint in the SDK, which we definitely do not want to do. All of this needs to be brought back, BRTC should be able to use this in its API calls to also support OAuth. We'll probably need to set up the username/password stuff in the configuration and then add logic to the configure auth function to set those as a fallback

*
* @param array $headers The headers for the request (passed by reference)
*/
protected function configureOAuth2Auth(&$headers)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is unnecessary, the SDK already supports OAuth, so we don't need a BRTC specific oauth function, we need to remove this and use the pre-existing logic that was in the configureAuth function


require_once "Verb.php";

class Connect extends Verb {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is missing the eventCallbackUrl attribute


class Connect extends Verb {
/**
* @var array
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @var array
* @var array(Endpoint)

*/
public function toBxml(DOMDocument $doc): DOMElement {
$element = $doc->createElement("Connect");
foreach ($this->endpoints as $endpoint) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

id like to add the isset check we do in other verbs here

Comment on lines +271 to +272
$this->assertNotNull($createResp->endpointId);
$this->assertEquals('WEBRTC', $createResp->type);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we need to be asserting as many fields on the response as possible, feel free to copy what i did for the tn lookup tests

$this->assertEquals('WEBRTC', $createResp->type);

// List endpoints
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same as above for the try catch and including more assertions

$this->assertContains($createResp->endpointId, $ids, 'Created endpoint should be in list');

// Get endpoint
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same as above

// $voiceClient->updateEndpointBxml($accountId, $createResp->endpointId, $bxml);

// Delete endpoint
try {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can remove try catch

$this->assertEquals(204, $deleteResp->getStatusCode());
}

public function testCreateEndpointResponseFields() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this and every test after are all unnecessary, we need to be asserting as many fields as possible in our 1 test run, like I mentioned in one of the other SDKs, these tests are strictly to test the SDK functionality, not the API.

smoghe-bw and others added 2 commits March 27, 2026 14:09
- Restore original configureAuth with OAuth2 client_credentials support
  that was accidentally deleted; remove redundant configureOAuth2Auth
- Move all BRTC endpoints out of Voice controller into new src/BRTC/
  module with its own BRTCClient and APIController
- Add BRTCDEFAULT server URL constant and configuration mapping
- Register getBRTC() accessor on BandwidthClient
- Fix Connect BXML: add eventCallbackUrl attribute, isset guards,
  correct @var doc to array(Endpoint)
- Fix Endpoint BXML: rename property to endpointId, render as text
  content (createTextNode) instead of XML attribute
- Fix BXML test expected output for Endpoint text content
- Create proper response wrapper models matching API spec:
  CreateEndpointResponse (links/data/errors),
  CreateEndpointResponseData (with token field),
  EndpointResponse, ListEndpointsResponse (with page),
  Endpoints (list summary without devices)
- Fix Device model fields: deviceId, deviceName, status,
  creationTimestamp (matching Python SDK spec)
- Fix Endpoint model fields to match spec: endpointId, type, status,
  creationTimestamp, expirationTimestamp, tag, devices
- Fix EndpointEvent model to match spec: add eventTime, eventType,
  device; remove fabricated fields
- Fix CreateEndpointRequest: direction is required (no null default),
  add connectionMetadata field
- Replace ErrorResponse with ErrorObject (type, description)
- Replace Page with spec-correct fields (pageSize, totalElements,
  totalPages, pageNumber)
- Remove Enums.php (use plain strings per SDK convention)
- Add Link model for BRTC responses
- Fix listEndpoints to accept explicit query params (type, status,
  direction, pageToken, pageSize) following getMessages pattern
- All BRTC API methods use configureAuth and BRTCDEFAULT server URL
- Update smoke tests to use BRTC client and wrapped response models

Generated from Claude9 with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Removed all try/catch wrappers from BRTC API calls — let tests fail
  naturally on exceptions, matching the pattern used by TN lookup and
  other existing smoke tests
- Removed 6 redundant test methods (testCreateEndpointResponseFields,
  testGetEndpointFields, testListEndpointsContainsCreated,
  testListEndpointsEachItemIsEndpointsInstance,
  testCreateMultipleEndpointsAndDeleteAll,
  testDeleteEndpointRemovedFromList)
- Consolidated all assertions into testCreateListGetDeleteEndpoint
  following the create → list → get → delete flow
- Added thorough field assertions on each response (status,
  creationTimestamp, expirationTimestamp, tag, first list element)

Generated from Claude9 with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

3 participants