From 0f577f0b2c5fba21ced4d9a747a2273c46aeafcb Mon Sep 17 00:00:00 2001 From: floor-licker Date: Fri, 30 Jan 2026 21:10:03 -0500 Subject: [PATCH] fix(api): improve order endpoint compatibility --- src/client.rs | 12 ++++++++---- src/types.rs | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/client.rs b/src/client.rs index 6e1e70c..4fc5e96 100644 --- a/src/client.rs +++ b/src/client.rs @@ -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::().await?) diff --git a/src/types.rs b/src/types.rs index 0c47a4e..53efb9f 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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,