mirror of
https://github.com/floor-licker/polyfill-rs.git
synced 2026-08-04 08:17:45 +00:00
fix(api): improve order endpoint compatibility
This commit is contained in:
+8
-4
@@ -848,10 +848,14 @@ impl ClobClient {
|
||||
|
||||
let response = req.json(&body).send().await?;
|
||||
if !response.status().is_success() {
|
||||
return Err(PolyfillError::api(
|
||||
response.status().as_u16(),
|
||||
"Failed to post order",
|
||||
));
|
||||
let status = response.status().as_u16();
|
||||
let body = response.text().await.unwrap_or_default();
|
||||
let message = if body.is_empty() {
|
||||
"Failed to post order".to_string()
|
||||
} else {
|
||||
format!("Failed to post order: {}", body)
|
||||
};
|
||||
return Err(PolyfillError::api(status, message));
|
||||
}
|
||||
|
||||
Ok(response.json::<Value>().await?)
|
||||
|
||||
+3
-2
@@ -208,9 +208,10 @@ impl Side {
|
||||
}
|
||||
|
||||
/// Order type specifications
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
pub enum OrderType {
|
||||
#[default]
|
||||
GTC,
|
||||
FOK,
|
||||
GTD,
|
||||
@@ -1099,7 +1100,7 @@ pub struct OpenOrder {
|
||||
pub asset_id: String,
|
||||
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
||||
pub expiration: u64,
|
||||
#[serde(rename = "type")]
|
||||
#[serde(rename = "type", alias = "order_type", alias = "orderType", default)]
|
||||
pub order_type: OrderType,
|
||||
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
||||
pub created_at: u64,
|
||||
|
||||
Reference in New Issue
Block a user