-
Notifications
You must be signed in to change notification settings - Fork 2
VAPI-3164 Add <Refer> BXML verb support #242
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
nkuma246
wants to merge
17
commits into
main
Choose a base branch
from
VAPI-3164
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.
+115
−0
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2f65182
VAPI-3164
nkuma246 82bc735
Merge branch 'main' into VAPI-3164
nkuma246 110109b
VAPI-3164 Changes done by open-api
nkuma246 3f88024
Merge branch 'main' into VAPI-3164
atelegu baa0abd
VAPI-3164 Changes done by open-api
nkuma246 593bdba
VAPI-3164
atelegu dbb4993
Merge branch 'main' into VAPI-3164
atelegu ce9f136
VAPI-3164
atelegu 18dcce9
Merge remote-tracking branch 'origin/VAPI-3164' into VAPI-3164
atelegu a72b2fc
VAPI-3164
atelegu 0c110eb
VAPI-3164
atelegu 727d9db
Remove ReferCompleteCallback and use shared SipUri in Refer
stampercasey c3abe37
Merge branch 'main' into VAPI-3164
stampercasey 0b07ad1
Remove orphaned referCompleteCallback schema and stale manifest entries
stampercasey 4d2d4b5
Merge remote-tracking branch 'origin/VAPI-3164' into VAPI-3164
stampercasey acc1804
Revert remaining referComplete additions in docs/*.md and model javadocs
stampercasey 425bd11
Revert api/openapi.yaml entirely; drop hand-maintained docs/Refer.md
stampercasey 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,59 @@ | ||
| /** | ||
| * The {@code <Refer>} verb is used to initiate a SIP REFER on an existing call, | ||
| * instructing the remote SIP endpoint to contact a third party directly. | ||
| * On success the call is terminated — the remote endpoint redirects away from Bandwidth entirely. | ||
| */ | ||
|
|
||
| package com.bandwidth.sdk.model.bxml; | ||
|
|
||
| import static com.bandwidth.sdk.model.bxml.utils.BxmlConstants.DEFAULT_CALLBACK_METHOD; | ||
|
|
||
| import jakarta.xml.bind.annotation.XmlAccessType; | ||
| import jakarta.xml.bind.annotation.XmlAccessorType; | ||
| import jakarta.xml.bind.annotation.XmlAttribute; | ||
| import jakarta.xml.bind.annotation.XmlElement; | ||
| import jakarta.xml.bind.annotation.XmlType; | ||
| import java.net.URI; | ||
|
|
||
| import lombok.*; | ||
| import lombok.Builder.Default; | ||
|
|
||
| @XmlAccessorType(XmlAccessType.FIELD) | ||
| @XmlType(name = Refer.TYPE_NAME) | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| @Getter | ||
| @EqualsAndHashCode | ||
| /** | ||
| * | ||
| * @param sipUri (SipUri, required): The SIP URI to refer the call to. Must start with "sip:". | ||
| * @param referCompleteUrl (str, optional): URL to send the Refer Complete event to and request new BXML for failure recovery. May be a relative URL. Defaults to None. | ||
| * @param referCompleteMethod (str, optional): The HTTP method to use for the request to referCompleteUrl. GET or POST. Default value is POST. | ||
| * @param tag (str, optional): A custom string that will be sent with these and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="". Max length 256 characters. Defaults to None. | ||
| * | ||
| */ | ||
| public class Refer implements Verb { | ||
|
|
||
| public static final String TYPE_NAME = "Refer"; | ||
|
|
||
| @XmlElement(name = "SipUri", type = SipUri.class) | ||
| @NonNull | ||
| protected SipUri sipUri; | ||
|
|
||
| @XmlAttribute | ||
| protected URI referCompleteUrl; | ||
|
|
||
| @XmlAttribute | ||
| @Default | ||
| protected String referCompleteMethod = DEFAULT_CALLBACK_METHOD; | ||
|
|
||
| @XmlAttribute | ||
| protected String tag; | ||
|
|
||
| @Override | ||
| public String getVerbName() { | ||
| return TYPE_NAME; | ||
| } | ||
| } | ||
|
|
55 changes: 55 additions & 0 deletions
55
src/test/java/com/bandwidth/sdk/unit/models/bxml/ReferVerbTest.java
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,55 @@ | ||
| /** | ||
| * | ||
| * Unit tests for Refer Verb class | ||
| * | ||
| * @throws JAXBException if the test fails | ||
| */ | ||
|
|
||
| package com.bandwidth.sdk.unit.models.bxml; | ||
|
|
||
| import com.bandwidth.sdk.model.bxml.Bxml; | ||
| import com.bandwidth.sdk.model.bxml.Refer; | ||
| import com.bandwidth.sdk.model.bxml.SipUri; | ||
|
|
||
| import jakarta.xml.bind.JAXBContext; | ||
| import jakarta.xml.bind.JAXBException; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.is; | ||
|
|
||
| import java.net.URI; | ||
|
|
||
| public class ReferVerbTest { | ||
|
|
||
| SipUri sipUri = SipUri.builder() | ||
| .uri("sip:alice@atlanta.example.com") | ||
| .build(); | ||
|
|
||
| Refer refer = Refer.builder() | ||
| .sipUri(sipUri) | ||
| .referCompleteUrl(URI.create("https://example.com/webhooks/refer_complete")) | ||
| .referCompleteMethod("POST") | ||
| .tag("test-tag") | ||
| .build(); | ||
|
|
||
| Refer referMinimal = Refer.builder() | ||
| .sipUri(sipUri) | ||
| .build(); | ||
|
|
||
| @Test | ||
| public void referVerbWithAllAttributes() throws JAXBException { | ||
| JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class); | ||
| String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Refer referCompleteUrl=\"https://example.com/webhooks/refer_complete\" referCompleteMethod=\"POST\" tag=\"test-tag\"><SipUri transferAnswerMethod=\"POST\" transferAnswerFallbackMethod=\"POST\" transferDisconnectMethod=\"POST\">sip:alice@atlanta.example.com</SipUri></Refer></Bxml>"; | ||
| assertThat(new Bxml().with(refer).toBxml(jaxbContext), is(expectedBxml)); | ||
| } | ||
|
|
||
| @Test | ||
| public void referVerbMinimal() throws JAXBException { | ||
| JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class); | ||
| String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><Refer referCompleteMethod=\"POST\"><SipUri transferAnswerMethod=\"POST\" transferAnswerFallbackMethod=\"POST\" transferDisconnectMethod=\"POST\">sip:alice@atlanta.example.com</SipUri></Refer></Bxml>"; | ||
| assertThat(new Bxml().with(referMinimal).toBxml(jaxbContext), is(expectedBxml)); | ||
| } | ||
| } | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.