trading_ig/operations/models.rs
1//! Types for the operations (application management) domain.
2
3use chrono::NaiveDateTime;
4use serde::{Deserialize, Serialize};
5
6/// Status of an API application key.
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
9pub enum ApplicationStatus {
10 /// The API key is active and can be used.
11 Enabled,
12 /// The API key has been disabled. Re-enable via the IG web UI.
13 Disabled,
14 /// The API key has been revoked and cannot be re-enabled.
15 Revoked,
16}
17
18/// Metadata about an IG API application (key).
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(rename_all = "camelCase")]
21pub struct Application {
22 /// Human-readable name of the application.
23 pub name: String,
24 /// The API key string.
25 pub api_key: String,
26 /// Current status of the key.
27 pub status: ApplicationStatus,
28 /// Non-trading requests per minute allowance for the account.
29 pub allowance_account_overall: u32,
30 /// Trading requests per minute allowance for the account.
31 pub allowance_account_trading: u32,
32 /// Non-trading requests per minute allowance for this application.
33 pub allowance_application_overall: u32,
34 /// Maximum number of concurrent Lightstreamer subscriptions.
35 pub concurrent_subscriptions_limit: u32,
36 /// Whether equity trading is permitted with this key.
37 pub allow_equities: bool,
38 /// Whether quote orders are permitted with this key.
39 pub allow_quote_orders: bool,
40 /// When the application/key was created.
41 pub created_date: NaiveDateTime,
42}
43
44/// Request body for [`crate::operations::OperationsApi::update_application`].
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(rename_all = "camelCase")]
47pub struct UpdateApplicationRequest {
48 /// The API key to update.
49 pub api_key: String,
50 /// New desired status.
51 pub status: ApplicationStatus,
52 /// New non-trading per-minute allowance for the account.
53 pub allowance_account_overall: u32,
54 /// New trading per-minute allowance for the account.
55 pub allowance_account_trading: u32,
56}