Skip to content

Commit a9620b8

Browse files
committed
feat: handle Prelude's Blocked: inablid_phone_number variant and defualt when blocked reason is unknown
1 parent e6fb13e commit a9620b8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sms_verification/prelude_api.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,23 @@ pub enum PreludeBlockedReason {
149149
InBlockList,
150150
/// The phone number is not a valid line number (e.g. landline).
151151
InvalidPhoneLine,
152+
/// The phone number is not a valid phone number (e.g. unallocated range).
153+
InvalidPhoneNumber,
152154
/// The signature of the SDK signals is invalid.
153155
InvalidSignature,
154156
/// The phone number has made too many verification attempts.
155157
RepeatedAttempts,
156158
/// The verification attempt was deemed suspicious by the anti-fraud system.
157159
Suspicious,
158-
/// Prelude API returned Blocked status without a reason.
160+
/// Prelude API returned a blocked reason we don't recognise.
161+
#[serde(other)]
159162
Unknown,
160163
}
161164

165+
fn default_blocked_reason() -> PreludeBlockedReason {
166+
PreludeBlockedReason::Unknown
167+
}
168+
162169
#[derive(Serialize, Deserialize, Debug)]
163170
#[serde(tag = "status", rename_all = "lowercase")]
164171
pub enum PreludeCreateVerificationResponse {
@@ -170,6 +177,7 @@ pub enum PreludeCreateVerificationResponse {
170177
},
171178
Blocked {
172179
id: String,
180+
#[serde(default = "default_blocked_reason")]
173181
reason: PreludeBlockedReason,
174182
},
175183
}

0 commit comments

Comments
 (0)