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