Skip to content

Commit

Permalink
Merge pull request #7 from kaicoh/release/v0.3.0
Browse files Browse the repository at this point in the history
v0.3.0
  • Loading branch information
kaicoh committed Apr 8, 2024
2 parents 5f75a14 + 0b52276 commit 7bc49b6
Show file tree
Hide file tree
Showing 140 changed files with 20,402 additions and 11,279 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [0.3.0][] - 2024-04-09

- https://github.com/kaicoh/slack-messaging/pull/8 Builder pattern.
- https://github.com/kaicoh/slack-messaging/pull/8 Remove `Attachment` (since it's a deprecated legacy feature).
- https://github.com/kaicoh/slack-messaging/pull/8 Support `Rich text` block.

## [0.2.2][] - 2023-03-02

- https://github.com/kaicoh/slack-messaging/pull/6 Add `mrkdwn` and `plain_text` macros.
Expand All @@ -16,6 +22,7 @@

- pre-release

[0.3.0]: https://github.com/kaicoh/slack-messaging/releases/v0.3.0
[0.2.2]: https://github.com/kaicoh/slack-messaging/releases/v0.2.2
[0.2.1]: https://github.com/kaicoh/slack-messaging/releases/v0.2.1
[0.2.0]: https://github.com/kaicoh/slack-messaging/releases/v0.2.0
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "slack-messaging"
version = "0.2.2"
version = "0.3.0"
authors = ["kaicoh <[email protected]>"]
edition = "2021"
keywords = ["slack", "messaging", "webhook"]
Expand All @@ -17,10 +17,10 @@ all-features = true
chrono = { version = "0.4", optional = true }
regex = { version = "1.7", optional = true }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"

[dev-dependencies]
reqwest = { version = "0.11", features = ["json"] }
serde_json = "1.0"
tokio = { version = "1", features = ["full"] }

[features]
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Kanji Tanaka
Copyright (c) 2024 Kanji Tanaka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
54 changes: 29 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,42 @@ This is a library for [Rust](https://www.rust-lang.org/) to support building mes
Using this, you can build any messages in type-safe way like following.

```rust
use slack_messaging::Message;
use slack_messaging::{mrkdwn, Message};
use slack_messaging::blocks::{elements::Button, Actions, Section};

#[tokio::main]
async fn main() {
let message = Message::new()
.push_block(
Section::new()
.set_text_mrkdwn("You have a new request:\n*<fakeLink.toEmployeeProfile.com|Fred Enriquez - New device request>*")
let message = Message::builder()
.block(
Section::builder()
.text(mrkdwn!("You have a new request:\n*<fakeLink.toEmployeeProfile.com|Fred Enriquez - New device request>*"))
.build()
)
.push_block(
Section::new()
.push_field_mrkdwn("*Type:*\nComputer (laptop)")
.push_field_mrkdwn("*When:*\nSubmitted Aut 10")
.block(
Section::builder()
.field(mrkdwn!("*Type:*\nComputer (laptop)"))
.field(mrkdwn!("*When:*\nSubmitted Aug 10"))
.build()
)
.push_block(
Actions::new()
.push_element(
Button::new()
.block(
Actions::builder()
.element(
Button::builder()
.text("Approve")
.set_value("approve")
.set_primary()
.value("approve")
.primary()
.build()
)
.push_element(
Button::new()
.element(
Button::builder()
.text("Deny")
.set_value("deny")
.set_danger()
.value("deny")
.danger()
.build()
)
);
.build()
)
.build();

let req = reqwest::Client::new()
.post("https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
Expand Down Expand Up @@ -70,7 +76,7 @@ The message payload of the above example is following.
},
{
"type": "mrkdwn",
"text": "*When:*\nSubmitted Aut 10"
"text": "*When:*\nSubmitted Aug 10"
}
]
},
Expand All @@ -81,8 +87,7 @@ The message payload of the above example is following.
"type": "button",
"text": {
"type": "plain_text",
"text": "Approve",
"emoji": true
"text": "Approve"
},
"value": "approve",
"style": "primary"
Expand All @@ -91,8 +96,7 @@ The message payload of the above example is following.
"type": "button",
"text": {
"type": "plain_text",
"text": "Deny",
"emoji": true
"text": "Deny"
},
"value": "deny",
"style": "danger"
Expand Down
250 changes: 0 additions & 250 deletions src/attachment.rs

This file was deleted.

Loading

0 comments on commit 7bc49b6

Please sign in to comment.