-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from Bandwidth/SWI-2789-FB
SWI-2789 Feature Branch Adding Start/Stop Transcription
- Loading branch information
Showing
9 changed files
with
278 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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
37 changes: 37 additions & 0 deletions
37
src/main/java/org/openapitools/client/model/bxml/CustomParam.java
This file contains 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,37 @@ | ||
/** | ||
* The {@code <CustomParam>} verb is used to define optional user specified parameters that will be sent to the destination URL when the real-time transcription is first started. | ||
* You may specify up to 12 {@code <CustomParam>} elements nested within a {@code <StartTranscription>} tag. | ||
*/ | ||
|
||
package org.openapitools.client.model.bxml; | ||
|
||
|
||
import jakarta.xml.bind.annotation.XmlAccessType; | ||
import jakarta.xml.bind.annotation.XmlAccessorType; | ||
import jakarta.xml.bind.annotation.XmlAttribute; | ||
import jakarta.xml.bind.annotation.XmlType; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@XmlType(name = CustomParam.TYPE_NAME) | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class CustomParam { | ||
/** | ||
* | ||
* @param name (str): The name of this parameter, up to 256 characters. | ||
* @param value (str): The value of this parameter, up to 2048 characters. | ||
* | ||
*/ | ||
public static final String TYPE_NAME = "CustomParam"; | ||
|
||
@XmlAttribute | ||
protected String name; | ||
@XmlAttribute | ||
protected String value; | ||
} |
This file contains 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
90 changes: 90 additions & 0 deletions
90
src/main/java/org/openapitools/client/model/bxml/StartTranscription.java
This file contains 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,90 @@ | ||
/** | ||
* The {@code <StartTranscription>} verb allows a segment of a call to be transcribed and optionally for the live transcription to be sent off to another destination for additional processing. | ||
*/ | ||
|
||
package org.openapitools.client.model.bxml; | ||
|
||
import static org.openapitools.client.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.XmlElements; | ||
import jakarta.xml.bind.annotation.XmlType; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import org.openapitools.client.model.CallDirectionEnum; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Builder.Default; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlType(name = StartTranscription.TYPE_NAME) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Getter | ||
@EqualsAndHashCode | ||
public class StartTranscription implements Verb { | ||
/** | ||
* | ||
* @param name (str, optional): A name to refer to this transcription by. Used when sending <StopTranscription>. If not provided, it will default to the generated transcription id as sent in the Real-Time Transcription Started webhook. | ||
* @param tracks (str, optional): The part of the call to send a transcription from. inbound, outbound or both. Default is inbound. | ||
* @param destination (str, optional): A websocket URI to send the stream to. The audio from the specified tracks will be sent via websocket to this URL as base64-encoded PCMU/G711 audio. See below for more details on the websocket packet format. | ||
* @param transcriptionEventUrl (str, optional): URL to send the associated Webhook events to during this real-time transcription's lifetime. Does not accept BXML. May be a relative URL. | ||
* @param transcriptionEventMethod (str, optional): The HTTP method to use for the request to transcriptionEventUrl. GET or POST. Default value is POST. | ||
* @param username (str, optional): The username to send in the HTTP request to transcriptionEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https). | ||
* @param password (str, optional): The password to send in the HTTP request to transcriptionEventUrl. If specified, the URLs must be TLS-encrypted (i.e., https). | ||
* @param stabilized (str, optional): Whether to send transcription update events to the specified destination only after they have become stable. Requires destination. Defaults to true. | ||
* | ||
* Nested Verbs: | ||
* @param CustomParam: (optional) You may specify up to 12 <CustomParam/> elements nested within a <StartTranscription> tag. | ||
* These elements define optional user specified parameters that will be sent to the destination URL when the real-time transcription is first started. | ||
* | ||
*/ | ||
|
||
public static final String TYPE_NAME = "StartTranscription"; | ||
|
||
@XmlAttribute | ||
protected String name; | ||
|
||
@XmlAttribute | ||
@Default | ||
protected CallDirectionEnum tracks = CallDirectionEnum.INBOUND; | ||
|
||
@XmlAttribute | ||
protected String destination; | ||
|
||
@XmlAttribute | ||
@Getter | ||
protected String transcriptionEventUrl; | ||
|
||
@XmlAttribute | ||
@Default | ||
protected String transcriptionEventMethod = DEFAULT_CALLBACK_METHOD; | ||
|
||
@XmlAttribute | ||
protected String username; | ||
|
||
@XmlAttribute | ||
protected String password; | ||
|
||
@XmlAttribute | ||
protected Boolean stabilized = true; | ||
|
||
@XmlElements({ | ||
@XmlElement(name = CustomParam.TYPE_NAME, type = CustomParam.class) | ||
}) | ||
protected List<CustomParam> customParams; | ||
|
||
@Override | ||
public String getVerbName() { | ||
return TYPE_NAME; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/openapitools/client/model/bxml/StopTranscription.java
This file contains 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,40 @@ | ||
/** | ||
* The {@code <StopTranscription>} verb is used to stop a real-time transcription that was started with a previous {@code <StartTranscription>} verb. | ||
*/ | ||
|
||
package org.openapitools.client.model.bxml; | ||
|
||
import jakarta.xml.bind.annotation.XmlAccessType; | ||
import jakarta.xml.bind.annotation.XmlAccessorType; | ||
import jakarta.xml.bind.annotation.XmlAttribute; | ||
import jakarta.xml.bind.annotation.XmlType; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlType(name = StopTranscription.TYPE_NAME) | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
@Getter | ||
@EqualsAndHashCode | ||
public class StopTranscription implements Verb { | ||
/** | ||
* | ||
* @param name (str, optional): The name of the real-time transcription to stop. | ||
* This is either the user selected name when sending the <StartTranscription> verb, or the system generated name returned in the Media Transcription Started webhook if <StartTranscription> was sent with no name attribute. | ||
*/ | ||
|
||
public static final String TYPE_NAME = "StopTranscription"; | ||
|
||
@XmlAttribute | ||
protected String name; | ||
|
||
@Override | ||
public String getVerbName() { | ||
return TYPE_NAME; | ||
} | ||
} |
This file contains 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
57 changes: 57 additions & 0 deletions
57
src/test/java/org/openapitools/client/model/unit/bxml/StartTranscriptionVerbTest.java
This file contains 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,57 @@ | ||
/** | ||
* | ||
* Unit tests for StartTranscription Verb class | ||
* | ||
* | ||
* @throws JAXBException if the test fails | ||
*/ | ||
|
||
package org.openapitools.client.model.unit.bxml; | ||
|
||
import org.openapitools.client.model.CallDirectionEnum; | ||
import org.openapitools.client.model.bxml.Bxml; | ||
import org.openapitools.client.model.bxml.StartTranscription; | ||
import org.openapitools.client.model.bxml.CustomParam; | ||
|
||
import jakarta.xml.bind.JAXBContext; | ||
import jakarta.xml.bind.JAXBException; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.List; | ||
|
||
public class StartTranscriptionVerbTest { | ||
/** | ||
* Setting up Variables | ||
*/ | ||
CustomParam customParam1 = new CustomParam().builder() | ||
.name("name1") | ||
.value("value1") | ||
.build(); | ||
CustomParam customParam2 = new CustomParam().builder() | ||
.name("name2") | ||
.value("value2") | ||
.build(); | ||
StartTranscription startTranscription = new StartTranscription().builder() | ||
.name("test_transcription") | ||
.tracks(CallDirectionEnum.INBOUND) | ||
.destination("testurl.com") | ||
.transcriptionEventUrl("eventurl.com") | ||
.transcriptionEventMethod("POST") | ||
.username("user") | ||
.password("pass") | ||
.customParams(List.of(customParam1, customParam2)) | ||
.build(); | ||
|
||
|
||
@Test | ||
public void startTranscriptionVerbWorks() throws JAXBException { | ||
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class); | ||
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><StartTranscription name=\"stream1\" tracks=\"INBOUND\" destination=\"testurl.com\" transcriptionEventUrl=\"eventurl.com\" transcriptionEventMethod=\"POST\" username=\"user\" password=\"pass\"><CustomParam name=\"name1\" value=\"value1\"/><CustomParam name=\"name2\" value=\"value2\"/></StartTranscription></Bxml>"; | ||
|
||
assertThat(new Bxml().with(startTranscription).toBxml(jaxbContext), is(expectedBxml)); | ||
} | ||
}; |
30 changes: 30 additions & 0 deletions
30
src/test/java/org/openapitools/client/model/unit/bxml/StopTranscriptionVerbTest.java
This file contains 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,30 @@ | ||
/** | ||
* | ||
* Unit tests for StopTranscription Verb class | ||
* | ||
* @throws JAXBException if the test fails | ||
*/ | ||
|
||
package org.openapitools.client.model.unit.bxml; | ||
|
||
import org.openapitools.client.model.bxml.Bxml; | ||
import org.openapitools.client.model.bxml.StopTranscription; | ||
|
||
import jakarta.xml.bind.JAXBContext; | ||
import jakarta.xml.bind.JAXBException; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
public class StopTranscriptionVerbTest { | ||
|
||
@Test | ||
public void stopTranscriptionVerbWorks() throws JAXBException { | ||
JAXBContext jaxbContext = JAXBContext.newInstance(Bxml.class); | ||
String expectedBxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Bxml><StopTranscription name=\"name\"/></Bxml>"; | ||
|
||
assertThat(new Bxml().with(new StopTranscription("name")).toBxml(jaxbContext), is(expectedBxml)); | ||
}; | ||
}; |