Skip to content

Commit

Permalink
fix arm_swiss missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky committed Sep 27, 2024
1 parent a27d94a commit a9465c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ async fn collect_ardshin(client: &Client) -> Result<Vec<Rate>, Error> {

async fn collect_arm_swiss(client: &Client) -> Result<Vec<Rate>, Error> {
let resp: arm_swiss::Response = arm_swiss::Response::get_rates(&client).await?;
let rates = resp
.lmasbrate
let Some(lmasbrate) = resp.lmasbrate else {
return Err(Error::NoRates);
};
let rates = lmasbrate
.iter()
.map(|v| Rate {
currency: v.iso.clone(),
Expand Down
27 changes: 14 additions & 13 deletions src/sources/arm_swiss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ use serde::Deserialize;

pub const API_URL: &str = "https://www.armswissbank.am/include/ajax.php";

#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize, Default)]
#[serde(default)]
pub struct Response {
pub lmasbrate: Vec<LmasbRate>,
pub imworldcuratesusd: Vec<ImWorldCuRatesUSD>,
pub imcuioil: Vec<ImCui>,
pub imcuigold: Vec<ImCui>,
pub imwmius: Vec<ImWmi>,
pub imwmiasiapac: Vec<ImWmi>,
pub imwmieurus: Vec<ImWmi>,
pub imlibor: Vec<ImlIbor>,
pub imeuribor: Vec<ImEurIbor>,
pub lmasbrate: Option<Vec<LmasbRate>>,
pub imworldcuratesusd: Option<Vec<ImWorldCuRatesUSD>>,
pub imcuioil: Option<Vec<ImCui>>,
pub imcuigold: Option<Vec<ImCui>>,
pub imwmius: Option<Vec<ImWmi>>,
pub imwmiasiapac: Option<Vec<ImWmi>>,
pub imwmieurus: Option<Vec<ImWmi>>,
pub imlibor: Option<Vec<ImlIbor>>,
pub imeuribor: Option<Vec<ImEurIbor>>,
#[serde(rename = "lmgoldRate")]
pub lmgold_rate: Vec<LmGoldRate>,
pub imusakey: Vec<ImKey>,
pub imeukey: Vec<ImKey>,
pub lmgold_rate: Option<Vec<LmGoldRate>>,
pub imusakey: Option<Vec<ImKey>>,
pub imeukey: Option<Vec<ImKey>>,
}

impl SourceSingleUrlTrait for Response {
Expand Down

0 comments on commit a9465c9

Please sign in to comment.