separate docs, added front comparison for pk
This commit is contained in:
parent
b0e080d1ee
commit
7617757861
20
README.org
20
README.org
|
@ -67,6 +67,7 @@ struct System {
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
#[derive(PartialEq)]
|
||||||
struct Member {
|
struct Member {
|
||||||
pk_id: String,
|
pk_id: String,
|
||||||
sp_id: String,
|
sp_id: String,
|
||||||
|
@ -99,6 +100,7 @@ fn main() {
|
||||||
//set_empty(config_path);
|
//set_empty(config_path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//"get" => get(config_path),
|
||||||
"memberlist" => memberlist(config_path),
|
"memberlist" => memberlist(config_path),
|
||||||
&_ => println!("Invalid command"),
|
&_ => println!("Invalid command"),
|
||||||
}
|
}
|
||||||
|
@ -201,12 +203,14 @@ fn set_member(config_path: String, tf_members: &[String]) -> Result<(), &'static
|
||||||
}
|
}
|
||||||
if to_front.len() != 0 {
|
if to_front.len() != 0 {
|
||||||
let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system);
|
let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system);
|
||||||
|
|
||||||
pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters);
|
pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
***** Memberlist
|
||||||
|
#+begin_src rust :tangle src/main.rs :comments link
|
||||||
fn memberlist(config_path: String) {
|
fn memberlist(config_path: String) {
|
||||||
let sys = get_system(&config_path);
|
let sys = get_system(&config_path);
|
||||||
|
|
||||||
|
@ -230,7 +234,10 @@ fn pk_get_system(key: &str) -> Value {
|
||||||
let res = http_get_request(url,key);
|
let res = http_get_request(url,key);
|
||||||
return serde_json::from_str(&res.unwrap()).unwrap();
|
return serde_json::from_str(&res.unwrap()).unwrap();
|
||||||
}
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
***** Get members
|
||||||
|
#+begin_src rust :tangle src/main.rs :comments link
|
||||||
fn pk_get_members(key: &str, sysid: &str) -> Vec<Value> {
|
fn pk_get_members(key: &str, sysid: &str) -> Vec<Value> {
|
||||||
let url = format!("{}/systems/{}/members", PK_URL, sysid);
|
let url = format!("{}/systems/{}/members", PK_URL, sysid);
|
||||||
|
|
||||||
|
@ -398,7 +405,10 @@ fn get_system(config_path: &str) -> System {
|
||||||
return sys;
|
return sys;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
***** Get fronters
|
||||||
|
#+begin_src rust :tangle src/main.rs :comments link
|
||||||
fn get_fronters(pk_key: &str, sp_key: &str, sys: &System) -> HashMap<String, Vec<Member>> {
|
fn get_fronters(pk_key: &str, sp_key: &str, sys: &System) -> HashMap<String, Vec<Member>> {
|
||||||
let mut fronters: HashMap<String, Vec<Member>> = HashMap::new();
|
let mut fronters: HashMap<String, Vec<Member>> = HashMap::new();
|
||||||
fronters.insert(String::from("pk"), pk_get_fronters(pk_key, sys));
|
fronters.insert(String::from("pk"), pk_get_fronters(pk_key, sys));
|
||||||
|
@ -409,6 +419,7 @@ fn get_fronters(pk_key: &str, sp_key: &str, sys: &System) -> HashMap<String, Vec
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
**** Http Request handler
|
**** Http Request handler
|
||||||
|
***** Get request
|
||||||
#+begin_src rust :tangle src/main.rs :comments link
|
#+begin_src rust :tangle src/main.rs :comments link
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn http_get_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
async fn http_get_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
@ -423,8 +434,10 @@ async fn http_get_request(url: String, key: &str) -> Result<String, Box<dyn std:
|
||||||
.await?;
|
.await?;
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
***** Post request
|
||||||
|
#+begin_src rust :tangle src/main.rs :comments link
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn http_post_request(url: String, key: &str, body: &HashMap<&str, Vec<String>>) -> Result<(), Box<dyn std::error::Error>> {
|
async fn http_post_request(url: String, key: &str, body: &HashMap<&str, Vec<String>>) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
@ -437,7 +450,10 @@ async fn http_post_request(url: String, key: &str, body: &HashMap<&str, Vec<Stri
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
***** Patch request
|
||||||
|
#+begin_src rust :tangle src/main.rs :comments link
|
||||||
/*
|
/*
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn http_patch_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
async fn http_patch_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
|
47
TODO.org
47
TODO.org
|
@ -8,20 +8,19 @@
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:COOKIE_DATA: recursive
|
:COOKIE_DATA: recursive
|
||||||
:END:
|
:END:
|
||||||
*** Milestone 1.0 [10/22][45%]
|
*** Milestone 1.0 [12/24][50%]
|
||||||
**** Main functions [4/11][36%]
|
**** Main functions [4/10][40%]
|
||||||
***** Finished Add `sync` command
|
***** Finished Add `sync` command
|
||||||
***** HighPriority Add `set` command [2/3]
|
***** HighPriority Add `set` command [2/3]
|
||||||
****** HighPriority [SET] Add empty
|
****** Backlog [SET] Add empty
|
||||||
****** Finished [SET] Add set
|
****** Finished [SET] Add set
|
||||||
****** Finished Adapt to set multiple arguments
|
****** Finished Adapt to set multiple arguments
|
||||||
***** HighPriority Add `get` command
|
***** InProgress Add `get` command
|
||||||
***** LowPriority Add `add` command [0/2]
|
***** Backlog Add `add` command [0/2]
|
||||||
****** LowPriority [ADD] Add empty
|
****** Backlog [ADD] Add empty
|
||||||
****** LowPriority [ADD] Add set
|
****** Backlog [ADD] Add set
|
||||||
***** LowPriority Add `setgroup` command
|
|
||||||
***** Finished Add `memberlist` command
|
***** Finished Add `memberlist` command
|
||||||
**** Utils [6/10][60%]
|
**** Utils [7/12][58%]
|
||||||
***** Json loading [2/2]
|
***** Json loading [2/2]
|
||||||
****** Finished Add new function to get the config create empty in path if not exists
|
****** Finished Add new function to get the config create empty in path if not exists
|
||||||
****** Finished `Get system` if Value::Null sync and load json
|
****** Finished `Get system` if Value::Null sync and load json
|
||||||
|
@ -29,29 +28,33 @@
|
||||||
***** Finished http PATCH request
|
***** Finished http PATCH request
|
||||||
***** Finished http POST request
|
***** Finished http POST request
|
||||||
***** Finished Set members know the alias
|
***** Finished Set members know the alias
|
||||||
***** HighPriority Compare if sent members are currently fronting and keep them otherwise add to fronting array
|
***** Finished Compare if sent members are currently fronting and keep them otherwise add to fronting array
|
||||||
|
***** InProgress Set simplyplural
|
||||||
|
***** InProgress Check if member is currently fronting and just add if not, remove the ones who do not
|
||||||
***** HighPriority Check for mismatch in fronting between pluralkit and simplyplural
|
***** HighPriority Check for mismatch in fronting between pluralkit and simplyplural
|
||||||
***** LowPriority Get fronters handles the front file
|
***** LowPriority Get fronters handles the front file
|
||||||
***** HighPriority Rofi stuff
|
***** HighPriority Rofi stuff
|
||||||
**** Doc [0/1][0%]
|
**** Exception handling [0/1][0%]
|
||||||
***** Functions [0/1]
|
***** Backlog do it proper
|
||||||
****** Backlog Separate memberlist into its own code block in the readme
|
**** Doc [1/1][100%]
|
||||||
|
***** Functions [1/1]
|
||||||
|
****** Finished Separate memberlist into its own code block in the readme
|
||||||
|
|
||||||
** Kanban
|
** Kanban
|
||||||
| Backlog | LowPriority | HighPriority | InProgress | Finished |
|
| Backlog | LowPriority | HighPriority | InProgress | Finished |
|
||||||
|--------------------------------+--------------------------------+--------------------------------+------------+--------------------------------|
|
|-------------------------+--------------------------------+--------------------------------+--------------------------------+--------------------------------|
|
||||||
| [[/home/alicia/git/pluralshit/TODO.org::separate memberlist into its own code block in the readme][separate memberlist into its o]] | [[/home/alicia/git/pluralshit/TODO.org::Add `add` command \[0/2\]][Add `add` command {0/2}]] | [[/home/alicia/git/pluralshit/TODO.org::Add `set` command \[2/3\]][Add `set` command {2/3}]] | | [[/home/alicia/git/pluralshit/TODO.org::Add `sync` command][Add `sync` command]] |
|
| [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add empty][{SET} Add empty]] | [[/home/alicia/git/pluralshit/TODO.org::Get fronters handles the front file][Get fronters handles the front]] | [[/home/alicia/git/pluralshit/TODO.org::Add `set` command \[2/3\]][Add `set` command {2/3}]] | [[/home/alicia/git/pluralshit/TODO.org::Add `get` command][Add `get` command]] | [[/home/alicia/git/pluralshit/TODO.org::Add `sync` command][Add `sync` command]] |
|
||||||
| | [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add empty][{ADD} Add empty]] | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add empty][{SET} Add empty]] | | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add set][{SET} Add set]] |
|
| [[/home/alicia/git/pluralshit/TODO.org::Add `add` command \[0/2\]][Add `add` command {0/2}]] | | [[/home/alicia/git/pluralshit/TODO.org::Check for mismatch in fronting between pluralkit and simplyplural][Check for mismatch in fronting]] | [[/home/alicia/git/pluralshit/TODO.org::Set simplyplural][Set simplyplural]] | [[/home/alicia/git/pluralshit/TODO.org::\[SET\] Add set][{SET} Add set]] |
|
||||||
| | [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add set][{ADD} Add set]] | [[/home/alicia/git/pluralshit/TODO.org::Add `get` command][Add `get` command]] | | [[/home/alicia/git/pluralshit/TODO.org::Adapt to set multiple arguments][Adapt to set multiple argument]] |
|
| [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add empty][{ADD} Add empty]] | | [[/home/alicia/git/pluralshit/TODO.org::Rofi stuff][Rofi stuff]] | [[/home/alicia/git/pluralshit/TODO.org::Check if member is currently fronting and just add if not, remove the ones who do not][Check if member is currently f]] | [[/home/alicia/git/pluralshit/TODO.org::Adapt to set multiple arguments][Adapt to set multiple argument]] |
|
||||||
| | [[/home/alicia/git/pluralshit/TODO.org::Add `setgroup` command][Add `setgroup` command]] | [[/home/alicia/git/pluralshit/TODO.org::Compare if sent members are currently fronting and keep them otherwise add to fronting array][Compare if sent members are cu]] | | [[/home/alicia/git/pluralshit/TODO.org::Add `memberlist` command][Add `memberlist` command]] |
|
| [[/home/alicia/git/pluralshit/TODO.org::\[ADD\] Add set][{ADD} Add set]] | | | | [[/home/alicia/git/pluralshit/TODO.org::Add `memberlist` command][Add `memberlist` command]] |
|
||||||
| | [[/home/alicia/git/pluralshit/TODO.org::Get fronters handles the front file][Get fronters handles the front]] | [[/home/alicia/git/pluralshit/TODO.org::Check for mismatch in fronting between pluralkit and simplyplural][Check for mismatch in fronting]] | | [[/home/alicia/git/pluralshit/TODO.org::Add new function to get the config create empty in path if not exists][Add new function to get the co]] |
|
| [[/home/alicia/git/pluralshit/TODO.org::do it proper][do it proper]] | | | | [[/home/alicia/git/pluralshit/TODO.org::Add new function to get the config create empty in path if not exists][Add new function to get the co]] |
|
||||||
| | | [[/home/alicia/git/pluralshit/TODO.org::Rofi stuff][Rofi stuff]] | | [[/home/alicia/git/pluralshit/TODO.org::`Get system` if Value::Null sync and load json][`Get system` if Value::Null sy]] |
|
| | | | | [[/home/alicia/git/pluralshit/TODO.org::`Get system` if Value::Null sync and load json][`Get system` if Value::Null sy]] |
|
||||||
| | | | | [[/home/alicia/git/pluralshit/TODO.org::Get current front][Get current front]] |
|
| | | | | [[/home/alicia/git/pluralshit/TODO.org::Get current front][Get current front]] |
|
||||||
| | | | | [[/home/alicia/git/pluralshit/TODO.org::http PATCH request][http PATCH request]] |
|
| | | | | [[/home/alicia/git/pluralshit/TODO.org::http PATCH request][http PATCH request]] |
|
||||||
| | | | | [[/home/alicia/git/pluralshit/TODO.org::http POST request][http POST request]] |
|
| | | | | [[/home/alicia/git/pluralshit/TODO.org::http POST request][http POST request]] |
|
||||||
| | | | | [[/home/alicia/git/pluralshit/TODO.org::Set members know the alias][Set members know the alias]] |
|
| | | | | [[/home/alicia/git/pluralshit/TODO.org::Set members know the alias][Set members know the alias]] |
|
||||||
| | | | | |
|
| | | | | [[/home/alicia/git/pluralshit/TODO.org::Compare if sent members are currently fronting and keep them otherwise add to fronting array][Compare if sent members are cu]] |
|
||||||
| | | | | |
|
| | | | | [[/home/alicia/git/pluralshit/TODO.org::Separate memberlist into its own code block in the readme][Separate memberlist into its o]] |
|
||||||
| | | | | |
|
| | | | | |
|
||||||
| | | | | |
|
| | | | | |
|
||||||
| | | | | |
|
| | | | | |
|
||||||
|
|
66
src/main.rs
66
src/main.rs
|
@ -32,6 +32,7 @@ struct System {
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
#[derive(PartialEq)]
|
||||||
struct Member {
|
struct Member {
|
||||||
pk_id: String,
|
pk_id: String,
|
||||||
sp_id: String,
|
sp_id: String,
|
||||||
|
@ -63,6 +64,7 @@ fn main() {
|
||||||
//set_empty(config_path);
|
//set_empty(config_path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
//"get" => get(config_path),
|
||||||
"memberlist" => memberlist(config_path),
|
"memberlist" => memberlist(config_path),
|
||||||
&_ => println!("Invalid command"),
|
&_ => println!("Invalid command"),
|
||||||
}
|
}
|
||||||
|
@ -161,12 +163,13 @@ fn set_member(config_path: String, tf_members: &[String]) -> Result<(), &'static
|
||||||
}
|
}
|
||||||
if to_front.len() != 0 {
|
if to_front.len() != 0 {
|
||||||
let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system);
|
let fronters = get_fronters(&config["pk_key"].as_str().unwrap(), &config["sp_key"].as_str().unwrap(), &system);
|
||||||
|
|
||||||
pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters);
|
pk_set_fronters(&config["pk_key"].as_str().unwrap(), &system, to_front, &fronters);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
// Set member:1 ends here
|
||||||
|
|
||||||
|
// [[file:../README.org::*Memberlist][Memberlist:1]]
|
||||||
fn memberlist(config_path: String) {
|
fn memberlist(config_path: String) {
|
||||||
let sys = get_system(&config_path);
|
let sys = get_system(&config_path);
|
||||||
|
|
||||||
|
@ -179,7 +182,7 @@ fn memberlist(config_path: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Set member:1 ends here
|
// Memberlist:1 ends here
|
||||||
|
|
||||||
// [[file:../README.org::*Get system][Get system:1]]
|
// [[file:../README.org::*Get system][Get system:1]]
|
||||||
fn pk_get_system(key: &str) -> Value {
|
fn pk_get_system(key: &str) -> Value {
|
||||||
|
@ -188,7 +191,9 @@ fn pk_get_system(key: &str) -> Value {
|
||||||
let res = http_get_request(url,key);
|
let res = http_get_request(url,key);
|
||||||
return serde_json::from_str(&res.unwrap()).unwrap();
|
return serde_json::from_str(&res.unwrap()).unwrap();
|
||||||
}
|
}
|
||||||
|
// Get system:1 ends here
|
||||||
|
|
||||||
|
// [[file:../README.org::*Get members][Get members:1]]
|
||||||
fn pk_get_members(key: &str, sysid: &str) -> Vec<Value> {
|
fn pk_get_members(key: &str, sysid: &str) -> Vec<Value> {
|
||||||
let url = format!("{}/systems/{}/members", PK_URL, sysid);
|
let url = format!("{}/systems/{}/members", PK_URL, sysid);
|
||||||
|
|
||||||
|
@ -197,43 +202,27 @@ fn pk_get_members(key: &str, sysid: &str) -> Vec<Value> {
|
||||||
|
|
||||||
return datas;
|
return datas;
|
||||||
}
|
}
|
||||||
// Get system:1 ends here
|
// Get members:1 ends here
|
||||||
|
|
||||||
// [[file:../README.org::*Get fronters][Get fronters:1]]
|
// [[file:../README.org::*Get fronters][Get fronters:1]]
|
||||||
fn pk_get_fronters(key: &str, sys: &System) -> Vec<Member> {
|
fn sp_get_fronters(key: &str, sys: &System) -> Vec<Member> {
|
||||||
let url = format!("{}/systems/{}/fronters", PK_URL, sys.pk_userid);
|
let url = format!("{}/fronters", SP_URL);
|
||||||
|
|
||||||
let res = http_get_request(url,key);
|
let res = http_get_request(url,key);
|
||||||
let data: Value = serde_json::from_str(&res.unwrap()).unwrap();
|
let datas: Vec<Value> = serde_json::from_str(&res.unwrap()).unwrap();
|
||||||
let memberdata = &data["members"].as_array();
|
|
||||||
|
|
||||||
let mut members: Vec<Member> = Vec::new();
|
let mut members: Vec<Member> = Vec::new();
|
||||||
for member in memberdata {
|
for data in datas {
|
||||||
for m in member.into_iter() {
|
let sp_id = &data["content"]["member"].as_str().unwrap();
|
||||||
for dbmem in &sys.members {
|
for member in &sys.members {
|
||||||
if m["name"].as_str().unwrap() == dbmem.name {
|
if &member.sp_id == sp_id {
|
||||||
members.push(dbmem.clone());
|
members.push(member.clone());
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pk_set_fronters(key: &str, sys: &System, to_front: Vec<Member>, _fronters: &HashMap<String, Vec<Member>>) {
|
|
||||||
let url = format!("{}/systems/{}/switches", PK_URL, sys.pk_userid);
|
|
||||||
|
|
||||||
// if not fronting
|
|
||||||
|
|
||||||
let mut frontcodes = Vec::new();
|
|
||||||
for tf in to_front {
|
|
||||||
frontcodes.push(tf.pk_id);
|
|
||||||
}
|
|
||||||
let mut body: HashMap<&str, Vec<String>> = HashMap::new();
|
|
||||||
body.insert("members", frontcodes);
|
|
||||||
let _ = http_post_request(url, key, &body);
|
|
||||||
}
|
|
||||||
// Get fronters:1 ends here
|
// Get fronters:1 ends here
|
||||||
|
|
||||||
// [[file:../README.org::*Get user ID][Get user ID:1]]
|
// [[file:../README.org::*Get user ID][Get user ID:1]]
|
||||||
|
@ -278,20 +267,22 @@ fn get_sp_id(mem: &Member, ids: &HashMap<String, String>) -> String {
|
||||||
// Get ID from member:1 ends here
|
// Get ID from member:1 ends here
|
||||||
|
|
||||||
// [[file:../README.org::*Get fronters][Get fronters:1]]
|
// [[file:../README.org::*Get fronters][Get fronters:1]]
|
||||||
fn sp_get_fronters(key: &str, sys: &System) -> Vec<Member> {
|
fn sp_get_fronters(key: &str, sys: &System) -> Vec<String> {
|
||||||
let url = format!("{}/fronters", SP_URL);
|
let url = format!("{}/fronters", SP_URL);
|
||||||
|
|
||||||
let res = http_get_request(url,key);
|
let res = http_get_request(url,key);
|
||||||
let datas: Vec<Value> = serde_json::from_str(&res.unwrap()).unwrap();
|
let datas: Vec<Value> = serde_json::from_str(&res.unwrap()).unwrap();
|
||||||
|
|
||||||
let mut members: Vec<Member> = Vec::new();
|
let mut members: Vec<String> = Vec::new();
|
||||||
for data in datas {
|
for data in datas {
|
||||||
let sp_id = &data["content"]["member"].as_str().unwrap();
|
let sp_id = &data["content"]["member"].as_str().unwrap();
|
||||||
|
let mut push_name = String::new();
|
||||||
for member in &sys.members {
|
for member in &sys.members {
|
||||||
if &member.sp_id == sp_id {
|
if &member.sp_id == sp_id {
|
||||||
members.push(member.clone());
|
push_name = String::from(&member.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
members.push(push_name);
|
||||||
|
|
||||||
}
|
}
|
||||||
return members;
|
return members;
|
||||||
|
@ -360,7 +351,9 @@ fn get_system(config_path: &str) -> System {
|
||||||
return sys;
|
return sys;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// Get system json:1 ends here
|
||||||
|
|
||||||
|
// [[file:../README.org::*Get fronters][Get fronters:1]]
|
||||||
fn get_fronters(pk_key: &str, sp_key: &str, sys: &System) -> HashMap<String, Vec<Member>> {
|
fn get_fronters(pk_key: &str, sp_key: &str, sys: &System) -> HashMap<String, Vec<Member>> {
|
||||||
let mut fronters: HashMap<String, Vec<Member>> = HashMap::new();
|
let mut fronters: HashMap<String, Vec<Member>> = HashMap::new();
|
||||||
fronters.insert(String::from("pk"), pk_get_fronters(pk_key, sys));
|
fronters.insert(String::from("pk"), pk_get_fronters(pk_key, sys));
|
||||||
|
@ -368,9 +361,9 @@ fn get_fronters(pk_key: &str, sp_key: &str, sys: &System) -> HashMap<String, Vec
|
||||||
|
|
||||||
return fronters;
|
return fronters;
|
||||||
}
|
}
|
||||||
// Get system json:1 ends here
|
// Get fronters:1 ends here
|
||||||
|
|
||||||
// [[file:../README.org::*Http Request handler][Http Request handler:1]]
|
// [[file:../README.org::*Get request][Get request:1]]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn http_get_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
async fn http_get_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
@ -384,8 +377,9 @@ async fn http_get_request(url: String, key: &str) -> Result<String, Box<dyn std:
|
||||||
.await?;
|
.await?;
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
// Get request:1 ends here
|
||||||
|
|
||||||
|
// [[file:../README.org::*Post request][Post request:1]]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn http_post_request(url: String, key: &str, body: &HashMap<&str, Vec<String>>) -> Result<(), Box<dyn std::error::Error>> {
|
async fn http_post_request(url: String, key: &str, body: &HashMap<&str, Vec<String>>) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
@ -398,7 +392,9 @@ async fn http_post_request(url: String, key: &str, body: &HashMap<&str, Vec<Stri
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
// Post request:1 ends here
|
||||||
|
|
||||||
|
// [[file:../README.org::*Patch request][Patch request:1]]
|
||||||
/*
|
/*
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn http_patch_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
async fn http_patch_request(url: String, key: &str) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
|
@ -415,4 +411,4 @@ async fn http_patch_request(url: String, key: &str) -> Result<String, Box<dyn st
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
// Http Request handler:1 ends here
|
// Patch request:1 ends here
|
||||||
|
|
Loading…
Reference in New Issue