|
| 1 | + |
| 2 | +package com.bandwidth.voice.bxml.verbs; |
| 3 | + |
| 4 | +import lombok.Builder; |
| 5 | + |
| 6 | +import java.net.URI; |
| 7 | +import java.util.ArrayList; |
| 8 | +import java.util.Arrays; |
| 9 | +import java.util.List; |
| 10 | + |
| 11 | +import javax.xml.bind.annotation.XmlAttribute; |
| 12 | +import javax.xml.bind.annotation.XmlType; |
| 13 | +import javax.xml.bind.annotation.XmlElement; |
| 14 | + |
| 15 | + |
| 16 | +/** |
| 17 | + * The 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. |
| 18 | + */ |
| 19 | +@Builder |
| 20 | +@XmlType(name = StartTranscription.TYPE_NAME) |
| 21 | +public class StartTranscription implements Verb { |
| 22 | + public static final String TYPE_NAME = "StartTranscription"; |
| 23 | + |
| 24 | + @XmlElement(name = CustomParam.TYPE_NAME) |
| 25 | + private final List<CustomParam> customParams; |
| 26 | + |
| 27 | + /** |
| 28 | + * <i>(optional)</i> 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. |
| 29 | + */ |
| 30 | + @XmlAttribute |
| 31 | + private String name; |
| 32 | + |
| 33 | + /** |
| 34 | + * <i>(optional)</i> the part of the call to send a transcription from. `inbound`, `outbound` or `both`. default is `inbound`. |
| 35 | + */ |
| 36 | + @XmlAttribute |
| 37 | + private String tracks; |
| 38 | + |
| 39 | + /** |
| 40 | + * <i>(optional)</i> a websocket uri to send the real-time transcription to. the audio from the specified tracks will be sent via websocket to this url encoded as base64 encoded pcmu/g711 audio. see below for more details on the websocket packet format. |
| 41 | + */ |
| 42 | + @XmlAttribute |
| 43 | + private URI destination; |
| 44 | + |
| 45 | + /** |
| 46 | + * <i>(optional)</i> Whether to send transcription update events to the specified destination only after they have become stable. Requires destination. Defaults to true. |
| 47 | + */ |
| 48 | + @XmlAttribute |
| 49 | + private Boolean stabilized; |
| 50 | + |
| 51 | + /** |
| 52 | + * <i>(optional)</i> url to send the associated webhook events to during this real-time transcription's lifetime. Does not accept bxml. May be a relative URL. |
| 53 | + */ |
| 54 | + @XmlAttribute |
| 55 | + private URI transcriptionEventUrl; |
| 56 | + |
| 57 | + /** |
| 58 | + * <i>(optional)</i> the http method to use for the request to `transcriptioneventurl`. get or post. default value is post. |
| 59 | + */ |
| 60 | + @XmlAttribute |
| 61 | + private Method transcriptionEventMethod; |
| 62 | + |
| 63 | + /** |
| 64 | + * <i>(optional)</i> the username to send in the http request to `transcriptioneventurl`. if specified, the urls must be tls-encrypted (i.e., `https`). |
| 65 | + */ |
| 66 | + @XmlAttribute |
| 67 | + protected String username; |
| 68 | + |
| 69 | + /** |
| 70 | + * <i>(optional)</i> the password to send in the http request to `transcriptioneventurl`. if specified, the urls must be tls-encrypted (i.e., `https`). |
| 71 | + */ |
| 72 | + @XmlAttribute |
| 73 | + protected String password; |
| 74 | + |
| 75 | + |
| 76 | + public static class StartTranscriptionBuilder { |
| 77 | + |
| 78 | + /** |
| 79 | + * <b>(optional)</b> url to send the associated webhook events to during this real-time transcription's lifetime. does not accept bxml. may be a relative url. |
| 80 | + */ |
| 81 | + public StartTranscriptionBuilder transcriptionEventUrl(URI uri ){ |
| 82 | + this.transcriptionEventUrl = uri; |
| 83 | + return this; |
| 84 | + } |
| 85 | + |
| 86 | + /** |
| 87 | + * <b>(optional)</b> url to send the associated webhook events to during this real-time transcription's lifetime. does not accept bxml. may be a relative url. |
| 88 | + */ |
| 89 | + public StartTranscriptionBuilder transcriptionEventUrl(String uri ){ |
| 90 | + return transcriptionEventUrl(URI.create(uri)); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * <b>(required)</b> a websocket uri to send the real-time transcription to. the audio from the specified tracks will be sent via websocket to this url encoded as base64 encoded pcmu/g711 audio. see below for more details on the websocket packet format. |
| 95 | + */ |
| 96 | + public StartTranscriptionBuilder destination(URI uri ){ |
| 97 | + this.destination = uri; |
| 98 | + return this; |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * <b>(optional)</b> a websocket uri to send the real-time transcription to. the audio from the specified tracks will be sent via websocket to this url encoded as base64 encoded pcmu/g711 audio. see below for more details on the websocket packet format. |
| 103 | + */ |
| 104 | + public StartTranscriptionBuilder destination(String uri ){ |
| 105 | + return destination(URI.create(uri)); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * <i>(optional)</i> the http method to use for the request to `transcriptioneventurl`. get or post. default value is post. |
| 110 | + */ |
| 111 | + public StartTranscriptionBuilder transcriptionEventMethod(Method method){ |
| 112 | + this.transcriptionEventMethod = method; |
| 113 | + return this; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * <i>(optional)</i> the http method to use for the request to `transcriptionEventUrl`. GET or POST. Default value is POST. |
| 118 | + */ |
| 119 | + public StartTranscriptionBuilder transcriptionEventMethod(String method){ |
| 120 | + return transcriptionEventMethod(Method.fromValue(method)); |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * <i>(optional)</i> 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. |
| 125 | + */ |
| 126 | + public StartTranscriptionBuilder customParams(CustomParam ... customParams){ |
| 127 | + this.customParams = Arrays.asList(customParams); |
| 128 | + return this; |
| 129 | + } |
| 130 | + |
| 131 | + /** |
| 132 | + * <i>(optional)</i> 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. |
| 133 | + */ |
| 134 | + public StartTranscriptionBuilder customParams(List<CustomParam> customParams){ |
| 135 | + this.customParams = customParams; |
| 136 | + return this; |
| 137 | + } |
| 138 | + } |
| 139 | +} |
0 commit comments