context69_sdk/client/
search.rs1use context69_contracts::{DocumentResponse, SearchRequest, SearchResponse};
2use reqwest::Method;
3
4use super::Context69Client;
5use crate::Error;
6
7pub struct SearchApi<'a> {
8 client: &'a Context69Client,
9}
10
11impl<'a> SearchApi<'a> {
12 pub(crate) fn new(client: &'a Context69Client) -> Self {
13 Self { client }
14 }
15
16 pub async fn execute(&self, request: &SearchRequest) -> Result<SearchResponse, Error> {
17 self.client
18 .execute_json(
19 self.client
20 .authorized_request(Method::POST, "/v1/search")
21 .await?
22 .json(request),
23 )
24 .await
25 }
26}
27
28pub struct DocumentApi<'a> {
29 client: &'a Context69Client,
30 document_id: i64,
31}
32
33impl<'a> DocumentApi<'a> {
34 pub(crate) fn new(client: &'a Context69Client, document_id: i64) -> Self {
35 Self {
36 client,
37 document_id,
38 }
39 }
40
41 pub async fn get(&self) -> Result<DocumentResponse, Error> {
42 let path = format!("/v1/documents/{}", self.document_id);
43 self.client
44 .execute_json(self.client.authorized_request(Method::GET, &path).await?)
45 .await
46 }
47}