feat: update according to spec
This commit is contained in:
parent
a28e7b57a2
commit
e4fe3c5779
1 changed files with 36 additions and 18 deletions
|
@ -1,27 +1,45 @@
|
||||||
use reqwest::blocking::Response;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
pub struct APITransaction<R = Response> {
|
enum Query {
|
||||||
/// Query made to API.
|
Pull {
|
||||||
query: String, //TODO: enum
|
name: String,
|
||||||
/// Response struct from abstracted library
|
version: Option<u128>,
|
||||||
_response: Option<R>
|
tags: Vec<String>
|
||||||
}
|
},
|
||||||
|
Push {
|
||||||
impl<R> APITransaction<R> {
|
_data: Vec<u8>
|
||||||
pub fn new(_response: Option<R>) -> Self {
|
|
||||||
APITransaction {
|
|
||||||
query: String::default(),
|
|
||||||
_response
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct API {
|
struct Request {
|
||||||
base_url: String,
|
version: u32,
|
||||||
|
id: String,
|
||||||
token: Option<String>,
|
token: Option<String>,
|
||||||
history: Vec<APITransaction>
|
query: HashMap<String, Query>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl API {
|
struct DataErrorDetails {
|
||||||
|
actor: String,
|
||||||
|
detailed_cause: String,
|
||||||
|
recovery_options: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct DataError {
|
||||||
|
name: String,
|
||||||
|
cause: Option<String>,
|
||||||
|
details: Option<DataErrorDetails>
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Data {
|
||||||
|
Pull {
|
||||||
|
_data: Option<Vec<u8>>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Response {
|
||||||
|
version: u32,
|
||||||
|
id: String,
|
||||||
|
reply_to: String,
|
||||||
|
errors: HashMap<String, DataError>,
|
||||||
|
data: HashMap<String, Data>
|
||||||
}
|
}
|
Loading…
Reference in a new issue