use std::fmt;
use crate::credential::Credential;
pub const DEFAULT_ENDPOINT: &str = "https://service.mtcaptcha.com/mtcv1/api/checktoken";
#[derive(PartialEq, Eq)]
pub struct MtCaptchaConfig {
private_key: Credential,
endpoint: String,
}
impl MtCaptchaConfig {
pub fn new(private_key: impl Into<String>) -> Self {
Self {
private_key: Credential::new(private_key),
endpoint: DEFAULT_ENDPOINT.to_owned(),
}
}
#[must_use]
pub fn with_endpoint(mut self, endpoint: impl Into<String>) -> Self {
self.endpoint = endpoint.into();
self
}
#[must_use]
pub fn endpoint(&self) -> &str {
&self.endpoint
}
}
impl fmt::Debug for MtCaptchaConfig {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("MtCaptchaConfig")
.field("private_key", &self.private_key)
.field("endpoint", &self.endpoint)
.finish()
}
}