paystack/models/
transaction_split.rs

1//! Transaction Split Models
2//! ========================
3//! This file contains the models for working with the transaction splits endpoint.
4
5use crate::{BearerType, Currency, SplitType, SubaccountBody, SubaccountData};
6use derive_builder::Builder;
7use serde::{Deserialize, Serialize};
8
9/// This struct is used to create a split payment on your integration.
10/// The struct is constructed using the `TransactionSplitRequestBuilder`
11#[derive(Serialize, Debug, Default, Builder)]
12pub struct TransactionSplitRequest {
13    /// Name of the transaction split
14    name: String,
15    /// The type of transaction split you want to create
16    #[serde(rename = "type")]
17    split_type: SplitType,
18    /// Any of the supported currency
19    currency: Currency,
20    /// A list of object containing subaccount code and number of shares: `[{subaccount: ‘ACT_xxxxxxxxxx’, share: xxx},{...}]`
21    subaccounts: Vec<SubaccountBody>,
22    /// Any of subaccount
23    bearer_type: BearerType,
24    /// Subaccount code
25    bearer_subaccount: String,
26}
27
28/// Represents the percentage split data received in the JSON response.
29#[derive(Debug, Deserialize, Serialize, Default)]
30pub struct TransactionSplitResponseData {
31    /// The ID of the percentage split.
32    pub id: u32,
33    /// The name of the percentage split.
34    pub name: String,
35    /// The type of the percentage split.
36    #[serde(rename = "type")]
37    pub split_type: String,
38    /// The currency used for the percentage split.
39    pub currency: String,
40    /// The integration associated with the percentage split.
41    pub integration: u32,
42    /// The domain associated with the percentage split.
43    pub domain: String,
44    /// The split code of the percentage split.
45    pub split_code: String,
46    /// Indicates whether the percentage split is active or not.
47    pub active: Option<bool>,
48    /// The bearer type of the percentage split.
49    pub bearer_type: String,
50    /// The subaccount ID of the bearer associated with the percentage split.
51    pub bearer_subaccount: u32,
52    /// The creation timestamp of the percentage split.
53    #[serde(rename = "createdAt")]
54    pub created_at: Option<String>,
55    /// The last update timestamp of the percentage split.
56    #[serde(rename = "updatedAt")]
57    pub updated_at: Option<String>,
58    pub is_dynamic: Option<bool>,
59    /// The list of subaccounts involved in the percentage split.
60    pub subaccounts: Vec<SubaccountData>,
61    /// The total count of subaccounts in the percentage split.
62    pub total_subaccounts: u32,
63}
64
65/// This struct is used to update a transaction split details on your integration.
66/// The struct is constructed using the `UpdateTransactionSplitRequestBuilder`
67#[derive(Serialize, Debug, Builder, Default)]
68pub struct UpdateTransactionSplitRequest {
69    /// Name of the transaction split
70    name: String,
71    /// True or False
72    active: bool,
73    /// Any of subaccount
74    #[builder(setter(strip_option), default)]
75    bearer_type: Option<BearerType>,
76    /// Subaccount code of a subaccount in the split group. This should be specified only if the `bearer_type is subaccount
77    #[builder(setter(strip_option), default)]
78    bearer_subaccount: Option<SubaccountBody>,
79}