etopay_sdk/types/
viviswap.rs

1use api_types::api::viviswap::payment::ViviPaymentMethodsResponse;
2use serde::{Deserialize, Serialize};
3
4/// Struct for new viviswap user
5#[derive(Debug, Serialize)]
6pub struct NewViviswapUser {
7    /// Username of new viviswap user
8    pub username: String,
9}
10
11/// Viviswap user verification step
12#[derive(Debug, Eq, PartialEq, Deserialize, Serialize, Clone)]
13pub enum ViviswapVerificationStep {
14    /// no verification step (no next verification step available)
15    Undefined,
16    /// general verification step
17    General,
18    /// personal verification step
19    Personal,
20    /// residence verification step
21    Residence,
22    /// identity verification step
23    Identity,
24    /// amla general verification step
25    Amla,
26    /// document verification step
27    Documents,
28}
29
30impl From<api_types::api::viviswap::kyc::KycStep> for ViviswapVerificationStep {
31    fn from(value: api_types::api::viviswap::kyc::KycStep) -> Self {
32        match value {
33            api_types::api::viviswap::kyc::KycStep::Undefined => Self::Undefined,
34            api_types::api::viviswap::kyc::KycStep::General => Self::General,
35            api_types::api::viviswap::kyc::KycStep::Personal => Self::Personal,
36            api_types::api::viviswap::kyc::KycStep::Identity => Self::Identity,
37            api_types::api::viviswap::kyc::KycStep::Residence => Self::Residence,
38            api_types::api::viviswap::kyc::KycStep::Amla => Self::Amla,
39            api_types::api::viviswap::kyc::KycStep::Document => Self::Documents,
40            // undefined means the there is no next verification step available, hence this makes sense
41            api_types::api::viviswap::kyc::KycStep::Completed => Self::Undefined,
42        }
43    }
44}
45
46/// Viviswap user verification status
47#[derive(Debug, Eq, PartialEq, Deserialize, Serialize, Clone)]
48pub enum ViviswapVerificationStatus {
49    /// The user is fully verified
50    Verified,
51    /// The user is not verified
52    Unverified,
53    /// The user is partially verified
54    PartiallyVerified,
55}
56
57impl From<api_types::api::viviswap::kyc::KycVerificationStatus> for ViviswapVerificationStatus {
58    fn from(value: api_types::api::viviswap::kyc::KycVerificationStatus) -> Self {
59        match value {
60            api_types::api::viviswap::kyc::KycVerificationStatus::Unverified => Self::Unverified,
61            api_types::api::viviswap::kyc::KycVerificationStatus::PartiallyVerified => Self::PartiallyVerified,
62            api_types::api::viviswap::kyc::KycVerificationStatus::Verified => Self::Verified,
63        }
64    }
65}
66
67/// Viviswap iban detail
68#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
69pub struct ViviswapAddressDetail {
70    /// the unique id of the address detail
71    pub id: String,
72    /// the address used in the detail
73    pub address: String,
74    /// the status from viviswap, whether the address is verified
75    pub is_verified: bool,
76}
77
78/// Viviswap local app state
79#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
80pub struct ViviswapState {
81    /// The verification status, either Verified, Unverified or PartiallyVerified
82    pub verification_status: ViviswapVerificationStatus,
83    /// The monthly swap limit of the user in euros
84    pub monthly_limit_eur: f32,
85    /// The next step in verification
86    pub next_verification_step: ViviswapVerificationStep,
87    /// The details of the partially verified KYC
88    pub partial_kyc_details_input: ViviswapPartiallyKycDetails,
89    /// The current IBAN as a viviswap address detail
90    pub current_iban: Option<ViviswapAddressDetail>,
91    /// The supported payment methods of viviswap
92    pub payment_methods: Option<ViviPaymentMethodsResponse>,
93}
94
95impl ViviswapState {
96    /// Creates a new viviswap state
97    pub fn new() -> ViviswapState {
98        ViviswapState {
99            verification_status: ViviswapVerificationStatus::Unverified,
100            monthly_limit_eur: 0.0,
101            next_verification_step: ViviswapVerificationStep::General,
102            partial_kyc_details_input: ViviswapPartiallyKycDetails::new(),
103            current_iban: Option::None,
104            payment_methods: Option::None,
105        }
106    }
107}
108
109impl Default for ViviswapState {
110    fn default() -> Self {
111        Self::new()
112    }
113}
114/// Viviswap kyc status
115#[derive(Debug, PartialEq, Deserialize, Serialize)]
116pub struct ViviswapKycStatus {
117    /// full name of the user
118    pub full_name: String,
119    /// the current submission step in the KYC onboarding process for the user
120    pub submission_step: ViviswapVerificationStep,
121    /// the current verified step in the KYC onboarding process for the user
122    pub verified_step: ViviswapVerificationStep,
123    /// the user verification status
124    pub verification_status: ViviswapVerificationStatus,
125    /// The monthly swap limit in euros
126    pub monthly_limit_eur: f32,
127}
128
129/// When a Viviswap detail is added, there can be different ways to handle the logic
130#[derive(Debug)]
131pub enum ViviswapDetailUpdateStrategy {
132    /// on add, delete the last one
133    Replace,
134    /// on add, just do nothing
135    Add,
136}
137
138/// The viviswap partial KYC details consisting of details for general and personal KYC steps
139#[derive(Debug, Default, Eq, PartialEq, Deserialize, Serialize, Clone)]
140pub struct ViviswapPartiallyKycDetails {
141    /// Is the user an individual
142    pub is_individual: Option<bool>,
143    /// Is the user a politically exposed person
144    pub is_pep: Option<bool>,
145    /// Is the user a US citizen
146    pub is_us_citizen: Option<bool>,
147    /// Is the regulatory disclosure confirmed by user
148    pub is_regulatory_disclosure: Option<bool>,
149    /// The country of tax residence of the user
150    pub country_of_residence: Option<String>,
151    /// The user's nationality
152    pub nationality: Option<String>,
153    /// The full name of the user as per his legal documents
154    pub full_name: Option<String>,
155    /// The date of birth of the user as per his legal documents
156    pub date_of_birth: Option<String>,
157}
158
159impl ViviswapPartiallyKycDetails {
160    /// New function to create the viviswap partial KYC details with default None
161    pub fn new() -> ViviswapPartiallyKycDetails {
162        ViviswapPartiallyKycDetails {
163            is_individual: Option::None,
164            is_pep: Option::None,
165            is_us_citizen: Option::None,
166            is_regulatory_disclosure: Option::None,
167            country_of_residence: Option::None,
168            nationality: Option::None,
169            full_name: Option::None,
170            date_of_birth: Option::None,
171        }
172    }
173}
174
175/// Viviswap deposit details for FIAT to Crypto Swap
176#[derive(Debug, Deserialize, Serialize, Clone)]
177pub struct ViviswapDepositDetails {
178    /// The reference to be entered by the user in his SEPA bank transfer
179    pub reference: String,
180    /// The name of the beneficiary receiving the SEPA transfer
181    pub beneficiary: String,
182    /// The name of the bank of the beneficiary
183    pub name_of_bank: String,
184    /// The address of the bank of the beneficiary
185    pub address_of_bank: String,
186    /// The IBAN of the beneficiary
187    pub iban: String,
188    /// The BIC/SWIFT code for the SEPA transfer
189    pub bic: String,
190}
191
192/// Viviswap deposit contract details
193#[derive(Debug, Serialize)]
194pub struct ViviswapDeposit {
195    /// The unique UUID of the contract
196    pub contract_id: String,
197    /// The deposit address (crypto) where the swap will put the funds from fiat
198    pub deposit_address: String,
199    /// The details of the deposit (for the user)
200    pub details: ViviswapDepositDetails,
201}
202
203/// Viviswap withdrawal details for crypto to FIAT swap
204#[derive(Serialize)]
205pub struct ViviswapWithdrawalDetails {
206    /// The reference used by viviswap for the SEPA transfer
207    pub reference: String,
208    /// The id of the unique wallet internal to viviswap
209    pub wallet_id: String,
210    /// The crypto address of viviswap where the crypto swap is to be sent
211    pub crypto_address: String,
212}
213
214/// The viviswap withdrawal contract information
215#[derive(Serialize)]
216pub struct ViviswapWithdrawal {
217    /// The unique UUID to track the withdrawal contract
218    pub contract_id: String,
219    /// The deposit address, in this case the IBAN of the user, where fiat will be deposited.
220    pub deposit_address: String,
221    /// The details of the withdrawal
222    pub details: ViviswapWithdrawalDetails,
223}