1use crate::{PrismerClient, types::*};
2use serde_json::json;
3
4pub struct ParseClient<'a> {
5 pub(crate) client: &'a PrismerClient,
6}
7
8impl<'a> ParseClient<'a> {
9 pub async fn submit(&self, input: &str, mode: Option<&str>) -> Result<ApiResponse<ParseResult>, PrismerError> {
11 self.client.request(
12 reqwest::Method::POST,
13 "/api/parse",
14 Some(json!({
15 "input": input,
16 "mode": mode.unwrap_or("fast"),
17 })),
18 ).await
19 }
20
21 pub async fn status(&self, task_id: &str) -> Result<ApiResponse<ParseResult>, PrismerError> {
23 self.client.request(
24 reqwest::Method::GET,
25 &format!("/api/parse/status/{}", task_id),
26 None,
27 ).await
28 }
29
30 pub async fn result(&self, task_id: &str) -> Result<ApiResponse<ParseResult>, PrismerError> {
32 self.client.request(
33 reqwest::Method::GET,
34 &format!("/api/parse/result/{}", task_id),
35 None,
36 ).await
37 }
38}