use crate::ids::{IdentityVerificationSessionId};
use crate::params::{Expandable, Metadata, Object, Timestamp};
use crate::resources::{Address, IdentityVerificationReport};
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct IdentityVerificationSession {
pub id: IdentityVerificationSessionId,
pub client_secret: Option<String>,
pub created: Timestamp,
pub last_error: Option<GelatoSessionLastError>,
pub last_verification_report: Option<Expandable<IdentityVerificationReport>>,
pub livemode: bool,
pub metadata: Metadata,
pub options: Option<GelatoVerificationSessionOptions>,
pub redaction: Option<VerificationSessionRedaction>,
pub status: IdentityVerificationSessionStatus,
#[serde(rename = "type")]
pub type_: Option<IdentityVerificationSessionType>,
pub url: Option<String>,
pub verified_outputs: Option<GelatoVerifiedOutputs>,
}
impl Object for IdentityVerificationSession {
type Id = IdentityVerificationSessionId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"identity.verification_session"
}
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GelatoSessionLastError {
pub code: Option<GelatoSessionLastErrorCode>,
pub reason: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GelatoVerificationSessionOptions {
#[serde(skip_serializing_if = "Option::is_none")]
pub document: Option<GelatoSessionDocumentOptions>,
#[serde(skip_serializing_if = "Option::is_none")]
pub id_number: Option<GelatoSessionIdNumberOptions>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GelatoSessionDocumentOptions {
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_types: Option<Vec<GelatoSessionDocumentOptionsAllowedTypes>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub require_id_number: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub require_live_capture: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub require_matching_selfie: Option<bool>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GelatoSessionIdNumberOptions {
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GelatoVerifiedOutputs {
pub address: Option<Address>,
pub dob: Option<GelatoDataVerifiedOutputsDate>,
pub first_name: Option<String>,
pub id_number: Option<String>,
pub id_number_type: Option<GelatoVerifiedOutputsIdNumberType>,
pub last_name: Option<String>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct GelatoDataVerifiedOutputsDate {
pub day: Option<i64>,
pub month: Option<i64>,
pub year: Option<i64>,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct VerificationSessionRedaction {
pub status: VerificationSessionRedactionStatus,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum GelatoSessionDocumentOptionsAllowedTypes {
DrivingLicense,
IdCard,
Passport,
}
impl GelatoSessionDocumentOptionsAllowedTypes {
pub fn as_str(self) -> &'static str {
match self {
GelatoSessionDocumentOptionsAllowedTypes::DrivingLicense => "driving_license",
GelatoSessionDocumentOptionsAllowedTypes::IdCard => "id_card",
GelatoSessionDocumentOptionsAllowedTypes::Passport => "passport",
}
}
}
impl AsRef<str> for GelatoSessionDocumentOptionsAllowedTypes {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for GelatoSessionDocumentOptionsAllowedTypes {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for GelatoSessionDocumentOptionsAllowedTypes {
fn default() -> Self {
Self::DrivingLicense
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum GelatoSessionLastErrorCode {
Abandoned,
ConsentDeclined,
CountryNotSupported,
DeviceNotSupported,
DocumentExpired,
DocumentTypeNotSupported,
DocumentUnverifiedOther,
IdNumberInsufficientDocumentData,
IdNumberMismatch,
IdNumberUnverifiedOther,
SelfieDocumentMissingPhoto,
SelfieFaceMismatch,
SelfieManipulated,
SelfieUnverifiedOther,
UnderSupportedAge,
}
impl GelatoSessionLastErrorCode {
pub fn as_str(self) -> &'static str {
match self {
GelatoSessionLastErrorCode::Abandoned => "abandoned",
GelatoSessionLastErrorCode::ConsentDeclined => "consent_declined",
GelatoSessionLastErrorCode::CountryNotSupported => "country_not_supported",
GelatoSessionLastErrorCode::DeviceNotSupported => "device_not_supported",
GelatoSessionLastErrorCode::DocumentExpired => "document_expired",
GelatoSessionLastErrorCode::DocumentTypeNotSupported => "document_type_not_supported",
GelatoSessionLastErrorCode::DocumentUnverifiedOther => "document_unverified_other",
GelatoSessionLastErrorCode::IdNumberInsufficientDocumentData => "id_number_insufficient_document_data",
GelatoSessionLastErrorCode::IdNumberMismatch => "id_number_mismatch",
GelatoSessionLastErrorCode::IdNumberUnverifiedOther => "id_number_unverified_other",
GelatoSessionLastErrorCode::SelfieDocumentMissingPhoto => "selfie_document_missing_photo",
GelatoSessionLastErrorCode::SelfieFaceMismatch => "selfie_face_mismatch",
GelatoSessionLastErrorCode::SelfieManipulated => "selfie_manipulated",
GelatoSessionLastErrorCode::SelfieUnverifiedOther => "selfie_unverified_other",
GelatoSessionLastErrorCode::UnderSupportedAge => "under_supported_age",
}
}
}
impl AsRef<str> for GelatoSessionLastErrorCode {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for GelatoSessionLastErrorCode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for GelatoSessionLastErrorCode {
fn default() -> Self {
Self::Abandoned
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum GelatoVerifiedOutputsIdNumberType {
BrCpf,
SgNric,
UsSsn,
}
impl GelatoVerifiedOutputsIdNumberType {
pub fn as_str(self) -> &'static str {
match self {
GelatoVerifiedOutputsIdNumberType::BrCpf => "br_cpf",
GelatoVerifiedOutputsIdNumberType::SgNric => "sg_nric",
GelatoVerifiedOutputsIdNumberType::UsSsn => "us_ssn",
}
}
}
impl AsRef<str> for GelatoVerifiedOutputsIdNumberType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for GelatoVerifiedOutputsIdNumberType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for GelatoVerifiedOutputsIdNumberType {
fn default() -> Self {
Self::BrCpf
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IdentityVerificationSessionStatus {
Canceled,
Processing,
RequiresInput,
Verified,
}
impl IdentityVerificationSessionStatus {
pub fn as_str(self) -> &'static str {
match self {
IdentityVerificationSessionStatus::Canceled => "canceled",
IdentityVerificationSessionStatus::Processing => "processing",
IdentityVerificationSessionStatus::RequiresInput => "requires_input",
IdentityVerificationSessionStatus::Verified => "verified",
}
}
}
impl AsRef<str> for IdentityVerificationSessionStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IdentityVerificationSessionStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IdentityVerificationSessionStatus {
fn default() -> Self {
Self::Canceled
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum IdentityVerificationSessionType {
Document,
IdNumber,
}
impl IdentityVerificationSessionType {
pub fn as_str(self) -> &'static str {
match self {
IdentityVerificationSessionType::Document => "document",
IdentityVerificationSessionType::IdNumber => "id_number",
}
}
}
impl AsRef<str> for IdentityVerificationSessionType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for IdentityVerificationSessionType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for IdentityVerificationSessionType {
fn default() -> Self {
Self::Document
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum VerificationSessionRedactionStatus {
Processing,
Redacted,
}
impl VerificationSessionRedactionStatus {
pub fn as_str(self) -> &'static str {
match self {
VerificationSessionRedactionStatus::Processing => "processing",
VerificationSessionRedactionStatus::Redacted => "redacted",
}
}
}
impl AsRef<str> for VerificationSessionRedactionStatus {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for VerificationSessionRedactionStatus {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for VerificationSessionRedactionStatus {
fn default() -> Self {
Self::Processing
}
}