Class: Dingtalk::Robot::FeedCardStrategy
- Inherits:
-
Object
- Object
- Dingtalk::Robot::FeedCardStrategy
- Defined in:
- lib/dingtalk/robot/strategies/feed_card_strategy.rb
Overview
Markdown type strategy for sending message
Defined Under Namespace
Classes: Link
Instance Method Summary collapse
-
#initialize(webhook_url, message) ⇒ FeedCardStrategy
constructor
A new instance of FeedCardStrategy.
- #notify(**options) ⇒ Object
Constructor Details
#initialize(webhook_url, message) ⇒ FeedCardStrategy
Returns a new instance of FeedCardStrategy.
9 10 11 12 |
# File 'lib/dingtalk/robot/strategies/feed_card_strategy.rb', line 9 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 |
# File 'lib/dingtalk/robot/strategies/feed_card_strategy.rb', line 15 def notify(**) links = Array.wrap([:links]) all_present = links.all? { |link| link.all?(&:present?) } raise ArgumentError, 'All items of links must be present, strategy: feed_card' unless all_present body = generate_body(links) headers = { 'Content-Type': 'application/json', Accept: 'application/json' } Net::HTTP.post(URI(webhook_url), body.to_json, headers).body end |