Ejemplo n.º 1
0
        /// <summary>
        /// Update the indicated label.
        /// </summary>
        /// <param name="labelID">Label identifier.</param>
        /// <param name="labelName">Name of the label.</param>
        /// <returns>Indicates if the modification has been made.</returns>
        public async Task <bool> UpdateLabelAsync(long labelID, string labelName)
        {
            var parameters = new LabelJson(labelName);

            RestResponse result = await _callerRestApiTodoist.CallRestMethodAsync(Method.Post, $"labels/{ labelID }", Guid.NewGuid().ToString(), null, parameters);

            return(result.StatusCode == System.Net.HttpStatusCode.NoContent);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a label.
        /// </summary>
        /// <param name="labelName">Name of the label.</param>
        /// <returns>Created label.</returns>
        public async Task <LabelModel> CreateLabelAsync(string labelName)
        {
            var parameters = new LabelJson(labelName);

            RestResponse result = await _callerRestApiTodoist.CallRestMethodAsync(Method.Post, "labels", Guid.NewGuid().ToString(), null, parameters);

            if (result.StatusCode == System.Net.HttpStatusCode.OK &&
                result.ContentType == "application/json")
            {
                return(JsonConvert.DeserializeObject <LabelModel>(result.Content));
            }

            return(null);
        }