-
Notifications
You must be signed in to change notification settings - Fork 10
VAPI-3160: Add <Refer> BXML Verb Support #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
s-aher
wants to merge
5
commits into
main
Choose a base branch
from
VAPI-3160
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+416
−2
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b592e0
VAPI-3160: Add Refer BXML implementation and related tests
s-aher dfe1f42
VAPI-3160: Add Refer BXML implementation and related tests
s-aher abf5392
Fix testSyncTnLookup: remove assertion on empty links array
Copilot ee9a69d
VAPI-3160: Fixed review commit
s-aher 7936e76
Merge remote-tracking branch 'origin/VAPI-3160' into VAPI-3160
s-aher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| <?php | ||
| /** | ||
| * Refer.php | ||
| * | ||
| * Implementation of the BXML Refer tag | ||
| * | ||
| * * @copyright Bandwidth INC | ||
| */ | ||
|
|
||
| namespace BandwidthLib\Voice\Bxml; | ||
|
|
||
| use DOMDocument; | ||
| use DOMElement; | ||
|
|
||
| require_once "Verb.php"; | ||
|
|
||
| class Refer extends Verb { | ||
| /** | ||
| * @var string | ||
| */ | ||
| private $referCompleteUrl; | ||
| /** | ||
| * @var string | ||
| */ | ||
| private $referCompleteMethod; | ||
| /** | ||
| * @var string | ||
| */ | ||
| private $tag; | ||
| /** | ||
| * @var ReferSipUri|SipUri | ||
| */ | ||
| private $sipUri; | ||
|
|
||
| /** | ||
| * Sets the referCompleteUrl attribute for Refer | ||
| * | ||
| * @param string $referCompleteUrl The URL to receive the refer complete callback | ||
| */ | ||
| public function referCompleteUrl(string $referCompleteUrl): Refer { | ||
| $this->referCompleteUrl = $referCompleteUrl; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the referCompleteMethod attribute for Refer | ||
| * | ||
| * @param string $referCompleteMethod The HTTP method for the refer complete callback (GET or POST) | ||
| */ | ||
| public function referCompleteMethod(string $referCompleteMethod): Refer { | ||
| $this->referCompleteMethod = $referCompleteMethod; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the tag attribute for Refer | ||
| * | ||
| * @param string $tag A custom string to be included in callbacks | ||
| */ | ||
| public function tag(string $tag): Refer { | ||
| $this->tag = $tag; | ||
| return $this; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the SipUri child element for Refer. | ||
| * Prefer ReferSipUri to avoid accidentally serializing Transfer-specific attributes. | ||
| * | ||
| * @param ReferSipUri|SipUri $sipUri The SipUri destination for the REFER | ||
| */ | ||
| public function sipUri($sipUri): Refer { | ||
| $this->sipUri = $sipUri; | ||
| return $this; | ||
| } | ||
|
|
||
| public function toBxml(DOMDocument $doc): DOMElement { | ||
| if (!isset($this->sipUri)) { | ||
| throw new \InvalidArgumentException('Refer requires a SipUri child element.'); | ||
| } | ||
|
|
||
| $element = $doc->createElement("Refer"); | ||
|
|
||
| if(isset($this->referCompleteUrl)) { | ||
| $element->setAttribute("referCompleteUrl", $this->referCompleteUrl); | ||
| } | ||
|
|
||
| if(isset($this->referCompleteMethod)) { | ||
| $element->setAttribute("referCompleteMethod", $this->referCompleteMethod); | ||
| } | ||
|
|
||
| if(isset($this->tag)) { | ||
| $element->setAttribute("tag", $this->tag); | ||
| } | ||
|
|
||
| $element->appendChild($this->sipUri->toBxml($doc)); | ||
|
|
||
| return $element; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?php | ||
| /** | ||
| * ReferSipUri.php | ||
| * | ||
| * Implementation of the BXML SipUri tag for use inside the Refer verb. | ||
| * Unlike the Transfer SipUri, this only accepts a SIP URI — no transfer-specific attributes. | ||
| * | ||
| * * @copyright Bandwidth INC | ||
| */ | ||
|
|
||
| namespace BandwidthLib\Voice\Bxml; | ||
|
|
||
| use DOMDocument; | ||
| use DOMElement; | ||
|
|
||
| require_once "Verb.php"; | ||
|
|
||
| class ReferSipUri extends Verb { | ||
| /** | ||
| * @var string | ||
| */ | ||
| private $sip; | ||
|
|
||
| /** | ||
| * Constructor for ReferSipUri | ||
| * | ||
| * @param string $sip The SIP URI destination (must start with "sip:") | ||
| */ | ||
| public function __construct(string $sip) { | ||
| $this->sip = $sip; | ||
| } | ||
|
|
||
| public function toBxml(DOMDocument $doc): DOMElement { | ||
| $element = $doc->createElement("SipUri"); | ||
| $element->appendChild($doc->createTextNode($this->sip)); | ||
| return $element; | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| <?php | ||
| /* | ||
| * BandwidthLib | ||
| * | ||
| * This file was manually added to support the Refer BXML verb. | ||
| */ | ||
|
|
||
| namespace BandwidthLib\Voice\Models; | ||
|
|
||
| /** | ||
| * This object represents fields included in callbacks related to refer complete events. | ||
| * Fired when the REFER flow completes (success or failure), only if referCompleteUrl is set. | ||
| */ | ||
| class ReferCompleteCallback implements \JsonSerializable | ||
| { | ||
| /** | ||
| * The event type of the callback. Always "referComplete". | ||
| * @var string|null $eventType public property | ||
| */ | ||
| public $eventType; | ||
|
|
||
| /** | ||
| * The time the event occurred, in ISO 8601 format. | ||
| * @var string|null $eventTime public property | ||
| */ | ||
| public $eventTime; | ||
|
|
||
| /** | ||
| * The user's Bandwidth account ID. | ||
| * @var string|null $accountId public property | ||
| */ | ||
| public $accountId; | ||
|
|
||
| /** | ||
| * The ID of the application associated with the call. | ||
| * @var string|null $applicationId public property | ||
| */ | ||
| public $applicationId; | ||
|
|
||
| /** | ||
| * The phone number that received the call, in E.164 format. | ||
| * @var string|null $from public property | ||
| */ | ||
| public $from; | ||
|
|
||
| /** | ||
| * The phone number that made the call, in E.164 format. | ||
| * @var string|null $to public property | ||
| */ | ||
| public $to; | ||
|
|
||
| /** | ||
| * The direction of the call. Always "inbound" for refer events. | ||
| * @var string|null $direction public property | ||
| */ | ||
| public $direction; | ||
|
|
||
| /** | ||
| * The unique ID of the call. | ||
| * @var string|null $callId public property | ||
| */ | ||
| public $callId; | ||
|
|
||
| /** | ||
| * The full URL of the call resource. | ||
| * @var string|null $callUrl public property | ||
| */ | ||
| public $callUrl; | ||
|
|
||
| /** | ||
| * The time the call started, in ISO 8601 format. | ||
| * @var string|null $startTime public property | ||
| */ | ||
| public $startTime; | ||
|
|
||
| /** | ||
| * The time the call was answered, in ISO 8601 format. | ||
| * @var string|null $answerTime public property | ||
| */ | ||
| public $answerTime; | ||
|
|
||
| /** | ||
| * The outcome of the REFER operation. Either "success" or "failure". | ||
| * @var string|null $referCallStatus public property | ||
| */ | ||
| public $referCallStatus; | ||
|
|
||
| /** | ||
| * The SIP response code for the REFER request (e.g. 202, 405). | ||
| * Absent when the REFER was not sent. Present on both success and failure. | ||
| * @var int|null $referSipResponseCode public property | ||
| */ | ||
| public $referSipResponseCode; | ||
|
|
||
| /** | ||
| * The SIP response code from the NOTIFY (e.g. 200, 404, 486). | ||
| * Absent on REFER rejection or NOTIFY timeout. | ||
| * @var int|null $notifySipResponseCode public property | ||
| */ | ||
| public $notifySipResponseCode; | ||
|
|
||
| /** | ||
| * A custom string provided in the Refer BXML tag, if any. | ||
| * @var string|null $tag public property | ||
| */ | ||
| public $tag; | ||
|
|
||
| /** | ||
| * Constructor to set initial or default values of member properties | ||
| */ | ||
| public function __construct() | ||
| { | ||
| if (15 == func_num_args()) { | ||
| $this->eventType = func_get_arg(0); | ||
| $this->eventTime = func_get_arg(1); | ||
| $this->accountId = func_get_arg(2); | ||
| $this->applicationId = func_get_arg(3); | ||
| $this->from = func_get_arg(4); | ||
| $this->to = func_get_arg(5); | ||
| $this->direction = func_get_arg(6); | ||
| $this->callId = func_get_arg(7); | ||
| $this->callUrl = func_get_arg(8); | ||
| $this->startTime = func_get_arg(9); | ||
| $this->answerTime = func_get_arg(10); | ||
| $this->referCallStatus = func_get_arg(11); | ||
| $this->referSipResponseCode = func_get_arg(12); | ||
| $this->notifySipResponseCode = func_get_arg(13); | ||
| $this->tag = func_get_arg(14); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Encode this object to JSON | ||
| */ | ||
| public function jsonSerialize(): array | ||
| { | ||
| $json = array(); | ||
| $json['eventType'] = $this->eventType; | ||
| $json['eventTime'] = $this->eventTime; | ||
| $json['accountId'] = $this->accountId; | ||
| $json['applicationId'] = $this->applicationId; | ||
| $json['from'] = $this->from; | ||
| $json['to'] = $this->to; | ||
| $json['direction'] = $this->direction; | ||
| $json['callId'] = $this->callId; | ||
| $json['callUrl'] = $this->callUrl; | ||
| $json['startTime'] = $this->startTime; | ||
| $json['answerTime'] = $this->answerTime; | ||
| $json['referCallStatus'] = $this->referCallStatus; | ||
| $json['referSipResponseCode'] = $this->referSipResponseCode; | ||
| $json['notifySipResponseCode'] = $this->notifySipResponseCode; | ||
| $json['tag'] = $this->tag; | ||
|
|
||
| return array_filter($json); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BLOCKER] Two assertions silently removed from
testSyncTnLookup— unrelated to this PRThe deleted lines:
…have nothing to do with
<Refer>. Removing assertions from an existing integration test to make it pass is a hidden regression. What broke here? Iflinksno longer exists on the response model, that should be a separate PR with an explanation.