paypal_rust/resources/money.rs
1use serde::{Deserialize, Serialize};
2
3use crate::resources::enums::currency_code::CurrencyCode;
4
5#[derive(Clone, Debug, Default, Deserialize, Serialize)]
6pub struct Money {
7 /// The three-character ISO-4217 currency code that identifies the currency.
8 pub currency_code: CurrencyCode,
9
10 /// The value, which might be:
11 /// * An integer for currencies like JPY that are not typically fractional.
12 /// * A decimal fraction for currencies like TND that are subdivided into thousandths.
13 /// For the required number of decimal places for a currency code, see [Currency Codes](<https://developer.paypal.com/api/rest/reference/currency-codes/>).
14 pub value: String,
15}
16
17impl Money {
18 #[must_use]
19 pub const fn new(currency_code: CurrencyCode, value: String) -> Money {
20 Self {
21 currency_code,
22 value,
23 }
24 }
25}