Skip to content

Commit

Permalink
Add parsing for DoorDash snack toppings
Browse files Browse the repository at this point in the history
  • Loading branch information
dtchiong committed Feb 12, 2020
1 parent 7bdf837 commit 71c36db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/DoorDashParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ public class DoorDashParser {
case "-Rice":
ParseRiceDishAddons(words, item);
break;
case "-Snack":
ParseSnackToppings(words, item);
break;
default:
Debug.WriteLine("Unidentified addon starter word: " + words[0] + "-");
break;
Expand Down Expand Up @@ -377,6 +380,20 @@ public class DoorDashParser {
item.AddOnList.Add(addon);
}

/* Parses snack toppings from string[]
* Example: "Snack Topping Basil Leaf (+ $0.60)
*/
private void ParseSnackToppings(string[] words, Item item) {
int startIdx = 2;
string addon = "";
for (int i = startIdx; i < words.Length; i++) {
if (words[i].StartsWith("(")) break;
addon = addon + words[i] + " ";
}
if (item.AddOnList == null) item.AddOnList = new List<string>();
item.AddOnList.Add(addon);
}

/* Parses ramen addons from string[] in form:
* "Ramen", "Addons", {Addon} {Price}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Program {
* 164b501111cebfe1
* 164aebfdb8b7a59a
*/
static string testMessageId = "16d4c263324c38eb"; //1691c8b4a6b606d3
static string testMessageId = "1702cc093428a10e"; //1691c8b4a6b606d3
static string userId = "t4milpitasonline@gmail.com";

static TimerT timer;
Expand Down

0 comments on commit 71c36db

Please sign in to comment.