fix: model changes (still WIP!)

This commit is contained in:
əlemi 2023-05-26 15:26:55 +02:00
parent 62af1e3c03
commit e92dd51505
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 23 additions and 7 deletions

View file

@ -68,7 +68,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
};
println!("╶┐ * {}", collection.info.name);
println!("{}", collection.info.description);
if let Some(descr) = collection.info.description {
println!("{}", descr);
}
println!("");
match args.action {
@ -78,7 +80,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let item = Item {
name: "TODO!".into(),
event: None,
request: Request {
item: None,
request: Some(Request {
url: crate::proto::Url::String(url),
method: method.to_string(),
header: Some(
@ -92,8 +95,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
),
body: if data.len() > 0 { Some(Body::Text(data)) } else { None },
description: None,
},
response: vec![],
}),
response: Some(vec![]),
};
if debug {

View file

@ -6,6 +6,18 @@ use crate::proto::Item;
impl Item {
pub async fn send(&self) -> Result<Response> {
if let Some(items) = self.item {
let tasks = vec![];
for i in items {
tasks.push(
tokio::spawn(async { i.send().await })
)
}
for t in tasks {
t.await.unwrap()?;
}
}
let method = Method::from_bytes(
self.request.method.as_bytes() // TODO lol?
).unwrap_or(Method::GET); // TODO throw an error rather than replacing it silently

View file

@ -10,7 +10,7 @@ pub struct PostWomanCollection {
#[derive(Serialize, Deserialize, Debug)]
pub struct CollectionInfo {
pub name: String,
pub description: String,
pub description: Option<String>,
pub schema: String,
pub _postman_id: Option<String>,
@ -20,8 +20,9 @@ pub struct CollectionInfo {
pub struct Item {
pub name: String,
pub event: Option<Vec<Event>>,
pub request: Request,
pub response: Vec<String>, // TODO surely isn't just strings
pub request: Option<Request>,
pub response: Option<Vec<String>>, // TODO surely isn't just strings
pub item: Option<Vec<Item>>,
}
#[derive(Serialize, Deserialize, Debug)]