a simple lib binding to the ifttt's webhook api.
there is a async interface can be activate in feature non-blocking
.
and a time delay trigger function for delay the trigger in feature delay
.
the blocking interface use ureq, and the non-blocking interface use reqwest internally.
about ifttt webhook usage: For example,You can call a url (supplied by ifttt) then receive a notification (could include data* you supplied) on you phone.
*sometimes you can set some json data (up to three fields in it) inside the request, which is depends on the service webhook connected with.
find on crates.io
use cargo-edit
sh
cargo add ift-webhook
code ```rust extern crate ift-webhook extern crate dotenv use ift_webhook::*
dotenv::dotenv().unwrap(); let eventname = dotenv::var("EVENT").unwrap(); let apikey = dotenv::var("KEY").unwrap(); let client = IftWHClient::new(&apikey); let data = WebHookData::new(Some("test1"), Some("test2"), Some("test3")); let res = client.trigger(&eventname, data); assert!(res.is_ok()) ```
Cargo.toml
toml
ift-webhook={version=*,default-features= false,features=["non-blocking"]}
code
```rust
extern crate ift-webhook
extern crate dotenv
use ift_webhook::*
dotenv::dotenv().unwrap(); let eventname = dotenv::var("EVENT").unwrap(); let apikey = dotenv::var("KEY").unwrap(); let client = AsyncIftWHClient::new(&apikey); let res = client.trigger(&eventname, None).await; assert!(res.is_ok()) ```
Cargo.toml
toml
ift-webhook={version=*,default-features= false,features=["delay"]}
code
```rust
extern crate ift-webhook
extern crate dotenv
use ift_webhook::*
dotenv::dotenv().unwrap(); let eventname = dotenv::var("EVENT").unwrap(); let apikey = dotenv::var("KEY").unwrap(); let client = AsyncIftWHClient::new(&apikey); let reshandler: DelayResultHandler = client.triggerwithdelay(&eventname, None, std::time::Duration::fromsecs(5)); ///do something else let res = reshandler.await; assert!(res.isok()) ```