1 stable release
1.0.0 | Aug 10, 2024 |
---|
#21 in #client-send
9KB
142 lines
禾禾奇趣屋-API-RUST版本SDK
引入
[dependencies]
ho-api-rust-sdk = "1.0.0"
使用示例
#[cfg(test)]
mod tests {
use serde_json::json;
use tokio::test;
use super::*;
#[test]
async fn test_send_request() {
let config = ApiClientConfig {
app_id: "your app id".to_string(),
app_secret: "your app secret".to_string(),
iv: "you app iv".to_string(),
base_url: "https://server.zelaser.com".to_string(),
content: "/server/common/api".to_string(),
};
let client = ApiClient::new(config).expect("Failed to create API client");
let body = json!({
"key": "value",
});
match client.send(Method::GET, "/v1/lol/champion/mate?region=cn", Some(body)).await {
Ok(response) => {
println!("Response Body: {}", response);
}
Err(e) => eprintln!("Error: {:?}", e),
}
}
}
Dependencies
~9–21MB
~283K SLoC