public void can_build_play_get_digits_string() { var options = new PlayGetDigitsOptions() { MinDigits = 4, MaxDigits = 8, MaxTries = 3, TimeoutMs = 4000, TerminatorDigits = "#", PromptAudioFile = "ivr/8000/ivr-please_enter_pin_followed_by_pound.wav", BadInputAudioFile = "ivr/8000/ivr-that_was_an_invalid_entry.wav", DigitTimeoutMs = 2000, ValidDigits = "1234567890" //note that in the command string this gets transformed into the regex ^(1|2|3|4|5|6|7|8|9|0)+ }; var toString = options.ToString(); Assert.Equal(@"4 8 3 4000 # ivr/8000/ivr-please_enter_pin_followed_by_pound.wav ivr/8000/ivr-that_was_an_invalid_entry.wav play_get_digits_result ^(1|2|3|4|5|6|7|8|9|0)+ 2000", toString); }
public static async Task<PlayGetDigitsResult> PlayGetDigits(this EventSocket eventSocket, string uuid, PlayGetDigitsOptions options) { try { // todo: what if applicationresult is null (hang up occurs before the application completes) var result = new PlayGetDigitsResult( await eventSocket.ExecuteApplication(uuid, "play_and_get_digits", options.ToString()).ConfigureAwait(false), options.ChannelVariableName); if (!result.Success) { LogFailedApplicationResult(eventSocket, result); } return result; } catch (TaskCanceledException ex) { return new PlayGetDigitsResult(null, null); } }
public async Task<string> PlayGetDigits(PlayGetDigitsOptions options) { if (!IsAnswered) { return string.Empty; } var result = await eventSocket.PlayGetDigits(UUID, options).ConfigureAwait(false); return result.Digits; }