-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathendpoint.rs
29 lines (26 loc) · 853 Bytes
/
endpoint.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use std::fmt::Display;
use crate::BASE_URL;
/// Enum representing the available endpoints.
pub(crate) enum NbrApiEndpoint {
/// Corresponds to the latest available rates.
Latest,
/// Corresponds to the last 10 days rates.
Last10Days,
/// Corresponds to the historical rates for a given year.
Historical(usize),
}
impl Display for NbrApiEndpoint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}/{}",
BASE_URL,
match self {
NbrApiEndpoint::Latest => "nbrfxrates.xml".to_owned(),
NbrApiEndpoint::Last10Days => "nbrfxrates10days.xml".to_owned(),
NbrApiEndpoint::Historical(year) =>
format!("files/xml/years/nbrfxrates{}.xml", year),
}
)
}
}