示例#1
0
        /// <summary>
        /// Get a task by id
        /// </summary>
        /// <param name="paramsGetTaskById">param object of get task by id request</param>
        /// <returns>ResponseGeneric with ResponseModelTask response object</returns>
        public ResponseGeneric <ResponseModelTask, ResponseError> GetTaskById(ParamsGetTaskById paramsGetTaskById)
        {
            var client  = new RestClient(_baseAddress);
            var request = new RestRequest($"task/{paramsGetTaskById.TaskId}", Method.GET);

            request.AddHeader("authorization", AccessToken);

            // execute the request
            ResponseGeneric <ResponseModelTask, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseModelTask, ResponseError>(client, request);

            return(result);
        }
示例#2
0
        /// <summary>
        /// Get a team's webhooks. This team must be one of the authorized teams for this token.
        /// </summary>
        /// <param name="paramsGetTeamWebhook">param object of get team Webhook request</param>
        /// <returns>ResponseGeneric with ResponseTeamWebhook response object</returns>
        public ResponseGeneric <ResponseWebhooks, ResponseError> GetTeamWebhooks(ParamsGetTeamWebhooks paramsGetTeamWebhook)
        {
            var client  = new RestClient(_baseAddress);
            var request = new RestRequest($"team/{paramsGetTeamWebhook.TeamId}/webhook", Method.GET);

            request.AddHeader("authorization", AccessToken);

            // execute the request
            ResponseGeneric <ResponseWebhooks, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseWebhooks, ResponseError>(client, request);

            return(result);
        }
示例#3
0
        /// <summary>
        /// Get a space's lists AKA folderless lists
        /// </summary>
        /// <param name="paramsGetFolderlessLists">param object of get folderless lists request</param>
        /// <returns>ResponseGeneric with ResponseFolderlessLists response object</returns>
        public ResponseGeneric <ResponseFolderlessLists, ResponseError> GetFolderlessLists(ParamsGetFolderlessLists paramsGetFolderlessLists)
        {
            var client  = new RestClient(_baseAddress);
            var request = new RestRequest($"space/{paramsGetFolderlessLists.SpaceId}/list", Method.GET);

            request.AddHeader("authorization", AccessToken);

            // execute the request
            ResponseGeneric <ResponseFolderlessLists, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseFolderlessLists, ResponseError>(client, request);

            return(result);
        }
示例#4
0
        /// <summary>
        /// Get the authorized teams for this token
        /// </summary>
        /// <returns>ResponseGeneric with ResponseAuthorizedTeams response object</returns>
        public ResponseGeneric <ResponseAuthorizedTeams, ResponseError> GetAuthorizedTeams()
        {
            var client  = new RestClient(_baseAddress);
            var request = new RestRequest($"team", Method.GET);

            request.AddHeader("authorization", AccessToken);

            // execute the request
            ResponseGeneric <ResponseAuthorizedTeams, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseAuthorizedTeams, ResponseError>(client, request);

            return(result);
        }
示例#5
0
        /// <summary>
        /// Edit Task informations.
        /// </summary>
        /// <param name="paramsEditTask">param object of Edit Task request</param>
        /// <param name="requestData">RequestEditTask object</param>
        /// <returns>ResponseGeneric with ResponseSuccess response object</returns>
        public ResponseGeneric <ResponseModelTask, ResponseError> EditTask(ParamsEditTask paramsEditTask, RequestEditTask requestData)
        {
            var client  = new RestClient(_baseAddress);
            var request = new RestRequest($"task/{paramsEditTask.TaskId}", Method.PUT);

            request.AddHeader("authorization", AccessToken);
            request.AddJsonBody(requestData);

            // execute the request
            ResponseGeneric <ResponseModelTask, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseModelTask, ResponseError>(client, request);

            return(result);
        }
示例#6
0
        /// <summary>
        /// Create a webhook in a Team
        /// </summary>
        /// <param name="paramsCreateTeamWebhook">param object of create webhook request</param>
        /// <param name="requestData">RequestCreateTeamWebhook object</param>
        /// <returns>ResponseGeneric with ResponseWebhook response object</returns>
        public ResponseGeneric <ResponseWebhook, ResponseError> CreateTeamWebhook(ParamsCreateTeamWebhook paramsCreateTeamWebhook, RequestCreateTeamWebhook requestData)
        {
            requestData.ValidateData();

            var client  = new RestClient(_baseAddress);
            var request = new RestRequest($"team/{paramsCreateTeamWebhook.TeamId}/webhook", Method.POST);

            request.AddHeader("authorization", AccessToken);
            request.AddJsonBody(requestData);

            // execute the request
            ResponseGeneric <ResponseWebhook, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseWebhook, ResponseError>(client, request);

            return(result);
        }
示例#7
0
        /// <summary>
        /// Create Task in List.
        /// </summary>
        /// <param name="paramCreateTaskInList">params object of create task in list request</param>
        /// <param name="requestData">RequestCreateTaskInList object</param>
        /// <returns>ResponseGeneric with ModelTask object Expected</returns>
        public ResponseGeneric <ResponseModelTask, ResponseError> CreateTaskInList(ParamsCreateTaskInList paramsCreateTaskInList, RequestCreateTaskInList requestData)
        {
            requestData.ValidateData();

            var client            = new RestClient(_baseAddress);
            var createListRequest = new RestRequest($"list/{paramsCreateTaskInList.ListId}/task", Method.POST);

            createListRequest.AddHeader("authorization", AccessToken);
            createListRequest.AddJsonBody(requestData);

            // execute the request
            ResponseGeneric <ResponseModelTask, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseModelTask, ResponseError>(client, createListRequest);

            return(result);
        }
示例#8
0
        /// <summary>
        /// Create folderless List
        /// </summary>
        /// <param name="paramsCreateList">param object of create list request</param>
        /// <param name="requestData">RequestCreateList object</param>
        /// <returns>ResponseGeneric with ModelList response object</returns>
        public ResponseGeneric <ResponseModelList, ResponseError> CreateFolderlessList(ParamsCreateFolderlessList paramsCreateList, RequestCreateList requestData)
        {
            requestData.ValidateData();

            var client  = new RestClient(_baseAddress);
            var request = new RestRequest($"space/{paramsCreateList.SpaceId}/list", Method.POST);

            request.AddHeader("authorization", AccessToken);
            request.AddJsonBody(requestData);

            // execute the request
            ResponseGeneric <ResponseModelList, ResponseError> result = RestSharperHelper.ExecuteRequest <ResponseModelList, ResponseError>(client, request);

            return(result);
        }
示例#9
0
        /// <summary>
        /// Create Object with <see cref="ParamsAccessToken"/>
        /// </summary>
        /// <param name="paramAccessToken">param access token object</param>
        public static ClickUpApi Create(ParamsAccessToken paramAccessToken)
        {
            var client  = new RestClient(_baseAddress);
            var request = new RestRequest("oauth/token", Method.POST);

            request.AddParameter("client_id", paramAccessToken.ClientId);
            request.AddParameter("client_secret", paramAccessToken.ClientSecret);
            request.AddParameter("code", paramAccessToken.Code);

            // execute the request
            ResponseGeneric <ResponseAccessToken, ResponseError> response = RestSharperHelper.ExecuteRequest <ResponseAccessToken, ResponseError>(client, request);

            string accessToken;

            // Manage Response
            if (response.ResponseSuccess == null)
            {
                throw new Exception(response.ResponseError.Err);
            }

            accessToken = response.ResponseSuccess.AccessToken;

            return(new ClickUpApi(accessToken));
        }