azure-devops 0.1.0

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

impl WorkItemsClient<'_> {
    /// Create a new work item with additional options.
    ///
    /// # Arguments
    ///
    /// * `project` — The project name.
    /// * `work_item_type` — The work item type (e.g., `"Bug"`).
    /// * `patch_document` — A slice of [`JsonPatchOperation`] describing the fields.
    /// * `options` — [`CreateWorkItemOptions`] for validation, rule bypass, and notifications.
    ///
    /// # Returns
    ///
    /// The newly created [`WorkItem`].
    pub async fn create_with_options(
        &self,
        project: &str,
        work_item_type: &str,
        patch_document: &[JsonPatchOperation],
        options: &CreateWorkItemOptions,
    ) -> Result<WorkItem> {
        let qp = options.to_query_params();
        let q = crate::util::ref_query(&qp);
        let body = crate::work_items::helpers::serialize_patch(patch_document)?;
        let p = ApiPath::work_item_create(project, work_item_type);
        self.http.post_json_patch(&p, &q, &body).await
    }
}