Record.cs
1 using System.Collections.Generic;
3 using Newtonsoft.Json;
4 
5 namespace Microsoft.Bot.Builder.Calling.ObjectModel.Contracts
6 {
10  [JsonObject(MemberSerialization.OptOut)]
11  public class Record : ActionBase
12  {
18  [JsonProperty(Required = Required.Default)]
19  public PlayPrompt PlayPrompt { get; set; }
20 
24  [JsonProperty(Required = Required.Default)]
25  public double? MaxDurationInSeconds { get; set; }
26 
33  [JsonProperty(Required = Required.Default)]
34  public double? InitialSilenceTimeoutInSeconds { get; set; }
35 
42  [JsonProperty(Required = Required.Default)]
43  public double? MaxSilenceTimeoutInSeconds { get; set; }
44 
50  [JsonProperty(Required = Required.Default)]
51  public RecordingFormat? RecordingFormat { get; set; }
52 
58  [JsonProperty(Required = Required.Default)]
59  public bool? PlayBeep { get; set; }
60 
76  [JsonProperty(Required = Required.Default)]
77  public IEnumerable<char> StopTones { get; set; }
78 
79  public Record()
80  {
81  this.Action = ValidActions.RecordAction;
82  }
83 
84  public override void Validate()
85  {
86  base.Validate();
87  if (this.PlayPrompt != null)
88  {
89  this.PlayPrompt.Validate();
90  }
91 
92  if (this.StopTones != null)
93  {
94  ValidDtmfs.Validate(this.StopTones);
95  }
96 
97  if (this.MaxDurationInSeconds.HasValue)
98  {
99  Utils.AssertArgument(this.MaxDurationInSeconds.Value >= MinValues.RecordingDuration.TotalSeconds && this.MaxDurationInSeconds.Value <= MaxValues.RecordingDuration.TotalSeconds,
100  "MaxDurationInSeconds has to be specified in the range of {0} - {1} secs", MinValues.RecordingDuration.TotalSeconds, MaxValues.RecordingDuration.TotalSeconds);
101  }
102 
103  if (this.InitialSilenceTimeoutInSeconds.HasValue)
104  {
105  Utils.AssertArgument(this.InitialSilenceTimeoutInSeconds.Value >= MinValues.InitialSilenceTimeout.TotalSeconds && this.InitialSilenceTimeoutInSeconds.Value <= MaxValues.InitialSilenceTimeout.TotalSeconds,
106  "InitialSilenceTimeoutInSeconds has to be specified in the range of {0} - {1} secs", MinValues.InitialSilenceTimeout.TotalSeconds, MaxValues.InitialSilenceTimeout.TotalSeconds);
107  }
108 
109  if (this.MaxSilenceTimeoutInSeconds.HasValue)
110  {
111  Utils.AssertArgument(this.MaxSilenceTimeoutInSeconds.Value >= MinValues.SilenceTimeout.TotalSeconds && this.MaxSilenceTimeoutInSeconds.Value <= MaxValues.SilenceTimeout.TotalSeconds,
112  "MaxSilenceTimeoutInSeconds has to be specified in the range of {0} - {1} secs", MinValues.SilenceTimeout.TotalSeconds, MaxValues.SilenceTimeout.TotalSeconds);
113  }
114  }
115  }
116 }
static readonly TimeSpan InitialSilenceTimeout
Maximum initial silence allowed from the time we start the operation before we timeout and fail the o...
Definition: MaxValues.cs:27
static readonly TimeSpan RecordingDuration
JSON Content Type
Definition: MinValues.cs:10
Root namespace for the Microsoft Bot Builder Calling SDK object model.
static void AssertArgument(bool condition, string format, params object[] args)
Argument checker
Definition: Utils.cs:17
This is a helper class for validating actions specified by customers
Definition: ValidActions.cs:11
This is the action which customers can specify to indicate that the server call agent should play/tts...
Definition: PlayPrompt.cs:10
static readonly TimeSpan InitialSilenceTimeout
Minimum initial silence allowed from the time we start the operation before we timeout and fail the o...
Definition: MinValues.cs:22
Root namespace for the Microsoft Bot Builder Calling SDK.
static readonly TimeSpan RecordingDuration
Minimum max recording duration
Definition: MaxValues.cs:10
This is a helper class for validating dtmfs specified in strings
Definition: ValidDtmfs.cs:10
This is the action which customers can specify to indicate that the server call agent should start re...
Definition: Record.cs:11
RecordingFormat
Encoding format to be used for recording
Namespace for utilities and helpers in the Microsoft Bot Builder Calling SDK.
Root namespace for the Microsoft Bot Builder SDK.