Class: Dingtalk::Robot::MarkdownStrategy
- Inherits:
-
Object
- Object
- Dingtalk::Robot::MarkdownStrategy
- Defined in:
- lib/dingtalk/robot/strategies/markdown_strategy.rb
Overview
Markdown type strategy for sending message
Instance Method Summary collapse
-
#initialize(webhook_url, message) ⇒ MarkdownStrategy
constructor
A new instance of MarkdownStrategy.
- #notify(**options) ⇒ Object
Constructor Details
#initialize(webhook_url, message) ⇒ MarkdownStrategy
Returns a new instance of MarkdownStrategy.
7 8 9 10 |
# File 'lib/dingtalk/robot/strategies/markdown_strategy.rb', line 7 def initialize(webhook_url, ) @webhook_url = webhook_url @message = end |
Instance Method Details
#notify(**options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/dingtalk/robot/strategies/markdown_strategy.rb', line 15 def notify(**) title = [:title].to_s raise ArgumentError, 'title must be present, strategy: markdown' if title.empty? at_mobiles = [:at_mobiles].to_a is_at_all = [:is_at_all] ? true : false body = generate_body(title, at_mobiles, is_at_all) headers = { 'Content-Type': 'application/json', Accept: 'application/json' } Net::HTTP.post(URI(webhook_url), body.to_json, headers).body end |