use crate::error::Result;
use crate::http::HttpClient;
use crate::types::api::FindResponse;
use reqwest::Method;
#[derive(Clone)]
pub struct FindApi {
http: HttpClient,
}
impl FindApi {
pub fn new(http: HttpClient) -> Self {
Self { http }
}
pub async fn text(&self, pattern: &str) -> Result<FindResponse> {
let encoded = urlencoding::encode(pattern);
self.http
.request_json(Method::GET, &format!("/find?pattern={encoded}"), None)
.await
}
pub async fn files(&self, query: &str) -> Result<FindResponse> {
let encoded = urlencoding::encode(query);
self.http
.request_json(Method::GET, &format!("/find/file?query={encoded}"), None)
.await
}
pub async fn symbols(&self, query: &str) -> Result<FindResponse> {
let encoded = urlencoding::encode(query);
self.http
.request_json(Method::GET, &format!("/find/symbol?query={encoded}"), None)
.await
}
}