kraapi/api/private/
cancel_on_timeout.rs1use indexmap::map::IndexMap;
2use serde::{Deserialize, Serialize};
3
4use crate::auth::KrakenAuth;
5use super::{EndpointInfo, KrakenInput, MethodType};
7
8use super::{Input, MutateInput, Output, UpdateInput};
10
11pub struct KICancelOnTimeout {
13 params: IndexMap<String, String>,
14}
15
16impl KICancelOnTimeout {
17 pub fn build(timeout: u32) -> KICancelOnTimeout {
20 let cancelorder = KICancelOnTimeout {
21 params: IndexMap::new(),
22 };
23 cancelorder.on_timeout(timeout)
24 }
25
26 pub fn on_timeout(self, timeout: u32) -> Self {
28 self.update_input("timeout", timeout.to_string())
29 }
30
31 fn with_nonce(self) -> Self {
32 self.update_input("nonce", KrakenAuth::nonce())
33 }
34}
35
36impl MutateInput for KICancelOnTimeout {
37 fn list_mut(&mut self) -> &mut IndexMap<String, String> {
38 &mut self.params
39 }
40}
41
42impl UpdateInput for KICancelOnTimeout {}
43
44impl Input for KICancelOnTimeout {
45 fn finish(self) -> KrakenInput {
46 KrakenInput {
47 info: EndpointInfo {
48 methodtype: MethodType::Private,
49 endpoint: String::from("CancelAllOrdersAfter"),
50 },
51 params: Some(self.with_nonce().params),
52 }
53 }
54
55 fn finish_clone(self) -> (KrakenInput, Self) {
56 let newself = self.with_nonce();
57 (
58 KrakenInput {
59 info: EndpointInfo {
60 methodtype: MethodType::Private,
61 endpoint: String::from("CancelAllOrdersAfter"),
62 },
63 params: Some(newself.params.clone()),
64 },
65 newself,
66 )
67 }
68}
69
70#[derive(Deserialize, Serialize, Debug)]
72pub struct KOCancelOnTimeout {
73 #[serde(rename = "currentTime")]
75 pub current_time: String,
76 #[serde(rename = "triggerTime")]
79 pub trigger_time: String,
80}
81
82impl Output for KOCancelOnTimeout {}