epochal_api/time_portal/
mod.rs1use chrono::{DateTime, Utc};
5use reqwest::{Method, RequestBuilder};
6
7use crate::client::{Client, with_as_of};
8
9pub mod entities;
10pub mod sandbox;
11pub mod web;
12
13const PREFIX: &str = "/v1/time-portal";
14
15#[derive(Clone, Debug)]
19pub struct TimePortal {
20 client: Client,
21 as_of: DateTime<Utc>,
22}
23
24impl Client {
25 pub fn time_portal(&self, as_of: DateTime<Utc>) -> TimePortal {
27 TimePortal {
28 client: self.clone(),
29 as_of,
30 }
31 }
32}
33
34impl TimePortal {
35 pub fn client(&self) -> &Client {
37 &self.client
38 }
39
40 pub fn as_of(&self) -> DateTime<Utc> {
42 self.as_of
43 }
44
45 fn request(&self, method: Method, path: &str) -> RequestBuilder {
46 self.client.request(method, &format!("{PREFIX}{path}"))
47 }
48
49 fn held(&self, method: Method, path: &str) -> RequestBuilder {
51 with_as_of(self.request(method, path), self.as_of)
52 }
53}