check_connection/
check_connection.rs1use dotenv::dotenv;
2use rujira::*;
3use serde_json::json;
4use tracing_subscriber::{fmt, EnvFilter};
5
6#[tokio::main]
7async fn main() {
8 dotenv().ok();
9 fmt()
10 .with_env_filter(EnvFilter::from_default_env())
11 .compact()
12 .init();
13 let bot = Rujira::new().from_env_handler();
14 let Ok(me) = crate::api::myself::get(bot.clone()).apply().await else {
15 todo!()
16 };
17 tracing::debug!(?me);
18 let Some(name) = me.data["displayName"].as_str() else {
19 todo!()
20 };
21 let Ok(project) = crate::api::project::create(bot.clone(), "ITMG", "iTmage", "software", name)
22 .add_payload("description", json!("Custom field added by bot"))
23 .apply()
24 .await
25 else {
26 todo!()
27 };
28 tracing::debug!(?project);
29 let fields = json!({
30 "project": { "key": "ITMG" },
31 "summary": "BOT: added a new feature.",
32 "description": "This task was generated by the bot when creating changes in the repository.",
33 "issuetype": { "name": "Task" },
34 });
35 let Ok(issue) = crate::api::issue::create(bot.clone(), fields, false)
36 .apply()
37 .await
38 else {
39 todo!()
40 };
41 tracing::debug!(?issue);
42 let project = crate::api::project::delete(bot.clone(), "ITMG")
43 .apply()
44 .await;
45 tracing::debug!(?project);
46}