示例#1
0
        /*/// <summary>
         * /// Given an exception object, a TrelloCard is created and populated with the relevant information from the exception. This is then uploaded to the Trello server.
         * /// </summary>
         * /// <returns>The exception card.</returns>
         * /// <param name="e">E.</param>
         * public TrelloCard uploadExceptionCardd(Exception e) {
         *
         *      TrelloCard card = new TrelloCard();
         *      card.name = e.GetType().ToString();
         *      card.due = DateTime.Now.ToString();
         *      card.desc = e.Message;
         *      card.idList = _currentListId;
         *
         *      return UploadCard(card);
         * }*/

        /// <summary>
        /// Uploads a given TrelloCard object to the Trello server.
        /// </summary>
        /// <returns>Trello card uploaded.</returns>
        /// <param name="card">Trello card to upload.</param>
        public TrelloCard UploadCard(TrelloCard card)
        {
            var post = new WWWForm();

            post.AddField("name", card.name);
            post.AddField("desc", card.desc);
            post.AddField("due", card.due);
            post.AddField("idList", card.idList);
            post.AddField("urlSource", card.urlSource);
            if (card.fileSource != null && card.fileName != null)
            {
                post.AddBinaryData("fileSource", card.fileSource, card.fileName);
            }

            var uwr       = UnityWebRequest.Post($"{CardBaseUrl}?key={_key}&token={_token}", post);
            var operation = uwr.SendWebRequest();

            // Wait for request to return
            while (!operation.isDone)
            {
                CheckWebRequestStatus("Could not upload the Trello card.", uwr);
            }

            Debug.Log($"Trello card sent!\nResponse {uwr.responseCode}");
            return(card);
        }
示例#2
0
        /// <summary>
        /// Given an exception object, a TrelloCard is created and populated with the relevant information from the exception. This is then uploaded to the Trello server.
        /// </summary>
        /// <returns>The exception card.</returns>
        /// <param name="e">E.</param>

        /*public TrelloCard uploadExceptionCardd(Exception e) {
         *
         *      TrelloCard card = new TrelloCard();
         *      card.name = e.GetType().ToString();
         *      card.due = DateTime.Now.ToString();
         *      card.desc = e.Message;
         *      card.idList = _currentListId;
         *
         *      return UploadCard(card);
         * }*/

        /// <summary>
        /// Uploads a given TrelloCard object to the Trello server.
        /// </summary>
        /// <returns>Trello card uploaded.</returns>
        /// <param name="card">Trello card to upload.</param>
        public TrelloCard UploadCard(TrelloCard card)
        {
            WWWForm post = new WWWForm();

            post.AddField("name", card.name);
            post.AddField("desc", card.desc);
            post.AddField("due", card.due);
            post.AddField("idList", card.idList);
            post.AddField("urlSource", card.urlSource);
            if (card.fileSource != null && card.fileName != null)
            {
                post.AddBinaryData("fileSource", card.fileSource, card.fileName);
            }

            UnityWebRequest www = UnityWebRequest.Post(string.Format("{0}?key={1}&token={2}", _cardBaseUrl, _key, _token), post);

            www.chunkedTransfer = false;

            UnityWebRequestAsyncOperation operation = www.SendWebRequest();

            // Wait for request to return
            while (!operation.isDone)
            {
                CheckWebRequestStatus("Could not upload the Trello card.", www);
            }

            Debug.Log("Trello card sent!\nResponse " + www.responseCode);
            return(card);
        }
示例#3
0
        /// <summary>
        /// Given an exception object, a TrelloCard is created and populated with the relevant information from the exception. This is then uploaded to the Trello server.
        /// </summary>
        /// <returns>The exception card.</returns>
        /// <param name="e">E.</param>

        /*public TrelloCard uploadExceptionCardd(Exception e) {
         *
         *      TrelloCard card = new TrelloCard();
         *      card.name = e.GetType().ToString();
         *      card.due = DateTime.Now.ToString();
         *      card.desc = e.Message;
         *      card.idList = _currentListId;
         *
         *      return UploadCard(card);
         * }*/

        /// <summary>
        /// Uploads a given TrelloCard object to the Trello server.
        /// </summary>
        /// <returns>Trello card uploaded.</returns>
        /// <param name="card">Trello card to upload.</param>
        public TrelloCard UploadCard(TrelloCard card)
        {
            WWWForm post = new WWWForm();

            post.AddField("name", card.name);
            post.AddField("desc", card.desc);
            post.AddField("due", card.due);
            post.AddField("idList", card.idList);
            post.AddField("urlSource", card.urlSource);
            if (card.fileSource != null && card.fileName != null)
            {
                post.AddBinaryData("fileSource", card.fileSource, card.fileName);
            }

            WWW www = new WWW(string.Format("{0}?key={1}&token={2}", _cardBaseUrl, _key, _token), post);

            // Wait for request to return
            while (!www.isDone)
            {
                CheckWwwStatus("Could not upload the Trello card.", www);
            }

            Debug.Log("Trello card sent!");
            return(card);
        }
        public IEnumerator PostCard(TrelloCard card)
        {
            WWWForm         postBody   = card.GetPostBody();
            UnityWebRequest webRequest = BuildAuthenticatedWebRequest(CardBaseUrl, postBody);

            yield return(webRequest.SendWebRequest());

            CheckWebRequestStatusAndDispose(webRequest, CardUploadError);
        }
示例#5
0
        /// <summary>
        /// Given an exception object, a TrelloCard is created and populated with the relevant information from the exception. This is then uploaded to the Trello server.
        /// </summary>
        /// <returns>The exception card.</returns>
        /// <param name="e">E.</param>
        public TrelloCard uploadExceptionCard(Exception e)
        {
            TrelloCard card = new TrelloCard();

            card.name   = e.GetType().ToString();
            card.due    = DateTime.Now.ToString();
            card.desc   = e.Message;
            card.idList = currentListId;

            return(uploadCard(card));
        }
示例#6
0
        /// <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);
        }
示例#7
0
        public IEnumerator PostCard(TrelloCard card)
        {
            WWWForm         postBody   = card.GetPostBody();
            UnityWebRequest webRequest = BuildAuthenticatedWebRequest(CardBaseUrl, postBody);

            yield return(webRequest.SendWebRequest());

            if (string.IsNullOrEmpty(webRequest.error))
            {
                LastCardId = JsonUtility.FromJson <TrelloCardResponse>(webRequest.downloadHandler.text).id;
            }
            CheckWebRequestStatusAndDispose(webRequest, CardUploadError);
        }
示例#8
0
        /// <summary>
        /// Sends a given Trello card using the authorization settings.
        /// </summary>
        /// <param name="card">Trello card to send.</param>
        /// <param name="list">Overrides default list.</param>
        /// <param name="board">Overrides default board.</param>
        public void SendNewCard(TrelloCard card, string list = null, string board = null)
        {
            if (board == null)
            {
                board = _defaultBoard;
            }
            if (list == null)
            {
                list = _defaultList;
            }

            StartCoroutine(Send_Internal(card, list, board));
        }
示例#9
0
        /// <summary>
        /// Uploads a given TrelloCard object to the Trello servers.
        /// </summary>
        /// <returns>Your card.</returns>
        /// <param name="card">Your card.</param>
        public TrelloCard uploadCard(TrelloCard card)
        {
            WWWForm post = new WWWForm();

            post.AddField("name", card.name);
            post.AddField("desc", card.desc);
            post.AddField("due", card.due);
            post.AddField("idList", card.idList);
            post.AddField("urlSource", card.urlSource);

            WWW www = new WWW(cardBaseUrl + "?" + "key=" + key + "&token=" + token, post);

            // Wait for request to return
            while (!www.isDone)
            {
                checkWwwStatus("Could not upload Trello card", www);
            }

            return(card);
        }
示例#10
0
        private IEnumerator Send_Internal(TrelloCard card, string list, string board)
        {
            // Create an API instance
            TrelloAPI api = new TrelloAPI(_key, _token);

            // Wait for the Trello boards
            yield return(api.PopulateBoards());

            api.SetCurrentBoard(board);

            // Wait for the Trello lists
            yield return(api.PopulateLists());

            api.SetCurrentList(list);

            // Set the current ID of the selected list
            card.idList = api.GetCurrentListId();

            // Upload to the server
            yield return(api.UploadCard(card));
        }