@@ -140,7 +140,18 @@ pub fn parse_result(response: &Map<String, Value>) -> Result<Map<String, Value>>
140
140
}
141
141
}
142
142
143
+ /// Return the currency enum associated with the
144
+ /// string used by Kraken. If no currency is found,
143
145
/// return None
146
+ /// # Examples
147
+ ///
148
+ /// ```
149
+ /// use coinnect::kraken::utils::get_currency_enum;
150
+ /// use coinnect::currency::Currency;
151
+ ///
152
+ /// let currency = get_currency_enum("ZUSD");
153
+ /// assert_eq!(Some(Currency::USD), currency);
154
+ /// ```
144
155
pub fn get_currency_enum ( currency : & str ) -> Option < Currency > {
145
156
match currency {
146
157
"ZEUR" => Some ( Currency :: EUR ) ,
@@ -166,3 +177,41 @@ pub fn get_currency_enum(currency: &str) -> Option<Currency> {
166
177
_ => None ,
167
178
}
168
179
}
180
+
181
+ /// Return the currency String associated with the
182
+ /// string used by Kraken. If no currency is found,
183
+ /// return None
184
+ /// # Examples
185
+ ///
186
+ /// ```
187
+ /// use coinnect::kraken::utils::get_currency_string;
188
+ /// use coinnect::currency::Currency;
189
+ ///
190
+ /// let currency = get_currency_string(Currency::BTC);
191
+ /// assert_eq!(currency, Some("XXBT".to_string()));
192
+ /// ```
193
+ pub fn get_currency_string ( currency : Currency ) -> Option < String > {
194
+ match currency {
195
+ Currency :: EUR => Some ( "ZEUR" . to_string ( ) ) ,
196
+ Currency :: CAD => Some ( "ZCAD" . to_string ( ) ) ,
197
+ Currency :: GBP => Some ( "ZGBP" . to_string ( ) ) ,
198
+ Currency :: JPY => Some ( "ZJPY" . to_string ( ) ) ,
199
+ Currency :: USD => Some ( "ZUSD" . to_string ( ) ) ,
200
+ Currency :: DASH => Some ( "XDASH" . to_string ( ) ) ,
201
+ Currency :: ETC => Some ( "XETC" . to_string ( ) ) ,
202
+ Currency :: ETH => Some ( "XETH" . to_string ( ) ) ,
203
+ Currency :: GNO => Some ( "XGNO" . to_string ( ) ) ,
204
+ Currency :: ICN => Some ( "XICN" . to_string ( ) ) ,
205
+ Currency :: LTC => Some ( "XLTC" . to_string ( ) ) ,
206
+ Currency :: MLN => Some ( "XMLN" . to_string ( ) ) ,
207
+ Currency :: REP => Some ( "XREP" . to_string ( ) ) ,
208
+ Currency :: USDT => Some ( "XUSDT" . to_string ( ) ) ,
209
+ Currency :: BTC => Some ( "XXBT" . to_string ( ) ) ,
210
+ Currency :: XDG => Some ( "XXDG" . to_string ( ) ) ,
211
+ Currency :: XLM => Some ( "XXLM" . to_string ( ) ) ,
212
+ Currency :: XMR => Some ( "XXMR" . to_string ( ) ) ,
213
+ Currency :: XRP => Some ( "XXRP" . to_string ( ) ) ,
214
+ Currency :: ZEC => Some ( "XZEC" . to_string ( ) ) ,
215
+ _ => None ,
216
+ }
217
+ }
0 commit comments