pub struct KnowledgeBaseApi<'a> { /* private fields */ }Expand description
Knowledge Base (FAQ) endpoints.
Implementations§
Source§impl<'a> KnowledgeBaseApi<'a>
impl<'a> KnowledgeBaseApi<'a>
Sourcepub async fn list(&self) -> Result<Vec<KbAnswer>>
pub async fn list(&self) -> Result<Vec<KbAnswer>>
List every answer known to the instance, flattened to
KbAnswers (title + category, no body).
POST /api/v1/knowledge_bases/init.
Sourcepub async fn get(&self, answer_id: u64) -> Result<KbAnswer>
pub async fn get(&self, answer_id: u64) -> Result<KbAnswer>
Fetch a single answer by its numeric id, including its full body.
Returns Error::NotFound when no answer with that id exists.
Issues two POST /api/v1/knowledge_bases/init calls: one for the
structure and one that requests the answer’s translation content.
Sourcepub async fn list_knowledge_bases(&self) -> Result<Vec<KbInfo>>
pub async fn list_knowledge_bases(&self) -> Result<Vec<KbInfo>>
Every knowledge base on the instance (from the init bundle).
POST /api/v1/knowledge_bases/init.
Sourcepub async fn list_categories(&self) -> Result<Vec<KbCategory>>
pub async fn list_categories(&self) -> Result<Vec<KbCategory>>
Every category of every knowledge base (from the init bundle),
sorted by id.
POST /api/v1/knowledge_bases/init.
Sourcepub async fn get_category(&self, category_id: u64) -> Result<KbCategory>
pub async fn get_category(&self, category_id: u64) -> Result<KbCategory>
Fetch a single category by its numeric id.
Returns Error::NotFound when no category with that id exists.
POST /api/v1/knowledge_bases/init.
Sourcepub async fn create_category(
&self,
kb_id: u64,
category: NewKbCategory,
) -> Result<KbCategory>
pub async fn create_category( &self, kb_id: u64, category: NewKbCategory, ) -> Result<KbCategory>
Create a category in the given knowledge base (primary locale).
kb_id is explicit because a new category cannot be resolved from
init. Returns Error::NotFound when the kb_id is unknown and
Error::Config when the KB has no locale.
POST /api/v1/knowledge_bases/:kb_id/categories.
Sourcepub async fn update_category(
&self,
category_id: u64,
patch: KbCategoryPatch,
) -> Result<KbCategory>
pub async fn update_category( &self, category_id: u64, patch: KbCategoryPatch, ) -> Result<KbCategory>
Partial update; kb_id resolved from the category via init.
An all-None patch skips the HTTP call and returns the current
state. Returns Error::NotFound when no category with that id
exists.
PATCH /api/v1/knowledge_bases/:kb_id/categories/:id.
Sourcepub async fn delete_category(&self, category_id: u64) -> Result<()>
pub async fn delete_category(&self, category_id: u64) -> Result<()>
Delete a category.
Zammad refuses (422) when the category still has answers or child
categories; that surfaces as Error::Api.
DELETE /api/v1/knowledge_bases/:kb_id/categories/:id.
Sourcepub async fn create_answer(&self, answer: NewKbAnswer) -> Result<KbAnswer>
pub async fn create_answer(&self, answer: NewKbAnswer) -> Result<KbAnswer>
Create a new answer in a category, in the knowledge base’s primary locale.
When NewKbAnswer::published is true a second
POST .../answers/:id/publish call makes it public right away;
otherwise it is left as a draft. The knowledge base and locale are
resolved from the category.
POST /api/v1/knowledge_bases/:kb_id/answers.
Sourcepub async fn update_answer(
&self,
answer_id: u64,
patch: KbAnswerPatch,
) -> Result<KbAnswer>
pub async fn update_answer( &self, answer_id: u64, patch: KbAnswerPatch, ) -> Result<KbAnswer>
Update an existing answer’s title, body, and/or published state. Fields
left as None in the KbAnswerPatch are preserved.
Returns Error::NotFound when no answer with that id exists.
PATCH /api/v1/knowledge_bases/:kb_id/answers/:id.
Sourcepub async fn delete_answer(&self, answer_id: u64) -> Result<()>
pub async fn delete_answer(&self, answer_id: u64) -> Result<()>
Delete an answer.
The knowledge base is resolved answer → category → kb.
DELETE /api/v1/knowledge_bases/:kb_id/answers/:id.
Sourcepub fn search(&self, query: impl Into<String>) -> SearchKnowledgeBase<'a>
pub fn search(&self, query: impl Into<String>) -> SearchKnowledgeBase<'a>
Full-text search across the Knowledge Base.
Returns a builder; call SearchKnowledgeBase::send to run it.