Skip to main content

oanda_rs/models/transaction/
account_tx.rs

1//! Account-lifecycle and funding transaction subtypes.
2
3use serde::{Deserialize, Serialize};
4
5use crate::models::macros::string_enum;
6use crate::models::{
7    AccountId, AccountUnits, Currency, DateTime, DecimalNumber, RequestId, TransactionId,
8};
9
10/// A ClientConfigureTransaction represents the configuration of an Account by a
11/// client.
12#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
13#[non_exhaustive]
14pub struct ClientConfigureTransaction {
15    /// The Transaction's Identifier.
16    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
17    pub id: Option<TransactionId>,
18
19    /// The date/time when the Transaction was created.
20    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
21    pub time: Option<DateTime>,
22
23    /// The ID of the user that initiated the creation of the Transaction.
24    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
25    pub user_id: Option<i64>,
26
27    /// The ID of the Account the Transaction was created for.
28    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
29    pub account_id: Option<AccountId>,
30
31    /// The ID of the "batch" that the Transaction belongs to. Transactions in
32    /// the same batch are applied to the Account simultaneously.
33    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
34    pub batch_id: Option<TransactionId>,
35
36    /// The Request ID of the request which generated the transaction.
37    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
38    pub request_id: Option<RequestId>,
39
40    // type is pinned to "CLIENT_CONFIGURE" by the enum wrapper
41    /// The client-provided alias for the Account.
42    #[serde(rename = "alias", skip_serializing_if = "Option::is_none")]
43    pub alias: Option<String>,
44
45    /// The margin rate override for the Account.
46    #[serde(rename = "marginRate", skip_serializing_if = "Option::is_none")]
47    pub margin_rate: Option<DecimalNumber>,
48}
49
50/// A ClientConfigureRejectTransaction represents the reject of configuration of
51/// an Account by a client.
52#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
53#[non_exhaustive]
54pub struct ClientConfigureRejectTransaction {
55    /// The Transaction's Identifier.
56    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
57    pub id: Option<TransactionId>,
58
59    /// The date/time when the Transaction was created.
60    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
61    pub time: Option<DateTime>,
62
63    /// The ID of the user that initiated the creation of the Transaction.
64    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
65    pub user_id: Option<i64>,
66
67    /// The ID of the Account the Transaction was created for.
68    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
69    pub account_id: Option<AccountId>,
70
71    /// The ID of the "batch" that the Transaction belongs to. Transactions in
72    /// the same batch are applied to the Account simultaneously.
73    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
74    pub batch_id: Option<TransactionId>,
75
76    /// The Request ID of the request which generated the transaction.
77    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
78    pub request_id: Option<RequestId>,
79
80    // type is pinned to "CLIENT_CONFIGURE_REJECT" by the enum wrapper
81    /// The client-provided alias for the Account.
82    #[serde(rename = "alias", skip_serializing_if = "Option::is_none")]
83    pub alias: Option<String>,
84
85    /// The margin rate override for the Account.
86    #[serde(rename = "marginRate", skip_serializing_if = "Option::is_none")]
87    pub margin_rate: Option<DecimalNumber>,
88
89    /// The `rejectReason` field.
90    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
91    pub reject_reason: Option<TransactionRejectReason>,
92}
93
94string_enum! {
95    /// The reason that a Transaction was rejected.
96    pub enum TransactionRejectReason {
97        InternalServerError => "INTERNAL_SERVER_ERROR",
98        InstrumentPriceUnknown => "INSTRUMENT_PRICE_UNKNOWN",
99        AccountNotActive => "ACCOUNT_NOT_ACTIVE",
100        AccountLocked => "ACCOUNT_LOCKED",
101        AccountOrderCreationLocked => "ACCOUNT_ORDER_CREATION_LOCKED",
102        AccountConfigurationLocked => "ACCOUNT_CONFIGURATION_LOCKED",
103        AccountDepositLocked => "ACCOUNT_DEPOSIT_LOCKED",
104        AccountWithdrawalLocked => "ACCOUNT_WITHDRAWAL_LOCKED",
105        AccountOrderCancelLocked => "ACCOUNT_ORDER_CANCEL_LOCKED",
106        InstrumentNotTradeable => "INSTRUMENT_NOT_TRADEABLE",
107        PendingOrdersAllowedExceeded => "PENDING_ORDERS_ALLOWED_EXCEEDED",
108        OrderIdUnspecified => "ORDER_ID_UNSPECIFIED",
109        OrderDoesntExist => "ORDER_DOESNT_EXIST",
110        OrderIdentifierInconsistency => "ORDER_IDENTIFIER_INCONSISTENCY",
111        TradeIdUnspecified => "TRADE_ID_UNSPECIFIED",
112        TradeDoesntExist => "TRADE_DOESNT_EXIST",
113        TradeIdentifierInconsistency => "TRADE_IDENTIFIER_INCONSISTENCY",
114        InsufficientMargin => "INSUFFICIENT_MARGIN",
115        InstrumentMissing => "INSTRUMENT_MISSING",
116        InstrumentUnknown => "INSTRUMENT_UNKNOWN",
117        UnitsMissing => "UNITS_MISSING",
118        UnitsInvalid => "UNITS_INVALID",
119        UnitsPrecisionExceeded => "UNITS_PRECISION_EXCEEDED",
120        UnitsLimitExceeded => "UNITS_LIMIT_EXCEEDED",
121        UnitsMimimumNotMet => "UNITS_MIMIMUM_NOT_MET",
122        PriceMissing => "PRICE_MISSING",
123        PriceInvalid => "PRICE_INVALID",
124        PricePrecisionExceeded => "PRICE_PRECISION_EXCEEDED",
125        PriceDistanceMissing => "PRICE_DISTANCE_MISSING",
126        PriceDistanceInvalid => "PRICE_DISTANCE_INVALID",
127        PriceDistancePrecisionExceeded => "PRICE_DISTANCE_PRECISION_EXCEEDED",
128        PriceDistanceMaximumExceeded => "PRICE_DISTANCE_MAXIMUM_EXCEEDED",
129        PriceDistanceMinimumNotMet => "PRICE_DISTANCE_MINIMUM_NOT_MET",
130        TimeInForceMissing => "TIME_IN_FORCE_MISSING",
131        TimeInForceInvalid => "TIME_IN_FORCE_INVALID",
132        TimeInForceGtdTimestampMissing => "TIME_IN_FORCE_GTD_TIMESTAMP_MISSING",
133        TimeInForceGtdTimestampInPast => "TIME_IN_FORCE_GTD_TIMESTAMP_IN_PAST",
134        PriceBoundInvalid => "PRICE_BOUND_INVALID",
135        PriceBoundPrecisionExceeded => "PRICE_BOUND_PRECISION_EXCEEDED",
136        OrdersOnFillDuplicateClientOrderIds => "ORDERS_ON_FILL_DUPLICATE_CLIENT_ORDER_IDS",
137        TradeOnFillClientExtensionsNotSupported => "TRADE_ON_FILL_CLIENT_EXTENSIONS_NOT_SUPPORTED",
138        ClientOrderIdInvalid => "CLIENT_ORDER_ID_INVALID",
139        ClientOrderIdAlreadyExists => "CLIENT_ORDER_ID_ALREADY_EXISTS",
140        ClientOrderTagInvalid => "CLIENT_ORDER_TAG_INVALID",
141        ClientOrderCommentInvalid => "CLIENT_ORDER_COMMENT_INVALID",
142        ClientTradeIdInvalid => "CLIENT_TRADE_ID_INVALID",
143        ClientTradeIdAlreadyExists => "CLIENT_TRADE_ID_ALREADY_EXISTS",
144        ClientTradeTagInvalid => "CLIENT_TRADE_TAG_INVALID",
145        ClientTradeCommentInvalid => "CLIENT_TRADE_COMMENT_INVALID",
146        OrderFillPositionActionMissing => "ORDER_FILL_POSITION_ACTION_MISSING",
147        OrderFillPositionActionInvalid => "ORDER_FILL_POSITION_ACTION_INVALID",
148        TriggerConditionMissing => "TRIGGER_CONDITION_MISSING",
149        TriggerConditionInvalid => "TRIGGER_CONDITION_INVALID",
150        OrderPartialFillOptionMissing => "ORDER_PARTIAL_FILL_OPTION_MISSING",
151        OrderPartialFillOptionInvalid => "ORDER_PARTIAL_FILL_OPTION_INVALID",
152        InvalidReissueImmediatePartialFill => "INVALID_REISSUE_IMMEDIATE_PARTIAL_FILL",
153        TakeProfitOrderAlreadyExists => "TAKE_PROFIT_ORDER_ALREADY_EXISTS",
154        TakeProfitOnFillPriceMissing => "TAKE_PROFIT_ON_FILL_PRICE_MISSING",
155        TakeProfitOnFillPriceInvalid => "TAKE_PROFIT_ON_FILL_PRICE_INVALID",
156        TakeProfitOnFillPricePrecisionExceeded => "TAKE_PROFIT_ON_FILL_PRICE_PRECISION_EXCEEDED",
157        TakeProfitOnFillTimeInForceMissing => "TAKE_PROFIT_ON_FILL_TIME_IN_FORCE_MISSING",
158        TakeProfitOnFillTimeInForceInvalid => "TAKE_PROFIT_ON_FILL_TIME_IN_FORCE_INVALID",
159        TakeProfitOnFillGtdTimestampMissing => "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_MISSING",
160        TakeProfitOnFillGtdTimestampInPast => "TAKE_PROFIT_ON_FILL_GTD_TIMESTAMP_IN_PAST",
161        TakeProfitOnFillClientOrderIdInvalid => "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_ID_INVALID",
162        TakeProfitOnFillClientOrderTagInvalid => "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_TAG_INVALID",
163        TakeProfitOnFillClientOrderCommentInvalid => "TAKE_PROFIT_ON_FILL_CLIENT_ORDER_COMMENT_INVALID",
164        TakeProfitOnFillTriggerConditionMissing => "TAKE_PROFIT_ON_FILL_TRIGGER_CONDITION_MISSING",
165        TakeProfitOnFillTriggerConditionInvalid => "TAKE_PROFIT_ON_FILL_TRIGGER_CONDITION_INVALID",
166        StopLossOrderAlreadyExists => "STOP_LOSS_ORDER_ALREADY_EXISTS",
167        StopLossOrderGuaranteedRequired => "STOP_LOSS_ORDER_GUARANTEED_REQUIRED",
168        StopLossOrderGuaranteedPriceWithinSpread => "STOP_LOSS_ORDER_GUARANTEED_PRICE_WITHIN_SPREAD",
169        StopLossOrderGuaranteedNotAllowed => "STOP_LOSS_ORDER_GUARANTEED_NOT_ALLOWED",
170        StopLossOrderGuaranteedHaltedCreateViolation => "STOP_LOSS_ORDER_GUARANTEED_HALTED_CREATE_VIOLATION",
171        StopLossOrderGuaranteedHaltedTightenViolation => "STOP_LOSS_ORDER_GUARANTEED_HALTED_TIGHTEN_VIOLATION",
172        StopLossOrderGuaranteedHedgingNotAllowed => "STOP_LOSS_ORDER_GUARANTEED_HEDGING_NOT_ALLOWED",
173        StopLossOrderGuaranteedMinimumDistanceNotMet => "STOP_LOSS_ORDER_GUARANTEED_MINIMUM_DISTANCE_NOT_MET",
174        StopLossOrderNotCancelable => "STOP_LOSS_ORDER_NOT_CANCELABLE",
175        StopLossOrderNotReplaceable => "STOP_LOSS_ORDER_NOT_REPLACEABLE",
176        StopLossOrderGuaranteedLevelRestrictionExceeded => "STOP_LOSS_ORDER_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED",
177        StopLossOrderPriceAndDistanceBothSpecified => "STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_SPECIFIED",
178        StopLossOrderPriceAndDistanceBothMissing => "STOP_LOSS_ORDER_PRICE_AND_DISTANCE_BOTH_MISSING",
179        StopLossOnFillRequiredForPendingOrder => "STOP_LOSS_ON_FILL_REQUIRED_FOR_PENDING_ORDER",
180        StopLossOnFillGuaranteedNotAllowed => "STOP_LOSS_ON_FILL_GUARANTEED_NOT_ALLOWED",
181        StopLossOnFillGuaranteedRequired => "STOP_LOSS_ON_FILL_GUARANTEED_REQUIRED",
182        StopLossOnFillPriceMissing => "STOP_LOSS_ON_FILL_PRICE_MISSING",
183        StopLossOnFillPriceInvalid => "STOP_LOSS_ON_FILL_PRICE_INVALID",
184        StopLossOnFillPricePrecisionExceeded => "STOP_LOSS_ON_FILL_PRICE_PRECISION_EXCEEDED",
185        StopLossOnFillGuaranteedMinimumDistanceNotMet => "STOP_LOSS_ON_FILL_GUARANTEED_MINIMUM_DISTANCE_NOT_MET",
186        StopLossOnFillGuaranteedLevelRestrictionExceeded => "STOP_LOSS_ON_FILL_GUARANTEED_LEVEL_RESTRICTION_EXCEEDED",
187        StopLossOnFillDistanceInvalid => "STOP_LOSS_ON_FILL_DISTANCE_INVALID",
188        StopLossOnFillPriceDistanceMaximumExceeded => "STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED",
189        StopLossOnFillDistancePrecisionExceeded => "STOP_LOSS_ON_FILL_DISTANCE_PRECISION_EXCEEDED",
190        StopLossOnFillPriceAndDistanceBothSpecified => "STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_SPECIFIED",
191        StopLossOnFillPriceAndDistanceBothMissing => "STOP_LOSS_ON_FILL_PRICE_AND_DISTANCE_BOTH_MISSING",
192        StopLossOnFillTimeInForceMissing => "STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING",
193        StopLossOnFillTimeInForceInvalid => "STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID",
194        StopLossOnFillGtdTimestampMissing => "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING",
195        StopLossOnFillGtdTimestampInPast => "STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST",
196        StopLossOnFillClientOrderIdInvalid => "STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID",
197        StopLossOnFillClientOrderTagInvalid => "STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID",
198        StopLossOnFillClientOrderCommentInvalid => "STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID",
199        StopLossOnFillTriggerConditionMissing => "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING",
200        StopLossOnFillTriggerConditionInvalid => "STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID",
201        TrailingStopLossOrderAlreadyExists => "TRAILING_STOP_LOSS_ORDER_ALREADY_EXISTS",
202        TrailingStopLossOnFillPriceDistanceMissing => "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MISSING",
203        TrailingStopLossOnFillPriceDistanceInvalid => "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_INVALID",
204        TrailingStopLossOnFillPriceDistancePrecisionExceeded => "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_PRECISION_EXCEEDED",
205        TrailingStopLossOnFillPriceDistanceMaximumExceeded => "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MAXIMUM_EXCEEDED",
206        TrailingStopLossOnFillPriceDistanceMinimumNotMet => "TRAILING_STOP_LOSS_ON_FILL_PRICE_DISTANCE_MINIMUM_NOT_MET",
207        TrailingStopLossOnFillTimeInForceMissing => "TRAILING_STOP_LOSS_ON_FILL_TIME_IN_FORCE_MISSING",
208        TrailingStopLossOnFillTimeInForceInvalid => "TRAILING_STOP_LOSS_ON_FILL_TIME_IN_FORCE_INVALID",
209        TrailingStopLossOnFillGtdTimestampMissing => "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_MISSING",
210        TrailingStopLossOnFillGtdTimestampInPast => "TRAILING_STOP_LOSS_ON_FILL_GTD_TIMESTAMP_IN_PAST",
211        TrailingStopLossOnFillClientOrderIdInvalid => "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_ID_INVALID",
212        TrailingStopLossOnFillClientOrderTagInvalid => "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_TAG_INVALID",
213        TrailingStopLossOnFillClientOrderCommentInvalid => "TRAILING_STOP_LOSS_ON_FILL_CLIENT_ORDER_COMMENT_INVALID",
214        TrailingStopLossOrdersNotSupported => "TRAILING_STOP_LOSS_ORDERS_NOT_SUPPORTED",
215        TrailingStopLossOnFillTriggerConditionMissing => "TRAILING_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_MISSING",
216        TrailingStopLossOnFillTriggerConditionInvalid => "TRAILING_STOP_LOSS_ON_FILL_TRIGGER_CONDITION_INVALID",
217        CloseTradeTypeMissing => "CLOSE_TRADE_TYPE_MISSING",
218        CloseTradePartialUnitsMissing => "CLOSE_TRADE_PARTIAL_UNITS_MISSING",
219        CloseTradeUnitsExceedTradeSize => "CLOSE_TRADE_UNITS_EXCEED_TRADE_SIZE",
220        CloseoutPositionDoesntExist => "CLOSEOUT_POSITION_DOESNT_EXIST",
221        CloseoutPositionIncompleteSpecification => "CLOSEOUT_POSITION_INCOMPLETE_SPECIFICATION",
222        CloseoutPositionUnitsExceedPositionSize => "CLOSEOUT_POSITION_UNITS_EXCEED_POSITION_SIZE",
223        CloseoutPositionReject => "CLOSEOUT_POSITION_REJECT",
224        CloseoutPositionPartialUnitsMissing => "CLOSEOUT_POSITION_PARTIAL_UNITS_MISSING",
225        MarkupGroupIdInvalid => "MARKUP_GROUP_ID_INVALID",
226        PositionAggregationModeInvalid => "POSITION_AGGREGATION_MODE_INVALID",
227        AdminConfigureDataMissing => "ADMIN_CONFIGURE_DATA_MISSING",
228        MarginRateInvalid => "MARGIN_RATE_INVALID",
229        MarginRateWouldTriggerCloseout => "MARGIN_RATE_WOULD_TRIGGER_CLOSEOUT",
230        AliasInvalid => "ALIAS_INVALID",
231        ClientConfigureDataMissing => "CLIENT_CONFIGURE_DATA_MISSING",
232        MarginRateWouldTriggerMarginCall => "MARGIN_RATE_WOULD_TRIGGER_MARGIN_CALL",
233        AmountInvalid => "AMOUNT_INVALID",
234        InsufficientFunds => "INSUFFICIENT_FUNDS",
235        AmountMissing => "AMOUNT_MISSING",
236        FundingReasonMissing => "FUNDING_REASON_MISSING",
237        ClientExtensionsDataMissing => "CLIENT_EXTENSIONS_DATA_MISSING",
238        ReplacingOrderInvalid => "REPLACING_ORDER_INVALID",
239        ReplacingTradeIdInvalid => "REPLACING_TRADE_ID_INVALID",
240    }
241}
242
243/// A CreateTransaction represents the creation of an Account.
244#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
245#[non_exhaustive]
246pub struct CreateTransaction {
247    /// The Transaction's Identifier.
248    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
249    pub id: Option<TransactionId>,
250
251    /// The date/time when the Transaction was created.
252    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
253    pub time: Option<DateTime>,
254
255    /// The ID of the user that initiated the creation of the Transaction.
256    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
257    pub user_id: Option<i64>,
258
259    /// The ID of the Account the Transaction was created for.
260    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
261    pub account_id: Option<AccountId>,
262
263    /// The ID of the "batch" that the Transaction belongs to. Transactions in
264    /// the same batch are applied to the Account simultaneously.
265    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
266    pub batch_id: Option<TransactionId>,
267
268    /// The Request ID of the request which generated the transaction.
269    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
270    pub request_id: Option<RequestId>,
271
272    // type is pinned to "CREATE" by the enum wrapper
273    /// The ID of the Division that the Account is in
274    #[serde(rename = "divisionID", skip_serializing_if = "Option::is_none")]
275    pub division_id: Option<i64>,
276
277    /// The ID of the Site that the Account was created at
278    #[serde(rename = "siteID", skip_serializing_if = "Option::is_none")]
279    pub site_id: Option<i64>,
280
281    /// The ID of the user that the Account was created for
282    #[serde(rename = "accountUserID", skip_serializing_if = "Option::is_none")]
283    pub account_user_id: Option<i64>,
284
285    /// The number of the Account within the site/division/user
286    #[serde(rename = "accountNumber", skip_serializing_if = "Option::is_none")]
287    pub account_number: Option<i64>,
288
289    /// The home currency of the Account
290    #[serde(rename = "homeCurrency", skip_serializing_if = "Option::is_none")]
291    pub home_currency: Option<Currency>,
292}
293
294/// A CloseTransaction represents the closing of an Account.
295#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
296#[non_exhaustive]
297pub struct CloseTransaction {
298    /// The Transaction's Identifier.
299    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
300    pub id: Option<TransactionId>,
301
302    /// The date/time when the Transaction was created.
303    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
304    pub time: Option<DateTime>,
305
306    /// The ID of the user that initiated the creation of the Transaction.
307    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
308    pub user_id: Option<i64>,
309
310    /// The ID of the Account the Transaction was created for.
311    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
312    pub account_id: Option<AccountId>,
313
314    /// The ID of the "batch" that the Transaction belongs to. Transactions in
315    /// the same batch are applied to the Account simultaneously.
316    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
317    pub batch_id: Option<TransactionId>,
318
319    /// The Request ID of the request which generated the transaction.
320    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
321    pub request_id: Option<RequestId>,
322    // type is pinned to "CLOSE" by the enum wrapper
323}
324
325/// A ReopenTransaction represents the re-opening of a closed Account.
326#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
327#[non_exhaustive]
328pub struct ReopenTransaction {
329    /// The Transaction's Identifier.
330    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
331    pub id: Option<TransactionId>,
332
333    /// The date/time when the Transaction was created.
334    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
335    pub time: Option<DateTime>,
336
337    /// The ID of the user that initiated the creation of the Transaction.
338    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
339    pub user_id: Option<i64>,
340
341    /// The ID of the Account the Transaction was created for.
342    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
343    pub account_id: Option<AccountId>,
344
345    /// The ID of the "batch" that the Transaction belongs to. Transactions in
346    /// the same batch are applied to the Account simultaneously.
347    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
348    pub batch_id: Option<TransactionId>,
349
350    /// The Request ID of the request which generated the transaction.
351    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
352    pub request_id: Option<RequestId>,
353    // type is pinned to "REOPEN" by the enum wrapper
354}
355
356/// A TransferFundsTransaction represents the transfer of funds in/out of an
357/// Account.
358#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
359#[non_exhaustive]
360pub struct TransferFundsTransaction {
361    /// The Transaction's Identifier.
362    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
363    pub id: Option<TransactionId>,
364
365    /// The date/time when the Transaction was created.
366    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
367    pub time: Option<DateTime>,
368
369    /// The ID of the user that initiated the creation of the Transaction.
370    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
371    pub user_id: Option<i64>,
372
373    /// The ID of the Account the Transaction was created for.
374    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
375    pub account_id: Option<AccountId>,
376
377    /// The ID of the "batch" that the Transaction belongs to. Transactions in
378    /// the same batch are applied to the Account simultaneously.
379    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
380    pub batch_id: Option<TransactionId>,
381
382    /// The Request ID of the request which generated the transaction.
383    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
384    pub request_id: Option<RequestId>,
385
386    // type is pinned to "TRANSFER_FUNDS" by the enum wrapper
387    /// The amount to deposit/withdraw from the Account in the Account's home
388    /// currency. A positive value indicates a deposit, a negative value
389    /// indicates a withdrawal.
390    #[serde(rename = "amount", skip_serializing_if = "Option::is_none")]
391    pub amount: Option<AccountUnits>,
392
393    /// The `fundingReason` field.
394    #[serde(rename = "fundingReason", skip_serializing_if = "Option::is_none")]
395    pub funding_reason: Option<FundingReason>,
396
397    /// An optional comment that may be attached to a fund transfer for audit
398    /// purposes
399    #[serde(rename = "comment", skip_serializing_if = "Option::is_none")]
400    pub comment: Option<String>,
401
402    /// The Account's balance after funds are transferred.
403    #[serde(rename = "accountBalance", skip_serializing_if = "Option::is_none")]
404    pub account_balance: Option<AccountUnits>,
405}
406
407/// A TransferFundsRejectTransaction represents the rejection of the transfer of
408/// funds in/out of an Account.
409#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
410#[non_exhaustive]
411pub struct TransferFundsRejectTransaction {
412    /// The Transaction's Identifier.
413    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
414    pub id: Option<TransactionId>,
415
416    /// The date/time when the Transaction was created.
417    #[serde(rename = "time", skip_serializing_if = "Option::is_none")]
418    pub time: Option<DateTime>,
419
420    /// The ID of the user that initiated the creation of the Transaction.
421    #[serde(rename = "userID", skip_serializing_if = "Option::is_none")]
422    pub user_id: Option<i64>,
423
424    /// The ID of the Account the Transaction was created for.
425    #[serde(rename = "accountID", skip_serializing_if = "Option::is_none")]
426    pub account_id: Option<AccountId>,
427
428    /// The ID of the "batch" that the Transaction belongs to. Transactions in
429    /// the same batch are applied to the Account simultaneously.
430    #[serde(rename = "batchID", skip_serializing_if = "Option::is_none")]
431    pub batch_id: Option<TransactionId>,
432
433    /// The Request ID of the request which generated the transaction.
434    #[serde(rename = "requestID", skip_serializing_if = "Option::is_none")]
435    pub request_id: Option<RequestId>,
436
437    // type is pinned to "TRANSFER_FUNDS_REJECT" by the enum wrapper
438    /// The amount to deposit/withdraw from the Account in the Account's home
439    /// currency. A positive value indicates a deposit, a negative value
440    /// indicates a withdrawal.
441    #[serde(rename = "amount", skip_serializing_if = "Option::is_none")]
442    pub amount: Option<AccountUnits>,
443
444    /// The `fundingReason` field.
445    #[serde(rename = "fundingReason", skip_serializing_if = "Option::is_none")]
446    pub funding_reason: Option<FundingReason>,
447
448    /// An optional comment that may be attached to a fund transfer for audit
449    /// purposes
450    #[serde(rename = "comment", skip_serializing_if = "Option::is_none")]
451    pub comment: Option<String>,
452
453    /// The `rejectReason` field.
454    #[serde(rename = "rejectReason", skip_serializing_if = "Option::is_none")]
455    pub reject_reason: Option<TransactionRejectReason>,
456}
457
458string_enum! {
459    /// The reason that an Account is being funded.
460    pub enum FundingReason {
461        ClientFunding => "CLIENT_FUNDING",
462        AccountTransfer => "ACCOUNT_TRANSFER",
463        DivisionMigration => "DIVISION_MIGRATION",
464        SiteMigration => "SITE_MIGRATION",
465        Adjustment => "ADJUSTMENT",
466    }
467}