Skip to main content

app_store_server_library/models/
extend_reason_code.rs

1use serde::{Deserialize, Serialize};
2
3/// The code that represents the reason for the subscription-renewal-date extension.
4///
5/// [extendReasonCode](https://developer.apple.com/documentation/appstoreserverapi/extendreasoncode)
6#[derive(Debug, Clone, Deserialize, Serialize, Hash, PartialEq, Eq)]
7#[serde(from = "i64", into = "i64")]
8pub enum ExtendReasonCode {
9    Undeclared,
10    CustomerSatisfaction,
11    Other,
12    ServiceIssueOrOutage,
13
14    /// A value the App Store sent that this version of the
15    /// library does not support, preserved as received.
16    NotSupported(i64),
17}
18
19impl From<i64> for ExtendReasonCode {
20    fn from(value: i64) -> Self {
21        match value {
22            0 => ExtendReasonCode::Undeclared,
23            1 => ExtendReasonCode::CustomerSatisfaction,
24            2 => ExtendReasonCode::Other,
25            3 => ExtendReasonCode::ServiceIssueOrOutage,
26            other => ExtendReasonCode::NotSupported(other),
27        }
28    }
29}
30
31impl From<ExtendReasonCode> for i64 {
32    fn from(value: ExtendReasonCode) -> Self {
33        match value {
34            ExtendReasonCode::Undeclared => 0,
35            ExtendReasonCode::CustomerSatisfaction => 1,
36            ExtendReasonCode::Other => 2,
37            ExtendReasonCode::ServiceIssueOrOutage => 3,
38            ExtendReasonCode::NotSupported(other) => other,
39        }
40    }
41}