Exemple #1
0
        /// <summary>
        /// Retrieves the project details for a given project id.
        /// </summary>
        /// <param name="projectId">The ID of the project to query.</param>
        /// <returns>Project details associated with a given project id, or null if no match is found.</returns>
        public projectType GetProjectById(string projectId)
        {
            Uri uri = Endpoints.GetUpdateProjectUri(baseUri, GetSiteId(), projectId);

            // Construct payload.
            tsRequest requestPayload = new tsRequest {
                Item = new projectType()
            };

            // Issue request.
            var        errorMessage = String.Format("Failed to retrieve project details for project '{0}' in site '{1}'", projectId, siteName);
            ApiRequest request      = new ApiRequest(uri, HttpMethod.Put, GetAuthToken(), headers: null, body: requestPayload.SerializeBody());
            tsResponse response     = request.IssueRequest(errorMessage);

            return(response.GetProject());
        }
Exemple #2
0
        /// <summary>
        /// Updates the project name & description fields for a given project.
        /// </summary>
        /// <param name="projectId">The ID of the existing project to update.</param>
        /// <param name="newProjectName">The new project name to set.</param>
        /// <param name="newProjectDescription">The new project description to set.</param>
        public void UpdateProject(string projectId, string newProjectName, string newProjectDescription)
        {
            Uri uri = Endpoints.GetUpdateProjectUri(baseUri, GetSiteId(), projectId);

            // Construct payload.
            tsRequest requestPayload = new tsRequest
            {
                Item = new projectType
                {
                    name        = newProjectName,
                    description = newProjectDescription
                }
            };

            // Issue request.
            var        errorMessage = String.Format("Failed to update project in site '{0}'", siteName);
            ApiRequest request      = new ApiRequest(uri, HttpMethod.Put, GetAuthToken(), headers: null, body: requestPayload.SerializeBody());

            request.IssueRequest(errorMessage);
        }