paystack/models/subaccount_models.rs
1//! Subaccounts
2//! ==============
3//! This file contains the models for working with the subaccounts endpoint.
4
5use super::Currency;
6use crate::utils::bool_from_int_or_bool;
7use derive_builder::Builder;
8use serde::{Deserialize, Serialize};
9
10/// This struct is used to create the body for creating a subaccount on your integration.
11/// Use the `SubaccountRequestBuilder` to create this object.
12#[derive(Serialize, Debug, Builder, Default)]
13pub struct CreateSubaccountRequest {
14 /// Name of business for subaccount
15 #[builder(setter(strip_option), default)]
16 #[serde(skip_serializing_if = "Option::is_none")]
17 business_name: Option<String>,
18 /// Bank Code for the bank.
19 /// You can get the list of Bank Codes by calling the List Banks endpoint.
20 #[builder(setter(strip_option), default)]
21 #[serde(skip_serializing_if = "Option::is_none")]
22 settlement_bank: Option<String>,
23 /// Bank Account Number
24 #[builder(setter(strip_option), default)]
25 #[serde(skip_serializing_if = "Option::is_none")]
26 account_number: Option<String>,
27 /// The default percentage charged when receiving on behalf of this subaccount
28 #[builder(setter(strip_option), default)]
29 #[serde(skip_serializing_if = "Option::is_none")]
30 percentage_charge: Option<f32>,
31 /// A description for this subaccount
32 #[builder(setter(strip_option), default)]
33 #[serde(skip_serializing_if = "Option::is_none")]
34 description: Option<String>,
35 /// A contact email for the subaccount
36 #[builder(setter(strip_option), default)]
37 #[serde(skip_serializing_if = "Option::is_none")]
38 primary_contact_email: Option<String>,
39 /// A name for the contact person for this subaccount
40 #[builder(setter(strip_option), default)]
41 #[serde(skip_serializing_if = "Option::is_none")]
42 primary_contact_name: Option<String>,
43 /// A phone number to call for this subaccount
44 #[builder(setter(strip_option), default)]
45 #[serde(skip_serializing_if = "Option::is_none")]
46 primary_contact_phone: Option<String>,
47 /// Stringified JSON object.
48 /// Add a custom_fields attribute which has an array of objects if you would like the fields to be
49 /// added to your transaction when displayed on the dashboard.
50 /// Sample: {"custom_fields":[{"display_name":"Cart ID","variable_name": "cart_id","value": "8393"}]}
51 #[builder(setter(strip_option), default)]
52 #[serde(skip_serializing_if = "Option::is_none")]
53 metadata: Option<String>,
54}
55
56/// This struct represents the subaccount.
57/// It can be used as the payload for the API end points that require a subaccount as a payload.
58/// It is also possible to extract a single field from this struct to use as well.
59/// The Struct is constructed using the `SubaccountBodyBuilder`
60#[derive(Serialize, Debug, Clone, Builder, Default)]
61pub struct SubaccountBody {
62 /// This is the subaccount code
63 pub subaccount: String,
64 /// This is the transaction share for the subaccount
65 pub share: f32,
66}
67
68/// Represents the data of th Subaccounts
69#[derive(Debug, Deserialize, Serialize, Default)]
70pub struct SubaccountData {
71 /// Sub account data
72 pub subaccount: SubaccountsResponseData,
73 /// Share of split assigned to this sub
74 pub share: u32,
75}
76
77/// Data of the list Subaccount response
78#[derive(Debug, Deserialize, Serialize, Default)]
79pub struct SubaccountsResponseData {
80 /// Integration ID of subaccount.
81 pub integration: Option<u32>,
82 /// Subaccount domain.
83 pub domain: Option<String>,
84 /// The code of the subaccount.
85 pub subaccount_code: String,
86 /// The name of the business associated with the subaccount.
87 pub business_name: String,
88 /// The description of the business associated with the subaccount.
89 pub description: Option<String>,
90 /// The name of the primary contact for the business, if available.
91 pub primary_contact_name: Option<String>,
92 /// The email of the primary contact for the business, if available.
93 pub primary_contact_email: Option<String>,
94 /// The phone number of the primary contact for the business, if available.
95 pub primary_contact_phone: Option<String>,
96 /// Additional metadata associated with the subaccount, if available.
97 pub metadata: Option<String>,
98 /// The percentage charge for transactions associated with the subaccount.
99 pub percentage_charge: Option<f32>,
100 /// Verification status of subaccount.
101 pub is_verified: Option<bool>,
102 /// The name of the settlement bank for the subaccount.
103 pub settlement_bank: String,
104 /// The id of the settlement bank for the subaccount.
105 pub bank_id: Option<u32>,
106 /// The account number of the subaccount.
107 pub account_number: String,
108 /// Currency of the subaccount
109 pub currency: Option<Currency>,
110 /// If the account is active or not, should be 1 for active and 0 for inactive
111 #[serde(default, deserialize_with = "bool_from_int_or_bool")]
112 pub active: Option<bool>,
113 /// Settlement schedule of subaccount.
114 pub settlement_schedule: Option<String>,
115 /// The ID of the subaccount.
116 pub id: u32,
117 /// Creation time of subaccount.
118 #[serde(rename = "createdAt")]
119 pub created_at: Option<String>,
120 /// Last update time of subaccount.
121 #[serde(rename = "updatedAt")]
122 pub updated_at: Option<String>,
123 pub product: Option<String>,
124 pub managed_by_integration: Option<u32>,
125}
126
127/// This struct is used to create the body for deleting a subaccount on your integration.
128#[derive(Debug, Deserialize, Serialize, Builder, Default)]
129pub struct DeleteSubAccountBody {
130 /// This is the subaccount code
131 pub subaccount: String,
132}