-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(New) Added Interdigit timeout to Ask object.
(New) Added collect digits sample app. (Fix) Code cleanup and reformatting.
- Loading branch information
unknown
committed
Dec 5, 2011
1 parent
0c33c47
commit 0e17d89
Showing
40 changed files
with
665 additions
and
262 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
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
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
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,76 @@ | ||
using System.IO; | ||
using Newtonsoft.Json.Linq; | ||
using System.Text; | ||
|
||
namespace TropoCSharp.Tropo | ||
{ | ||
/// <summary> | ||
/// Utility class for Tropo WebAPI. | ||
/// </summary> | ||
public static class TropoUtilities | ||
{ | ||
/// <summary> | ||
/// Method to read JSON sent from Tropo WebAPI. | ||
/// </summary> | ||
/// <param name="reader">Streamreader representing the JSON sent from Tropo.</param> | ||
/// <returns>String of JSON</returns> | ||
public static string parseJSON(StreamReader reader) | ||
{ | ||
return reader.ReadToEnd(); | ||
} | ||
|
||
/// <summary> | ||
/// Parse a child object that is part of a Tropo JSON payload. | ||
/// </summary> | ||
/// <param name="tropoObject"></param> | ||
/// <returns></returns> | ||
public static JObject parseObject(JContainer tropoObject) | ||
{ | ||
return JObject.Parse(tropoObject.ToString()); | ||
} | ||
|
||
/// <summary> | ||
/// Parse the child Actions object that is part of the Tropo Result object. | ||
/// </summary> | ||
/// <param name="actions">Actions - is either an Object or an Array.</param> | ||
/// <returns></returns> | ||
public static JContainer parseActions(JContainer actions) | ||
{ | ||
JTokenType type = actions.Type; | ||
if (type == JTokenType.Array) | ||
{ | ||
return JArray.Parse(actions.ToString()); | ||
} | ||
else | ||
{ | ||
return parseObject(actions); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Remove double quotes from strings that can break JSON. | ||
This comment has been minimized.
Sorry, something went wrong. |
||
/// </summary> | ||
/// <param name="value">The string to remove double quotes from.</param> | ||
/// <returns></returns> | ||
public static string removeQuotes(string value) | ||
{ | ||
return value.Replace("\"", ""); | ||
} | ||
|
||
/// <summary> | ||
/// Add spaces to a string of digits to improve TTS readback. | ||
/// </summary> | ||
/// <param name="value">The string to add spaces to.</param> | ||
/// <returns></returns> | ||
public static string addSpaces(string value) | ||
{ | ||
StringBuilder str = new StringBuilder(); | ||
char[] array = value.ToCharArray(); | ||
foreach(char s in array) | ||
{ | ||
str.Append(s + " "); | ||
} | ||
return str.ToString(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
lol