use chrono::{DateTime, Utc};
use reqwest::{Method, RequestBuilder};
use crate::client::{Client, with_as_of};
pub mod entities;
pub mod sandbox;
pub mod web;
const PREFIX: &str = "/v1/time-portal";
#[derive(Clone, Debug)]
pub struct TimePortal {
client: Client,
as_of: DateTime<Utc>,
}
impl Client {
pub fn time_portal(&self, as_of: DateTime<Utc>) -> TimePortal {
TimePortal {
client: self.clone(),
as_of,
}
}
}
impl TimePortal {
pub fn client(&self) -> &Client {
&self.client
}
pub fn as_of(&self) -> DateTime<Utc> {
self.as_of
}
fn request(&self, method: Method, path: &str) -> RequestBuilder {
self.client.request(method, &format!("{PREFIX}{path}"))
}
fn held(&self, method: Method, path: &str) -> RequestBuilder {
with_as_of(self.request(method, path), self.as_of)
}
}