1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// use std::collections::HashMap;
// use std::sync::Arc;
// use async_trait::async_trait;
// use tokio::sync::Mutex;
// use crate::Client;
// use crate::error::{Error, ErrorType};
// use crate::orders::create::{CreateOrderParams, CreateOrderResponse};
// use crate::orders::delete::{DeleteAllOrdersParams, DeleteOrderParams};
// use crate::orders::get::GetOrderParams;
// use crate::orders::Order;
//
// #[async_trait]
// pub trait ClientInterface: Send + Sync {
// async fn delete_order(&self, token: &str, params: DeleteOrderParams) -> Result<(), Error>;
// async fn delete_all_orders(&self, token: &str, params: DeleteAllOrdersParams) -> Result<(), Error>;
// async fn get_order(&self, _token: &str, params: GetOrderParams) -> Result<Order, Error>;
// async fn create_order(&self, token: &str, params: CreateOrderParams) -> Result<CreateOrderResponse, Error>;
// }
//
//
// #[async_trait]
// impl ClientInterface for Client {
// async fn delete_order(&self, token: &str, params: DeleteOrderParams) -> Result<(), Error> {
// self.delete_order(token, params).await
// }
//
// async fn delete_all_orders(&self, token: &str, params: DeleteAllOrdersParams) -> Result<(), Error> {
// self.delete_all_orders(token, params).await
// }
//
// async fn get_order(&self, token: &str, params: GetOrderParams) -> Result<Order, Error> {
// self.get_order(token, params).await
// }
//
// async fn create_order(&self, token: &str, params: CreateOrderParams) -> Result<CreateOrderResponse, Error> {
// self.create_order(token, params).await
// }
// }
//
// #[derive(Debug, Clone, Default)]
// pub struct MockClient {
// pub deleted_order_ids: Arc<Mutex<Vec<(String, String)>>>,
// pub deleted_all_orders: Arc<Mutex<Vec<(String, Option<String>)>>>,
// pub orders: Arc<Mutex<HashMap<(String, String), Order>>>,
// pub created_orders: Arc<Mutex<Vec<CreateOrderParams>>>,
// }
//
// #[async_trait]
// impl ClientInterface for MockClient {
// async fn delete_order(&self, _token: &str, params: DeleteOrderParams) -> Result<(), Error> {
// self.deleted_order_ids
// .lock()
// .await
// .push((params.account_id, params.order_id));
// Ok(())
// }
//
// async fn delete_all_orders(&self, _token: &str, params: DeleteAllOrdersParams) -> Result<(), Error> {
// self.deleted_all_orders
// .lock()
// .await
// .push((params.account_id, params.symbol));
// Ok(())
// }
//
// async fn get_order(&self, _token: &str, params: GetOrderParams) -> Result<Order, Error> {
// let key = (params.account_id.clone(), params.order_id.clone());
// let map = self.orders.lock().await;
// map.get(&key)
// .cloned()
// .ok_or_else(|| Error::new(ErrorType::NotFound, "Order not found".to_string()))
// }
//
// async fn create_order(&self, _token: &str, params: CreateOrderParams) -> Result<CreateOrderResponse, Error> {
// self.created_orders.lock().await.push(params.clone());
// Ok(CreateOrderResponse {
// order_id: "mock_order_123".to_string(),
// })
// }
// }