ig_client/session/
response.rs

1/// Response structure for session-related API calls
2#[derive(serde::Deserialize)]
3pub struct SessionResp {
4    /// Account ID associated with the session
5    #[serde(alias = "accountId")]
6    #[serde(alias = "currentAccountId")]
7    pub account_id: String,
8
9    /// Client ID provided by the API
10    #[serde(alias = "clientId")]
11    pub client_id: Option<String>,
12    /// Timezone offset in hours
13    #[serde(alias = "timezoneOffset")]
14    pub timezone_offset: Option<i32>,
15}
16
17/// Request model for switching the active account
18#[derive(serde::Serialize)]
19pub struct AccountSwitchRequest {
20    /// The identifier of the account being switched to
21    #[serde(rename = "accountId")]
22    pub account_id: String,
23    /// True if the specified account is to be set as the new default account
24    #[serde(rename = "defaultAccount")]
25    pub default_account: Option<bool>,
26}
27
28/// Response model for account switch operation
29#[derive(serde::Deserialize, Debug)]
30pub struct AccountSwitchResponse {
31    /// Whether dealing is enabled for the account
32    #[serde(rename = "dealingEnabled")]
33    pub dealing_enabled: Option<bool>,
34    /// Whether the user has active demo accounts
35    #[serde(rename = "hasActiveDemoAccounts")]
36    pub has_active_demo_accounts: Option<bool>,
37    /// Whether the user has active live accounts
38    #[serde(rename = "hasActiveLiveAccounts")]
39    pub has_active_live_accounts: Option<bool>,
40    /// Whether trailing stops are enabled for the account
41    #[serde(rename = "trailingStopsEnabled")]
42    pub trailing_stops_enabled: Option<bool>,
43}
44
45/// OAuth token information returned by API v3
46#[derive(serde::Deserialize, serde::Serialize, Debug, Clone)]
47pub struct OAuthToken {
48    /// OAuth access token
49    pub access_token: String,
50    /// OAuth refresh token
51    pub refresh_token: String,
52    /// Token scope
53    pub scope: String,
54    /// Token type (typically "Bearer")
55    pub token_type: String,
56    /// Token expiry time in seconds
57    pub expires_in: String,
58}
59
60/// Response structure for session API v3 calls
61#[derive(serde::Deserialize, Debug)]
62pub struct SessionV3Resp {
63    /// Client ID provided by the API
64    #[serde(rename = "clientId")]
65    pub client_id: String,
66    /// Account ID associated with the session
67    #[serde(rename = "accountId")]
68    pub account_id: String,
69    /// Timezone offset in hours
70    #[serde(rename = "timezoneOffset")]
71    pub timezone_offset: i32,
72    /// Lightstreamer endpoint for subscribing to account and price updates
73    #[serde(rename = "lightstreamerEndpoint")]
74    pub lightstreamer_endpoint: String,
75    /// OAuth token information
76    #[serde(rename = "oauthToken")]
77    pub oauth_token: OAuthToken,
78}