paypal_rust/resources/enums/
usage.rs

1use serde::{Deserialize, Serialize};
2
3/// Indicates if this is a first or subsequent payment using a stored payment source
4/// (also referred to as stored credential or card on file).
5#[derive(Copy, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
6pub enum Usage {
7    /// Indicates the Initial/First payment with a payment_source that is intended to be stored upon
8    //  successful processing of the payment.
9    #[serde(rename = "FIRST")]
10    First,
11    ///  Indicates a payment using a stored payment_source which has been successfully used previously for a payment.
12    #[serde(rename = "SUBSEQUENT")]
13    Subsequent,
14    /// Indicates that PayPal will derive the value of `FIRST` or `SUBSEQUENT` based on data available to PayPal.
15    #[serde(rename = "Derived")]
16    Derived,
17}
18
19impl Usage {
20    pub const fn as_str(self) -> &'static str {
21        match self {
22            Self::First => "FIRST",
23            Self::Subsequent => "SUBSEQUENT",
24            Self::Derived => "Derived",
25        }
26    }
27}
28
29impl AsRef<str> for Usage {
30    fn as_ref(&self) -> &str {
31        self.as_str()
32    }
33}
34
35impl std::fmt::Display for Usage {
36    fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
37        self.as_str().fmt(formatter)
38    }
39}