@@ -8,36 +8,42 @@ This is a library for [Rust](https://www.rust-lang.org/) to support building mes
88Using this, you can build any messages in type-safe way like following.
99
1010``` rust
11- use slack_messaging :: Message ;
11+ use slack_messaging :: {mrkdwn, Message } ;
1212use slack_messaging :: blocks :: {elements :: Button , Actions , Section };
1313
1414#[tokio:: main]
1515async fn main () {
16- let message = Message :: new ()
17- . push_block (
18- Section :: new ()
19- . set_text_mrkdwn (" You have a new request:\ n *<fakeLink.toEmployeeProfile.com|Fred Enriquez - New device request>*" )
16+ let message = Message :: builder ()
17+ . block (
18+ Section :: builder ()
19+ . text (mrkdwn! (" You have a new request:\ n *<fakeLink.toEmployeeProfile.com|Fred Enriquez - New device request>*" ))
20+ . build ()
2021 )
21- . push_block (
22- Section :: new ()
23- . push_field_mrkdwn (" *Type:*\ n Computer (laptop)" )
24- . push_field_mrkdwn (" *When:*\ n Submitted Aut 10" )
22+ . block (
23+ Section :: builder ()
24+ . field (mrkdwn! (" *Type:*\ n Computer (laptop)" ))
25+ . field (mrkdwn! (" *When:*\ n Submitted Aug 10" ))
26+ . build ()
2527 )
26- . push_block (
27- Actions :: new ()
28- . push_element (
29- Button :: new ()
28+ . block (
29+ Actions :: builder ()
30+ . element (
31+ Button :: builder ()
3032 . text (" Approve" )
31- . set_value (" approve" )
32- . set_primary ()
33+ . value (" approve" )
34+ . primary ()
35+ . build ()
3336 )
34- . push_element (
35- Button :: new ()
37+ . element (
38+ Button :: builder ()
3639 . text (" Deny" )
37- . set_value (" deny" )
38- . set_danger ()
40+ . value (" deny" )
41+ . danger ()
42+ . build ()
3943 )
40- );
44+ . build ()
45+ )
46+ . build ();
4147
4248 let req = reqwest :: Client :: new ()
4349 . post (" https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX" )
@@ -70,7 +76,7 @@ The message payload of the above example is following.
7076 },
7177 {
7278 "type" : " mrkdwn" ,
73- "text" : " *When:*\n Submitted Aut 10"
79+ "text" : " *When:*\n Submitted Aug 10"
7480 }
7581 ]
7682 },
@@ -81,8 +87,7 @@ The message payload of the above example is following.
8187 "type" : " button" ,
8288 "text" : {
8389 "type" : " plain_text" ,
84- "text" : " Approve" ,
85- "emoji" : true
90+ "text" : " Approve"
8691 },
8792 "value" : " approve" ,
8893 "style" : " primary"
@@ -91,8 +96,7 @@ The message payload of the above example is following.
9196 "type" : " button" ,
9297 "text" : {
9398 "type" : " plain_text" ,
94- "text" : " Deny" ,
95- "emoji" : true
99+ "text" : " Deny"
96100 },
97101 "value" : " deny" ,
98102 "style" : " danger"
0 commit comments