use serde::{Deserialize, Serialize};
use crate::{
http::de_str,
porkbun::Auth,
RecordType
};
#[derive(Deserialize, Serialize, Debug)]
pub struct AuthOnly {
pub secretapikey: String,
pub apikey: String,
}
impl From<Auth> for AuthOnly {
fn from(value: Auth) -> Self {
Self {
secretapikey: value.secret,
apikey: value.key,
}
}
}
#[derive(Deserialize, Serialize, Debug)]
pub struct CreateUpdate<T> {
pub secretapikey: String,
pub apikey: String,
pub name: String,
#[serde(rename = "type")]
pub rtype: RecordType,
pub content: T,
pub ttl: u32,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct Record<T> {
#[serde(deserialize_with = "de_str")]
pub id: u64,
pub name: String,
#[serde(rename = "type")]
pub rtype: RecordType,
pub content: T,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct Records<T> {
pub records: Vec<Record<T>>
}