use std::sync::Arc;
use crate::core::{CreditResponse, HttpClient, IntoBody, RequestOptions, Result};
use crate::services::CreditService;
#[derive(Clone, Debug)]
pub struct ConsultaService {
base: CreditService,
}
impl ConsultaService {
pub(crate) fn new(client: Arc<HttpClient>) -> Self {
Self {
base: CreditService::new(client),
}
}
pub fn with_options(&self, options: RequestOptions) -> Self {
Self {
base: self.base.with_options(options),
}
}
pub async fn generic(&self, service: &str, body: impl IntoBody) -> Result<CreditResponse> {
self.base.request(service, body).await
}
pub async fn quod(&self, body: impl IntoBody) -> Result<CreditResponse> {
self.base.credit_post("quod/cnpj/credits", body).await
}
pub async fn veiculos_base(&self, base: &str, body: impl IntoBody) -> Result<CreditResponse> {
self.base
.credit_post(&format!("vehicles/base/000/{base}"), body)
.await
}
pub async fn cep_distancia(&self, body: impl IntoBody) -> Result<CreditResponse> {
self.base.credit_post("cep/distancia/calcular", body).await
}
pub async fn proxy_seller(&self, body: impl IntoBody) -> Result<CreditResponse> {
self.base.credit_post("proxy/seller/credits", body).await
}
}
impl std::ops::Deref for ConsultaService {
type Target = CreditService;
fn deref(&self) -> &CreditService {
&self.base
}
}
credit_methods! {
ConsultaService {
cpf => "cpf",
cnpj => "cnpj",
cnh => "cnh",
cep => "cep",
veiculos => "veiculos",
vehicles => "vehicles",
telefone => "telefone",
ddd_anatel => "ddd-anatel",
geoip => "geoip",
rastreio => "rastreio",
crm => "crm",
crbm => "crbm",
cro => "cro",
weather => "weather-api",
emissao_notas => "emissao-notas",
frete_antt => "frete-antt",
api_rntrc => "api-rntrc",
}
}