use super::super::models::{JsonPatchOperation, WorkItem};
use super::super::WorkItemsClient;
use crate::constants::ApiPath;
use crate::error::Result;
impl WorkItemsClient<'_> {
/// Create a new work item.
///
/// # Arguments
///
/// * `project` — The project name where the work item will be created.
/// * `work_item_type` — The work item type (e.g., `"Bug"`, `"Task"`, `"User Story"`).
/// * `patch_document` — A slice of [`JsonPatchOperation`] describing the
/// fields to set. Use [`JsonPatchOperation::add()`] to build operations.
///
/// # Returns
///
/// The newly created [`WorkItem`].
pub async fn create(
&self,
project: &str,
work_item_type: &str,
patch_document: &[JsonPatchOperation],
) -> Result<WorkItem> {
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, &[], &body).await
}
}