-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
MediaEventReasonCode.cs
118 lines (101 loc) · 6.97 KB
/
MediaEventReasonCode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.ComponentModel;
using System;
namespace Azure.Communication.CallAutomation
{
/// <summary>
/// Reason Codes for incoming webhook events.
/// </summary>
public readonly partial struct MediaEventReasonCode : IEquatable<MediaEventReasonCode>
{
private readonly string _value;
/// <summary> Initializes a new instance of <see cref="MediaEventReasonCode"/>. </summary>
/// <exception cref="ArgumentNullException"> <paramref name="value"/> is null. </exception>
public MediaEventReasonCode(string value)
{
_value = value ?? throw new ArgumentNullException(nameof(value));
}
private const string RecognizeInitialSilenceTimedOutValue = "8510";
private const string RecognizeInterDigitTimedOutValue = "8532";
private const string RecognizeDtmfOptionMatchedValue = "8533";
private const string RecognizePlayPromptFailedValue = "8511";
private const string RecognizeMaxDigitsReceivedValue = "8531";
private const string RecognizeIncorrectToneDetectedValue = "8534";
private const string RecognizeStopToneDetectedValue = "8514";
private const string RecognizeSpeechOptionMatchedValue = "8545";
private const string RecognizeSpeechOptionNotMatchedValue = "8547";
private const string RecognizeSpeechNotRecognizedValue = "8563";
private const string RecognizeSpeechServiceConnectionErrorValue = "8564";
private const string PlayDownloadFailedValue = "8536";
private const string PlayInvalidFileFormatValue = "8535";
private const string CognitiveServicesErrorValue = "8565";
private const string CompletedSuccessfullyValue = "0";
private const string UnspecifiedErrorValue = "9999";
/// <summary> Action failed, initial silence timeout reached. </summary>
public static MediaEventReasonCode RecognizeInitialSilenceTimedOut { get; } = new MediaEventReasonCode(RecognizeInitialSilenceTimedOutValue);
/// <summary> Action failed, inter-digit silence timeout reached. </summary>
public static MediaEventReasonCode RecognizeInterDigitTimedOut { get; } = new MediaEventReasonCode(RecognizeInterDigitTimedOutValue);
/// <summary> Action failed, encountered failure while trying to play the prompt. </summary>
public static MediaEventReasonCode RecognizePlayPromptFailed { get; } = new MediaEventReasonCode(RecognizePlayPromptFailedValue);
/// <summary> Action completed, max digits received. </summary>
public static MediaEventReasonCode RecognizeMaxDigitsReceived { get; } = new MediaEventReasonCode(RecognizeMaxDigitsReceivedValue);
/// <summary> Action completed as stop tone was detected. </summary>
public static MediaEventReasonCode RecognizeStopToneDetected { get; } = new MediaEventReasonCode(RecognizeStopToneDetectedValue);
/// <summary> Action failed, play source not working. </summary>
public static MediaEventReasonCode RecognizeDtmfOptionMatched { get; } = new MediaEventReasonCode(RecognizeDtmfOptionMatchedValue);
/// <summary> Speech option matched. </summary>
public static MediaEventReasonCode RecognizeSpeechOptionMatched { get; } = new MediaEventReasonCode(RecognizeSpeechOptionMatchedValue);
/// <summary> Speech option not matched. </summary>
public static MediaEventReasonCode RecognizeSpeechOptionNotMatched { get; } = new MediaEventReasonCode(RecognizeSpeechOptionNotMatchedValue);
/// <summary> Recognize with Choice that incorrect tone detected. </summary>
public static MediaEventReasonCode RecognizeIncorrectToneDetected { get; } = new MediaEventReasonCode(RecognizeIncorrectToneDetectedValue);
/// <summary> Speech not recognized. </summary>
public static MediaEventReasonCode RecognizeSpeechNotRecognized { get; } = new MediaEventReasonCode(RecognizeSpeechNotRecognizedValue);
/// <summary> Speech service connection error. </summary>
public static MediaEventReasonCode RecognizeSpeechServiceConnectionError { get; } = new MediaEventReasonCode(RecognizeSpeechServiceConnectionErrorValue);
/// <summary> Action failed, file could not be downloaded. </summary>
public static MediaEventReasonCode PlayDownloadFailed { get; } = new MediaEventReasonCode(PlayDownloadFailedValue);
/// <summary> Action failed, file could not be downloaded. </summary>
public static MediaEventReasonCode PlayInvalidFileFormat { get; } = new MediaEventReasonCode(PlayInvalidFileFormatValue);
/// <summary> Action failed, cognitive service error. </summary>
public static MediaEventReasonCode CognitiveServicesError { get; } = new MediaEventReasonCode(CognitiveServicesErrorValue);
/// <summary> Action completed successfully. </summary>
public static MediaEventReasonCode CompletedSuccessfully { get; } = new MediaEventReasonCode(CompletedSuccessfullyValue);
/// <summary> Unknown internal server error. </summary>
public static MediaEventReasonCode UnspecifiedError { get; } = new MediaEventReasonCode(UnspecifiedErrorValue);
/// <summary> Determines if two <see cref="MediaEventReasonCode"/> values are the same. </summary>
public static bool operator ==(MediaEventReasonCode left, MediaEventReasonCode right) => left.Equals(right);
/// <summary> Determines if two <see cref="MediaEventReasonCode"/> values are not the same. </summary>
public static bool operator !=(MediaEventReasonCode left, MediaEventReasonCode right) => !left.Equals(right);
/// <summary> Converts a string to a <see cref="MediaEventReasonCode"/>. </summary>
public static implicit operator MediaEventReasonCode(string value) => new MediaEventReasonCode(value);
/// <inheritdoc />
[EditorBrowsable(EditorBrowsableState.Never)]
public override bool Equals(object obj) => obj is MediaEventReasonCode other && Equals(other);
/// <inheritdoc />
public bool Equals(MediaEventReasonCode other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase);
/// <inheritdoc />
[EditorBrowsable(EditorBrowsableState.Never)]
public override int GetHashCode() => _value?.GetHashCode() ?? 0;
/// <inheritdoc />
public override string ToString() => _value;
/// <summary>
/// Retrieves the integer value associated with the specified ReasonCode.
/// </summary>
/// <returns>The integer value corresponding to the provided ReasonCode.</returns>
/// <exception cref="Exception"></exception>
public int GetReasonCodeValue()
{
int result;
if (int.TryParse(_value, out result))
{
return result;
}
else
{
throw new Exception("Unable to parse ReasonCode value.");
}
}
}
}