@@ -35,70 +35,20 @@ impl Candle {
35
35
// optional
36
36
parameters. extend (
37
37
[
38
- options
39
- . market
40
- . map ( |market| ( "market" . to_string ( ) , market. to_string ( ) ) ) ,
41
38
options
42
39
. interval
43
40
. map ( |interval| ( "interval" . to_string ( ) , interval. to_string ( ) ) ) ,
44
- options
45
- . page
46
- . map ( |page| ( "page" . to_string ( ) , page. to_string ( ) ) ) ,
47
- options
48
- . limit
49
- . map ( |limit| ( "limit" . to_string ( ) , limit. to_string ( ) ) ) ,
50
41
options
51
42
. from
52
43
. map ( |from| ( "from" . to_string ( ) , from. to_string ( ) ) ) ,
53
44
options. to . map ( |to| ( "to" . to_string ( ) , to. to_string ( ) ) ) ,
54
- options
55
- . sort
56
- . map ( |sort| ( "sort" . to_string ( ) , sort. to_string ( ) ) ) ,
57
45
]
58
46
. into_iter ( )
59
47
. flatten ( ) ,
60
48
) ;
61
49
62
50
self . client . get ( "/dex/candle" , Some ( parameters) )
63
51
}
64
-
65
- /// Retrieves information about available pools, including details about the chain, exchange,
66
- /// base and quote symbols, and pool address. Optional parameters can be provided to filter the
67
- /// results by chain and exchange.
68
- pub fn pools ( & self , options : PoolsOptions ) -> Result < Vec < PoolsResponse > > {
69
- let mut parameters = HashMap :: new ( ) ;
70
-
71
- // optional
72
- parameters. extend (
73
- [
74
- options
75
- . exchange
76
- . map ( |exchange| ( "exchange" . to_string ( ) , exchange. to_string ( ) ) ) ,
77
- options
78
- . chain
79
- . map ( |chain| ( "chain" . to_string ( ) , chain. to_string ( ) ) ) ,
80
- ]
81
- . into_iter ( )
82
- . flatten ( ) ,
83
- ) ;
84
-
85
- self . client . get ( "/dex/candle/pools" , Some ( parameters) )
86
- }
87
-
88
- /// Retrieves a list of available chains for candle data.
89
- pub fn chains ( & self ) -> Result < Vec < String > > {
90
- self . client . get ( "/dex/candle/chains" , None )
91
- }
92
-
93
- /// Retrieves a list of available exchanges for candle data.
94
- pub fn exchanges ( & self ) -> Result < Vec < String > > {
95
- self . client . get ( "/dex/candle/exchanges" , None )
96
- }
97
-
98
- /// Retrieves a list of available intervals for candle data.
99
- pub fn intervals ( & self ) -> Result < Vec < String > > {
100
- self . client . get ( "/dex/candle/intervals" , None )
101
- }
102
52
}
103
53
104
54
/// Implements the `Datamaxi` trait for `Candle`, providing methods
@@ -204,87 +154,139 @@ impl Trade {
204
154
205
155
self . client . get ( "/dex/trade" , Some ( parameters) )
206
156
}
157
+ }
158
+
159
+ /// Implements the `Datamaxi` trait for `Trade`, providing methods
160
+ /// to create new instances of `Trade` with or without a custom base URL.
161
+ impl Datamaxi for Trade {
162
+ /// Creates a new `Trade` instance with the default base URL.
163
+ ///
164
+ /// # Parameters
165
+ /// - `api_key`: A `String` containing the API key to authenticate requests.
166
+ ///
167
+ /// # Returns
168
+ /// A new `Trade` instance configured with the default base URL and the provided `api_key`.
169
+ ///
170
+ /// # Example
171
+ /// ```rust
172
+ /// use crate::datamaxi::api::Datamaxi;
173
+ /// let trade = datamaxi::dex::Trade::new("my_api_key".to_string());
174
+ /// ```
175
+ fn new ( api_key : String ) -> Trade {
176
+ let config = Config {
177
+ base_url : None , // Use the default base URL
178
+ api_key, // Provided API key
179
+ } ;
180
+ Trade {
181
+ client : Client :: new ( config) , // Create a new client with the given config
182
+ }
183
+ }
184
+
185
+ /// Creates a new `Trade` instance with a custom base URL.
186
+ ///
187
+ /// # Parameters
188
+ /// - `api_key`: A `String` containing the API key to authenticate requests.
189
+ /// - `base_url`: A `String` specifying the custom base URL for API requests.
190
+ ///
191
+ /// # Returns
192
+ /// A new `Trade` instance configured with the provided `base_url` and `api_key`.
193
+ ///
194
+ /// # Example
195
+ /// ```rust
196
+ /// use crate::datamaxi::api::Datamaxi;
197
+ /// let trade = datamaxi::dex::Trade::new_with_base_url("my_api_key".to_string(), "https://custom-api.example.com".to_string());
198
+ /// ```
199
+ fn new_with_base_url ( api_key : String , base_url : String ) -> Trade {
200
+ let config = Config {
201
+ base_url : Some ( base_url) , // Use the provided custom base URL
202
+ api_key, // Provided API key
203
+ } ;
204
+ Trade {
205
+ client : Client :: new ( config) , // Create a new client with the given config
206
+ }
207
+ }
208
+ }
207
209
210
+ #[ derive( Clone ) ]
211
+ pub struct Pool {
212
+ pub client : Client ,
213
+ }
214
+
215
+ impl Pool {
208
216
/// Retrieves information about available pools, including details about the chain, exchange,
209
217
/// base and quote symbols, and pool address. Optional parameters can be provided to filter the
210
218
/// results by chain and exchange.
211
- pub fn pools ( & self , options : PoolsOptions ) -> Result < Vec < PoolsResponse > > {
219
+ pub fn get (
220
+ & self ,
221
+ options : PoolsOptions ,
222
+ ) -> Result < PoolsResponse >
223
+ {
212
224
let mut parameters = HashMap :: new ( ) ;
213
225
214
226
// optional
215
227
parameters. extend (
216
228
[
217
- options
218
- . chain
219
- . map ( |chain| ( "chain" . to_string ( ) , chain. to_string ( ) ) ) ,
220
229
options
221
230
. exchange
222
231
. map ( |exchange| ( "exchange" . to_string ( ) , exchange. to_string ( ) ) ) ,
232
+ options
233
+ . chain
234
+ . map ( |chain| ( "chain" . to_string ( ) , chain. to_string ( ) ) ) ,
223
235
]
224
236
. into_iter ( )
225
237
. flatten ( ) ,
226
238
) ;
227
239
228
- self . client . get ( "/dex/trade/pools" , Some ( parameters) )
229
- }
230
-
231
- /// Retrieves a list of available intervals for trade data.
232
- pub fn chains ( & self ) -> Result < Vec < String > > {
233
- self . client . get ( "/dex/trade/chains" , None )
234
- }
235
-
236
- /// Retrieves a list of available exchanges for trade data.
237
- pub fn exchanges ( & self ) -> Result < Vec < String > > {
238
- self . client . get ( "/dex/trade/exchanges" , None )
240
+ self . client . get ( "/dex/pools" , Some ( parameters) )
239
241
}
240
242
}
241
243
242
- /// Implements the `Datamaxi` trait for `Trade `, providing methods
243
- /// to create new instances of `Trade ` with or without a custom base URL.
244
- impl Datamaxi for Trade {
245
- /// Creates a new `Trade ` instance with the default base URL.
244
+ /// Implements the `Datamaxi` trait for `Pool `, providing methods
245
+ /// to create new instances of `Pool ` with or without a custom base URL.
246
+ impl Datamaxi for Pool {
247
+ /// Creates a new `Pool ` instance with the default base URL.
246
248
///
247
249
/// # Parameters
248
250
/// - `api_key`: A `String` containing the API key to authenticate requests.
249
251
///
250
252
/// # Returns
251
- /// A new `Trade ` instance configured with the default base URL and the provided `api_key`.
253
+ /// A new `Pool ` instance configured with the default base URL and the provided `api_key`.
252
254
///
253
255
/// # Example
254
256
/// ```rust
255
257
/// use crate::datamaxi::api::Datamaxi;
256
- /// let trade = datamaxi::dex::Trade ::new("my_api_key".to_string());
258
+ /// let pool = datamaxi::dex::Pool ::new("my_api_key".to_string());
257
259
/// ```
258
- fn new ( api_key : String ) -> Trade {
260
+ fn new ( api_key : String ) -> Pool {
259
261
let config = Config {
260
262
base_url : None , // Use the default base URL
261
263
api_key, // Provided API key
262
264
} ;
263
- Trade {
265
+ Pool {
264
266
client : Client :: new ( config) , // Create a new client with the given config
265
267
}
266
268
}
267
269
268
- /// Creates a new `Trade ` instance with a custom base URL.
270
+ /// Creates a new `Pool ` instance with a custom base URL.
269
271
///
270
272
/// # Parameters
271
273
/// - `api_key`: A `String` containing the API key to authenticate requests.
272
274
/// - `base_url`: A `String` specifying the custom base URL for API requests.
273
275
///
274
276
/// # Returns
275
- /// A new `Trade ` instance configured with the provided `base_url` and `api_key`.
277
+ /// A new `Pool ` instance configured with the provided `base_url` and `api_key`.
276
278
///
277
279
/// # Example
278
280
/// ```rust
279
281
/// use crate::datamaxi::api::Datamaxi;
280
- /// let trade = datamaxi::dex::Trade ::new_with_base_url("my_api_key".to_string(), "https://custom-api.example.com".to_string());
282
+ /// let pool = datamaxi::dex::Pool ::new_with_base_url("my_api_key".to_string(), "https://custom-api.example.com".to_string());
281
283
/// ```
282
- fn new_with_base_url ( api_key : String , base_url : String ) -> Trade {
284
+ fn new_with_base_url ( api_key : String , base_url : String ) -> Pool {
283
285
let config = Config {
284
286
base_url : Some ( base_url) , // Use the provided custom base URL
285
287
api_key, // Provided API key
286
288
} ;
287
- Trade {
289
+ Pool {
288
290
client : Client :: new ( config) , // Create a new client with the given config
289
291
}
290
292
}
0 commit comments