use crate::error::Result;
use crate::http::HttpClient;
use crate::types::{Hip3Instrument, Instrument, LighterInstrument};
#[derive(Debug, Clone)]
pub struct InstrumentsResource {
http: HttpClient,
prefix: String,
}
impl InstrumentsResource {
pub(crate) fn new(http: HttpClient, prefix: &str) -> Self {
Self {
http,
prefix: prefix.to_string(),
}
}
pub async fn list(&self) -> Result<Vec<Instrument>> {
self.http
.get(&format!("{}/instruments", self.prefix), &[])
.await
}
pub async fn get(&self, coin: &str) -> Result<Instrument> {
self.http
.get(&format!("{}/instruments/{}", self.prefix, coin), &[])
.await
}
}
#[derive(Debug, Clone)]
pub struct LighterInstrumentsResource {
http: HttpClient,
prefix: String,
}
impl LighterInstrumentsResource {
pub(crate) fn new(http: HttpClient, prefix: &str) -> Self {
Self {
http,
prefix: prefix.to_string(),
}
}
pub async fn list(&self) -> Result<Vec<LighterInstrument>> {
self.http
.get(&format!("{}/instruments", self.prefix), &[])
.await
}
pub async fn get(&self, coin: &str) -> Result<LighterInstrument> {
self.http
.get(&format!("{}/instruments/{}", self.prefix, coin), &[])
.await
}
}
#[derive(Debug, Clone)]
pub struct Hip3InstrumentsResource {
http: HttpClient,
prefix: String,
}
impl Hip3InstrumentsResource {
pub(crate) fn new(http: HttpClient, prefix: &str) -> Self {
Self {
http,
prefix: prefix.to_string(),
}
}
pub async fn list(&self) -> Result<Vec<Hip3Instrument>> {
self.http
.get(&format!("{}/instruments", self.prefix), &[])
.await
}
pub async fn get(&self, coin: &str) -> Result<Hip3Instrument> {
self.http
.get(&format!("{}/instruments/{}", self.prefix, coin), &[])
.await
}
}