/// <summary> /// A function that returns a JObject based on the storeID, and orderKey /// </summary> /// <param name="storeID">The store ID of our Store</param> /// <param name="orderKey">The order key of our Order</param> /// <param name="c">The country our store is in for the API</param> /// <returns>A JObject representation of the XML returned by the tracker.</returns> public static JObject trackByOrder(string storeID, string orderKey, URLs.Country c) { return(Utils.request_XML( URLs.trackOrder(c) .Replace("{store_id}", storeID) .Replace("{order_key}", orderKey))); }
/// <summary> /// Returns the price of the current Order combined. /// Use this instead of place() when testing. /// </summary> /// <param name="card">The Payment.CreditCard object to pay with.</param> public JObject payWith(Payment.CreditCard card) { // Get the price to check that everything worked okay JObject response = send(URLs.priceURL(store.country), true); // Throw an exception if we messed up. if (response["Status"].ToString() == "-1") { throw new Exception("Dominos returned -1 due to order being, \"" + errorReason(response["Order"]) + "\" | Response: " + response.ToString()); } data["Payments"] = new JArray { new JObject { { "Type", "CreditCard" }, { "Expiration", card.expirationDate }, { "Amount", double.Parse(response["Order"]["Amounts"]["Customer"].ToString()) }, { "CardType", card.cardType.ToString().ToUpper() }, { "Number", long.Parse(card.number) }, { "SecurityCode", long.Parse(card.cvv) }, { "PostalCode", long.Parse(card.zip) } } }; return(response); }
/// <summary> /// Returns the price of the current Order combined. /// Use this instead of place() when testing /// </summary> public JObject payWith() { // Get the price to check that everything worked okay JObject response = send(URLs.priceURL(store.country), true); // Throw an exception if we messed up. if (response["Status"].ToString() == "-1") { throw new Exception("Dominos returned -1 due to order being, \"" + errorReason(response["Order"]) + "\" | Response: " + response.ToString()); } data["Payments"] = new JArray { new JObject { { "Type", "Cash" } } }; return(response); }
/// <summary> /// Gets a List of Stores of the nearby currently open stores according to the Dominos API /// </summary> /// <returns>A List of Stores of the nearby stores according to the Dominos API</returns> public List <Store> getNearbyStores() { // Queries the nearest stores string properURL = URLs.findURL(Country).Replace("{street}", Street).Replace("{city}", City).Replace("{reigon}", Region).Replace("{postal}", ZIP).Replace("{type}", delivery.ToString()); // Get JObject from our JSON data gathered. JObject data = Utils.request_JSON(properURL); List <Store> stores = new List <Store>(); JArray storeArray = JArray.Parse(data.GetValue("Stores").ToString()); for (int i = 0; i < storeArray.Count; i++) { dynamic store = storeArray[i]; if (store.IsOnlineNow != "True" || store.ServiceIsOpen[delivery.ToString()] != "True" || store == null) { continue; } stores.Add(new Store(store.StoreID, store)); } return(stores); }
/// <summary> /// This *hopefully* places an Order to Dominos. /// Not really sure if this works, not really going to pay. /// This requires testing. /// </summary> /// <param name="creditCard">The credit card one is paying with. null if paying in cash.</param> public JObject placeOrder(Payment.CreditCard creditCard) { if (creditCard.cardType == Payment.CreditCard.CreditCardType.MAX) { throw new Exception("Credit Card is not a valid type!"); } if (creditCard == null) { payWith(); } else { payWith(creditCard); } JObject response = send(URLs.placeURL(store.country), false); if (response["Status"].ToString() == "-1") { throw new Exception("Dominos returned -1 due to order being, \"" + errorReason(response["Order"]) + "\" | Response: " + response.ToString()); } return(response); }
/// <summary> /// Returns a Menu object for the menu of our current store based on the API. /// </summary> /// <returns>A Menu object for the menu of our current store based on the API.</returns> public Menu getMenu() { string properURL = URLs.menuURL(country).Replace("{store_id}", ID).Replace("{lang}", "en"); return(new Menu(Utils.request_JSON(properURL), country)); }
/// <summary> /// A function that returns a JObject based on the phone number returned by the API as XML. /// </summary> /// <param name="phoneNumber">The phone number linked to the order</param> /// <param name="c">The country associated with the order</param> /// <returns>A JObject representation of the XML returned by the tracker.</returns> public static JObject trackByPhone(string phoneNumber, URLs.Country c) { return(Utils.request_XML(URLs.trackPhone(c).Replace("{phone}", phoneNumber))); }
/// <summary> /// Checks the validation of an order /// </summary> /// <returns>If the order is valid</returns> public bool validateOrder() { JObject s = send(URLs.placeURL(store.country), false); return(s["Status"].ToString() != "-1"); }