/// <summary> /// Uploads a given TrelloCard object to the Trello servers. /// [pos], [name], [desc], [due], [idList], [idLabels], [urlSource], [fileSource] /// </summary> /// <returns>Your card.</returns> /// <param name="card">Your card.</param> public TrelloCard uploadCard(TrelloCard card) { WWWForm post = new WWWForm(); post.AddField("key", key); post.AddField("token", token); post.AddField("pos", card.pos); post.AddField("name", card.name); post.AddField("desc", card.desc); post.AddField("due", card.due); post.AddField("idList", card.idList); post.AddField("idLabels", card.idLabels); post.AddField("urlSource", card.urlSource); if (card.fileSource != "") { post.AddBinaryData("fileSource", File.ReadAllBytes(card.fileSource)); } WWW www = new WWW(cardBaseUrl, post); // Wait for request to return while (!www.isDone) { checkWwwStatus("Could not upload Trello card", www); } return(card); }
/// <summary> /// Retrieve a new Trello card objects, with the correct list id populated already. /// </summary> /// <returns>The card object.</returns> public TrelloCard newCard() { if (currentListId == "") { throw new TrelloException("Cannot create a card when you have not set selected a list."); } var card = new TrelloCard(); card.idList = currentListId; return(card); }
/// <summary> /// Given an exception objects condition and stack trace, a TrelloCard is created and populated with the relevant information from the exception. This is then uploaded to the Trello server. /// [name], [desc], [due], [idList], [idLabels] /// </summary> /// <returns>The exception card.</returns> /// <param name="condition">Conditoin.</param> /// <param name="stackTrace">Stack Trace.</param> private TrelloCard uploadExceptionCard(string condition, string stackTrace) { TrelloCard card = new TrelloCard(); SystemInformation sysInfo = new SystemInformation(); card.pos = "top"; card.name = String.Format("[Exception] {0}", condition); card.due = DateTime.Now.ToString(); card.desc = String.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}", condition, Environment.NewLine, "--------", Environment.NewLine, "```", Environment.NewLine, stackTrace, Environment.NewLine, sysInfo.BuildSystemInformation(true, true, true), "```"); card.idList = currentListId; card.fileSource = ""; MonoBehaviour.print("IN uploadException"); return(uploadCard(card)); }