Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 39 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use serde::Serialize;
pub struct Price {
pub annual: &'static str,
pub annual_per_month: &'static str,
pub annual_renewal_price: &'static str,
pub monthly: &'static str,
}

Expand All @@ -18,56 +19,67 @@ pub static PRICES: phf::Map<&'static str, Price> = phf_map! {
"USD" => Price {
annual: "$60",
annual_per_month: "$5",
annual_renewal_price: "$45",
monthly: "$6",
},
"JPY" => Price {
annual: "9,000円",
annual_per_month: "750円",
monthly: "900円",
},
"GBP" => Price {
annual: "£45",
annual_per_month: "£3.75",
monthly: "£4.50",
},
"EUR" => Price {
annual: "€50",
annual_per_month: "€4.17",
monthly: "€5",
"AUD" => Price {
annual: "A$90",
annual_per_month: "A$7.50",
annual_renewal_price: "A$67.50",
monthly: "A$9",
},
"BRL" => Price {
annual: "R$300",
annual_per_month: "R$25",
annual_renewal_price: "R$225",
monthly: "R$30",
},
"CAD" => Price {
annual: "C$80",
annual_per_month: "C$6.67",
annual_renewal_price: "C$60",
monthly: "C$8",
},
"CNY" => Price {
annual: "400元",
annual_per_month: "33元",
annual_renewal_price: "300元",
monthly: "40元",
},
"AUD" => Price {
annual: "A$90",
annual_per_month: "A$7.50",
monthly: "A$9",
"EUR" => Price {
annual: "€50",
annual_per_month: "€4.17",
annual_renewal_price: "€37.50",
monthly: "€5",
},
"GBP" => Price {
annual: "£45",
annual_per_month: "£3.75",
annual_renewal_price: "£33.75",
monthly: "£4.50",
},
"JPY" => Price {
annual: "9,000円",
annual_per_month: "750円",
annual_renewal_price: "6,750円",
monthly: "900円",
},
"KRW" => Price {
annual: "₩80,000",
annual_per_month: "₩6,667",
annual_renewal_price: "₩60,000",
monthly: "₩8,000",
},
"CAD" => Price {
annual: "C$80",
annual_per_month: "C$6.67",
monthly: "C$8",
},
"TWD" => Price {
annual: "NT$1,600",
annual_per_month: "NT$133",
annual_renewal_price: "NT$1,200",
monthly: "NT$160",
},
"Other" => Price {
annual: "60 USD",
annual_per_month: "5 USD",
annual_renewal_price: "45 USD",
monthly: "6 USD",
},
};
Expand Down Expand Up @@ -201,6 +213,7 @@ fn get_currency_and_price(country: &str) -> PriceResponse {
currency,
annual: price.annual,
annual_per_month: price.annual_per_month,
annual_renewal_price: price.annual_renewal_price,
monthly: price.monthly,
}
}
Expand All @@ -210,6 +223,7 @@ struct PriceResponse {
currency: &'static str,
annual: &'static str,
annual_per_month: &'static str,
annual_renewal_price: &'static str,
monthly: &'static str,
}

Expand Down Expand Up @@ -260,13 +274,15 @@ mod tests {
assert_eq!(res.currency, "JPY");
assert_eq!(res.annual, "9,000円");
assert_eq!(res.annual_per_month, "750円");
assert_eq!(res.annual_renewal_price, "6,750円");
assert_eq!(res.monthly, "900円");
}
{ // Unknown country
let res = get_currency_and_price("ZZ");
assert_eq!(res.currency, OTHER_CURRENCY_NAME);
assert_eq!(res.annual, "60 USD");
assert_eq!(res.annual_per_month, "5 USD");
assert_eq!(res.annual_renewal_price, "45 USD");
assert_eq!(res.monthly, "6 USD");
}
}
Expand Down
Loading