use serde_derive::{Deserialize, Serialize};
use crate::ids::PersonId;
use crate::params::{Expandable, Metadata, Object, Timestamp};
use crate::resources::{Address, Dob, File};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Person {
pub id: PersonId,
#[serde(skip_serializing_if = "Option::is_none")]
pub account: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address_kana: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub address_kanji: Option<Address>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created: Option<Timestamp>,
#[serde(default)]
pub deleted: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub dob: Option<Dob>,
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub first_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub first_name_kana: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub first_name_kanji: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub gender: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub id_number_provided: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name_kana: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub last_name_kanji: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub maiden_name: Option<String>,
#[serde(default)]
pub metadata: Metadata,
#[serde(skip_serializing_if = "Option::is_none")]
pub nationality: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub phone: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub political_exposure: Option<PersonPoliticalExposure>,
#[serde(skip_serializing_if = "Option::is_none")]
pub relationship: Option<PersonRelationship>,
#[serde(skip_serializing_if = "Option::is_none")]
pub requirements: Option<PersonRequirements>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ssn_last_4_provided: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub verification: Option<PersonVerification>,
}
impl Object for Person {
type Id = PersonId;
fn id(&self) -> Self::Id {
self.id.clone()
}
fn object(&self) -> &'static str {
"person"
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PersonVerification {
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_document: Option<PersonVerificationDocument>,
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub details_code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub document: Option<PersonVerificationDocument>,
pub status: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PersonVerificationDocument {
#[serde(skip_serializing_if = "Option::is_none")]
pub back: Option<Expandable<File>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub details_code: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub front: Option<Expandable<File>>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PersonRelationship {
#[serde(skip_serializing_if = "Option::is_none")]
pub director: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub executive: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub percent_ownership: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub representative: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PersonRequirements {
pub currently_due: Vec<String>,
pub errors: Vec<AccountRequirementsError>,
pub eventually_due: Vec<String>,
pub past_due: Vec<String>,
pub pending_verification: Vec<String>,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct AccountRequirementsError {
pub code: AccountRequirementsErrorCode,
pub reason: String,
pub requirement: String,
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum AccountRequirementsErrorCode {
InvalidAddressCityStatePostalCode,
InvalidStreetAddress,
InvalidValueOther,
VerificationDocumentAddressMismatch,
VerificationDocumentAddressMissing,
VerificationDocumentCorrupt,
VerificationDocumentCountryNotSupported,
VerificationDocumentDobMismatch,
VerificationDocumentDuplicateType,
VerificationDocumentExpired,
VerificationDocumentFailedCopy,
VerificationDocumentFailedGreyscale,
VerificationDocumentFailedOther,
VerificationDocumentFailedTestMode,
VerificationDocumentFraudulent,
VerificationDocumentIdNumberMismatch,
VerificationDocumentIdNumberMissing,
VerificationDocumentIncomplete,
VerificationDocumentInvalid,
VerificationDocumentIssueOrExpiryDateMissing,
VerificationDocumentManipulated,
VerificationDocumentMissingBack,
VerificationDocumentMissingFront,
VerificationDocumentNameMismatch,
VerificationDocumentNameMissing,
VerificationDocumentNationalityMismatch,
VerificationDocumentNotReadable,
VerificationDocumentNotSigned,
VerificationDocumentNotUploaded,
VerificationDocumentPhotoMismatch,
VerificationDocumentTooLarge,
VerificationDocumentTypeNotSupported,
VerificationFailedAddressMatch,
VerificationFailedBusinessIecNumber,
VerificationFailedDocumentMatch,
VerificationFailedIdNumberMatch,
VerificationFailedKeyedIdentity,
VerificationFailedKeyedMatch,
VerificationFailedNameMatch,
VerificationFailedOther,
VerificationFailedTaxIdMatch,
VerificationFailedTaxIdNotIssued,
}
impl AccountRequirementsErrorCode {
pub fn as_str(self) -> &'static str {
match self {
AccountRequirementsErrorCode::InvalidAddressCityStatePostalCode => {
"invalid_address_city_state_postal_code"
}
AccountRequirementsErrorCode::InvalidStreetAddress => "invalid_street_address",
AccountRequirementsErrorCode::InvalidValueOther => "invalid_value_other",
AccountRequirementsErrorCode::VerificationDocumentAddressMismatch => {
"verification_document_address_mismatch"
}
AccountRequirementsErrorCode::VerificationDocumentAddressMissing => {
"verification_document_address_missing"
}
AccountRequirementsErrorCode::VerificationDocumentCorrupt => {
"verification_document_corrupt"
}
AccountRequirementsErrorCode::VerificationDocumentCountryNotSupported => {
"verification_document_country_not_supported"
}
AccountRequirementsErrorCode::VerificationDocumentDobMismatch => {
"verification_document_dob_mismatch"
}
AccountRequirementsErrorCode::VerificationDocumentDuplicateType => {
"verification_document_duplicate_type"
}
AccountRequirementsErrorCode::VerificationDocumentExpired => {
"verification_document_expired"
}
AccountRequirementsErrorCode::VerificationDocumentFailedCopy => {
"verification_document_failed_copy"
}
AccountRequirementsErrorCode::VerificationDocumentFailedGreyscale => {
"verification_document_failed_greyscale"
}
AccountRequirementsErrorCode::VerificationDocumentFailedOther => {
"verification_document_failed_other"
}
AccountRequirementsErrorCode::VerificationDocumentFailedTestMode => {
"verification_document_failed_test_mode"
}
AccountRequirementsErrorCode::VerificationDocumentFraudulent => {
"verification_document_fraudulent"
}
AccountRequirementsErrorCode::VerificationDocumentIdNumberMismatch => {
"verification_document_id_number_mismatch"
}
AccountRequirementsErrorCode::VerificationDocumentIdNumberMissing => {
"verification_document_id_number_missing"
}
AccountRequirementsErrorCode::VerificationDocumentIncomplete => {
"verification_document_incomplete"
}
AccountRequirementsErrorCode::VerificationDocumentInvalid => {
"verification_document_invalid"
}
AccountRequirementsErrorCode::VerificationDocumentIssueOrExpiryDateMissing => {
"verification_document_issue_or_expiry_date_missing"
}
AccountRequirementsErrorCode::VerificationDocumentManipulated => {
"verification_document_manipulated"
}
AccountRequirementsErrorCode::VerificationDocumentMissingBack => {
"verification_document_missing_back"
}
AccountRequirementsErrorCode::VerificationDocumentMissingFront => {
"verification_document_missing_front"
}
AccountRequirementsErrorCode::VerificationDocumentNameMismatch => {
"verification_document_name_mismatch"
}
AccountRequirementsErrorCode::VerificationDocumentNameMissing => {
"verification_document_name_missing"
}
AccountRequirementsErrorCode::VerificationDocumentNationalityMismatch => {
"verification_document_nationality_mismatch"
}
AccountRequirementsErrorCode::VerificationDocumentNotReadable => {
"verification_document_not_readable"
}
AccountRequirementsErrorCode::VerificationDocumentNotSigned => {
"verification_document_not_signed"
}
AccountRequirementsErrorCode::VerificationDocumentNotUploaded => {
"verification_document_not_uploaded"
}
AccountRequirementsErrorCode::VerificationDocumentPhotoMismatch => {
"verification_document_photo_mismatch"
}
AccountRequirementsErrorCode::VerificationDocumentTooLarge => {
"verification_document_too_large"
}
AccountRequirementsErrorCode::VerificationDocumentTypeNotSupported => {
"verification_document_type_not_supported"
}
AccountRequirementsErrorCode::VerificationFailedAddressMatch => {
"verification_failed_address_match"
}
AccountRequirementsErrorCode::VerificationFailedBusinessIecNumber => {
"verification_failed_business_iec_number"
}
AccountRequirementsErrorCode::VerificationFailedDocumentMatch => {
"verification_failed_document_match"
}
AccountRequirementsErrorCode::VerificationFailedIdNumberMatch => {
"verification_failed_id_number_match"
}
AccountRequirementsErrorCode::VerificationFailedKeyedIdentity => {
"verification_failed_keyed_identity"
}
AccountRequirementsErrorCode::VerificationFailedKeyedMatch => {
"verification_failed_keyed_match"
}
AccountRequirementsErrorCode::VerificationFailedNameMatch => {
"verification_failed_name_match"
}
AccountRequirementsErrorCode::VerificationFailedOther => "verification_failed_other",
AccountRequirementsErrorCode::VerificationFailedTaxIdMatch => {
"verification_failed_tax_id_match"
}
AccountRequirementsErrorCode::VerificationFailedTaxIdNotIssued => {
"verification_failed_tax_id_not_issued"
}
}
}
}
impl AsRef<str> for AccountRequirementsErrorCode {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for AccountRequirementsErrorCode {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum PersonPoliticalExposure {
Existing,
None,
}
impl PersonPoliticalExposure {
pub fn as_str(self) -> &'static str {
match self {
PersonPoliticalExposure::Existing => "existing",
PersonPoliticalExposure::None => "none",
}
}
}
impl AsRef<str> for PersonPoliticalExposure {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for PersonPoliticalExposure {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}