From 5fe2d9b599f5ec064368a4b050fd153308a7ad26 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Sun, 20 Aug 2023 20:34:31 -0700 Subject: [PATCH] working get reqest of all notes --- Cargo.lock | 19 +++++++++++++++++-- status_cloud/Cargo.toml | 1 + status_cloud/src/main.rs | 28 ++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95e5fc8..a5bb69d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -652,9 +652,23 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.183" +version = "1.0.184" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ac8da02677876d532745a130fc9d8e6edfa81a269b107c5b00829b91d8eb3c" +checksum = "2c911f4b04d7385c9035407a4eff5903bf4fe270fa046fda448b69e797f4fff0" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.184" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1df27f5b29406ada06609b2e2f77fb34f6dbb104a457a671cc31dbed237e09e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "serde_json" @@ -713,6 +727,7 @@ name = "status_cloud" version = "0.1.0" dependencies = [ "reqwest", + "serde", ] [[package]] diff --git a/status_cloud/Cargo.toml b/status_cloud/Cargo.toml index a78cbd0..1bd73d7 100644 --- a/status_cloud/Cargo.toml +++ b/status_cloud/Cargo.toml @@ -7,3 +7,4 @@ edition = "2021" [dependencies] reqwest = { version = "0.11.18", features = ["blocking", "json"] } +serde = { version = "1.0.184", features = ["serde_derive"] } diff --git a/status_cloud/src/main.rs b/status_cloud/src/main.rs index e7a11a9..9b7b36a 100644 --- a/status_cloud/src/main.rs +++ b/status_cloud/src/main.rs @@ -1,3 +1,27 @@ -fn main() { - println!("Hello, world!"); +use serde::{Deserialize, Serialize}; +use reqwest::blocking::Client; + +fn main() -> Result<(), Box> { + let client = Client::new(); + let res = client + .get("https://username:password@files.nickiel.net/index.php/apps/notes/api/v1/notes") + .header("Accept", "application/json") + .send()? + .json::>()?; + + println!("{:#?}", res); + Ok(()) +} + + +#[derive(Serialize, Deserialize, Debug)] +struct Note { + id: usize, + etag: String, + readonly: bool, + modified: u64, + title: String, + category: String, + content: String, + favorite: bool }