mirror of
https://github.com/floor-licker/polyfill-rs.git
synced 2026-08-19 07:28:10 +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?;
|
let response = req.json(&body).send().await?;
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
return Err(PolyfillError::api(
|
let status = response.status().as_u16();
|
||||||
response.status().as_u16(),
|
let body = response.text().await.unwrap_or_default();
|
||||||
"Failed to post order",
|
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?)
|
Ok(response.json::<Value>().await?)
|
||||||
|
|||||||
+3
-2
@@ -208,9 +208,10 @@ impl Side {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Order type specifications
|
/// 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)]
|
#[allow(clippy::upper_case_acronyms)]
|
||||||
pub enum OrderType {
|
pub enum OrderType {
|
||||||
|
#[default]
|
||||||
GTC,
|
GTC,
|
||||||
FOK,
|
FOK,
|
||||||
GTD,
|
GTD,
|
||||||
@@ -1099,7 +1100,7 @@ pub struct OpenOrder {
|
|||||||
pub asset_id: String,
|
pub asset_id: String,
|
||||||
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
||||||
pub expiration: u64,
|
pub expiration: u64,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type", alias = "order_type", alias = "orderType", default)]
|
||||||
pub order_type: OrderType,
|
pub order_type: OrderType,
|
||||||
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
|
||||||
pub created_at: u64,
|
pub created_at: u64,
|
||||||
|
|||||||
Reference in New Issue
Block a user