paystack/models/
transaction_split_models.rs

1//! Transaction Split Models
2//! ========================
3//! This file contains the models for working with the transaction splits endpoint.
4
5use crate::{BearerType, Currency, Domain, 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: Domain,
44    /// The split code of the percentage split.
45    pub split_code: String,
46    /// Indicates whether the percentage split is active or not.
47    #[serde(default)]
48    pub active: Option<bool>,
49    /// The bearer type of the percentage split.
50    pub bearer_type: String,
51    /// The subaccount ID of the bearer associated with the percentage split.
52    pub bearer_subaccount: u32,
53    /// The creation timestamp of the percentage split.
54    #[serde(rename = "createdAt")]
55    pub created_at: Option<String>,
56    /// The last update timestamp of the percentage split.
57    #[serde(rename = "updatedAt")]
58    pub updated_at: Option<String>,
59    pub is_dynamic: Option<bool>,
60    /// The list of subaccounts involved in the percentage split.
61    pub subaccounts: Vec<SubaccountData>,
62    /// The total count of subaccounts in the percentage split.
63    pub total_subaccounts: u32,
64}
65
66/// This struct is used to update a transaction split details on your integration.
67/// The struct is constructed using the `UpdateTransactionSplitRequestBuilder`
68#[derive(Serialize, Debug, Builder, Default)]
69pub struct UpdateTransactionSplitRequest {
70    /// Name of the transaction split
71    name: String,
72    /// True or False
73    active: bool,
74    /// Any of subaccount
75    #[builder(setter(strip_option), default)]
76    bearer_type: Option<BearerType>,
77    /// Subaccount code of a subaccount in the split group. This should be specified only if the `bearer_type is subaccount
78    #[builder(setter(strip_option), default)]
79    bearer_subaccount: Option<SubaccountBody>,
80}