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