use crate::http::{request::Request, Method};
pub struct AvgPrice {
symbol: String,
}
impl AvgPrice {
pub fn new(symbol: &str) -> Self {
Self {
symbol: symbol.to_owned(),
}
}
}
impl From<AvgPrice> for Request {
fn from(request: AvgPrice) -> Request {
let params = vec![("symbol".to_owned(), request.symbol)];
Request {
path: "/api/v3/avgPrice".to_owned(),
method: Method::Get,
params,
credentials: None,
sign: false,
}
}
}
#[cfg(test)]
mod tests {
use super::AvgPrice;
use crate::http::{request::Request, Method};
#[test]
fn market_avg_price_convert_to_request_test() {
let request: Request = AvgPrice::new("BNBUSDT").into();
assert_eq!(
request,
Request {
path: "/api/v3/avgPrice".to_owned(),
credentials: None,
method: Method::Get,
params: vec![("symbol".to_owned(), "BNBUSDT".to_string()),],
sign: false
}
);
}
}