azure-devops 0.1.0

Idiomatic Rust client for Azure DevOps REST APIs
Documentation
use super::super::models::{JsonPatchOperation, WorkItem};
use super::super::WorkItemsClient;
use crate::constants::ApiPath;
use crate::error::Result;

impl WorkItemsClient<'_> {
    /// Update an existing work item.
    ///
    /// # Arguments
    ///
    /// * `id` — The work item ID to update.
    /// * `patch_document` — A slice of [`JsonPatchOperation`] describing the
    ///   fields to modify. Use [`JsonPatchOperation::replace()`] or
    ///   [`JsonPatchOperation::add()`] to build operations.
    ///
    /// # Returns
    ///
    /// The updated [`WorkItem`].
    pub async fn update(&self, id: i64, patch_document: &[JsonPatchOperation]) -> Result<WorkItem> {
        let body = crate::work_items::helpers::serialize_patch(patch_document)?;
        let p = ApiPath::work_item(id);
        self.http.patch_json_patch(&p, &[], &body).await
    }
}