architect_api/accounts/
mod.rs

1use crate::{Account, AccountIdOrName, AccountPermissions, TraderIdOrEmail, UserId};
2use derive::grpc;
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6pub mod account;
7pub mod clearing_account;
8pub mod trader;
9
10#[grpc(package = "json.architect")]
11#[grpc(service = "Accounts", name = "accounts", response = "AccountsResponse")]
12#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
13pub struct AccountsRequest {
14    /// Request accounts from the perspective of this trader;
15    /// if not specified, defaults to the caller user.
16    pub trader: Option<TraderIdOrEmail>,
17    #[serde(default)]
18    pub paper: bool,
19}
20
21#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
22pub struct AccountsResponse {
23    pub accounts: Vec<AccountWithPermissions>,
24}
25
26#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
27#[cfg_attr(feature = "graphql", derive(juniper::GraphQLObject))]
28pub struct AccountWithPermissions {
29    pub account: Account,
30    pub trader: UserId,
31    pub permissions: AccountPermissions,
32}
33
34#[grpc(package = "json.architect")]
35#[grpc(
36    service = "Accounts",
37    name = "reset_paper_account",
38    response = "ResetPaperAccountResponse"
39)]
40#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
41pub struct ResetPaperAccountRequest {
42    /// The trader for whom to reset paper accounts.
43    /// If not specified, defaults to the caller user.
44    pub account: AccountIdOrName,
45    /// Balance to reset paper account to in USD cents
46    #[serde(default)]
47    pub usd_balance_cents: Option<i32>,
48}
49
50#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
51pub struct ResetPaperAccountResponse {}
52
53#[grpc(package = "json.architect")]
54#[grpc(
55    service = "Accounts",
56    name = "open_paper_account",
57    response = "OpenPaperAccountResponse"
58)]
59#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
60pub struct OpenPaperAccountRequest {
61    /// The name for the new paper account (will be of the form "PAPER:{email}:{account_name}")
62    /// If not specified, the default account will be created "PAPER:{email}"
63    /// Note that you cannot close a paper account once you open it.
64    pub account_name: Option<String>,
65    /// Balance to open paper account with in USD cents
66    pub usd_balance_cents: Option<i32>,
67}
68
69#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
70pub struct OpenPaperAccountResponse {
71    /// The newly created paper account
72    pub account: Account,
73}