paystack/models/subaccounts.rs
1//! Subaccounts
2//! ==============
3//! This file contains the models for working with the subaccounts endpoint.
4
5use crate::MetaData;
6use derive_builder::Builder;
7use serde::{Deserialize, Serialize};
8
9/// This struct is used to create the body for creating a subaccount on your integration.
10#[derive(Serialize, Debug, Builder, Default)]
11pub struct CreateSubaccountBody {
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(default = "None")]
25 primary_contact_email: Option<String>,
26 /// A name for the contact person for this subaccount
27 #[builder(default = "None")]
28 primary_contact_name: Option<String>,
29 /// A phone number to call for this subaccount
30 #[builder(default = "None")]
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(default = "None")]
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 `SubaccountBuilder`
44#[derive(Serialize, Debug, Clone, Builder)]
45pub struct SubaccountBody {
46 /// This is the sub account 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)]
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/// Response from List Subaccount route
62#[derive(Debug, Deserialize, Serialize)]
63pub struct ListSubaccountsResponse {
64 /// This lets you know if your request was successful or not.
65 pub status: bool,
66 /// This is a summary of the response and its status.
67 pub message: String,
68 /// This contain the results of your request.
69 pub data: Vec<SubaccountsResponseData>,
70 /// The meta key is used to provide context for the contents of the data key.
71 pub meta: MetaData,
72}
73
74/// Data of the list Subaccount response
75#[derive(Debug, Deserialize, Serialize)]
76pub struct SubaccountsResponseData {
77 /// Integration Id of subaccount.
78 pub integration: Option<u32>,
79 /// Subaccount domain.
80 pub domain: Option<String>,
81 /// The code of the subaccount.
82 pub subaccount_code: String,
83 /// The name of the business associated with the subaccount.
84 pub business_name: String,
85 /// The description of the business associated with the subaccount.
86 pub description: Option<String>,
87 /// The name of the primary contact for the business, if available.
88 pub primary_contact_name: Option<String>,
89 /// The email of the primary contact for the business, if available.
90 pub primary_contact_email: Option<String>,
91 /// The phone number of the primary contact for the business, if available.
92 pub primary_contact_phone: Option<String>,
93 /// Additional metadata associated with the subaccount, if available.
94 pub metadata: Option<String>,
95 /// The percentage charge for transactions associated with the subaccount.
96 pub percentage_charge: Option<f32>,
97 /// Verification status of subaccount.
98 pub is_verified: Option<bool>,
99 /// The name of the settlement bank for the subaccount.
100 pub settlement_bank: String,
101 /// The account number of the subaccount.
102 pub account_number: String,
103 /// Settlement schedule of subaccount.
104 pub settlement_schedule: Option<String>,
105 /// The ID of the subaccount.
106 pub id: u32,
107 /// Creation time of subaccount.
108 #[serde(rename = "createdAt")]
109 pub created_at: Option<String>,
110 /// Last update time of subaccount.
111 #[serde(rename = "updatedAt")]
112 pub updated_at: Option<String>,
113}
114
115/// Represents the JSON response for subaccount creation.
116#[derive(Debug, Deserialize, Serialize)]
117pub struct CreateSubaccountResponse {
118 /// The status of the JSON response.
119 pub status: bool,
120 /// The message associated with the JSON response
121 pub message: String,
122 /// Subaccount response data
123 pub data: SubaccountsResponseData,
124}
125
126/// Represents the JSON response for fetch subaccount.
127#[derive(Debug, Deserialize, Serialize)]
128pub struct FetchSubaccountResponse {
129 /// The status of the JSON response.
130 pub status: bool,
131 /// The message associated with the JSON response.
132 pub message: String,
133 /// Fetch Subaccount response data.
134 pub data: SubaccountsResponseData,
135}
136
137/// This struct is used to create the body for deleting a subaccount on your integration.
138#[derive(Debug, Deserialize, Serialize)]
139pub struct DeleteSubAccountBody {
140 /// This is the sub account code
141 pub subaccount: String,
142}