Class: Dingtalk::Robot::TextStrategy
- Inherits:
-
Object
- Object
- Dingtalk::Robot::TextStrategy
- Defined in:
- lib/dingtalk/robot/strategies/text_strategy.rb
Overview
Text type strategy for sending message
Instance Method Summary collapse
-
#initialize(webhook_url, message) ⇒ TextStrategy
constructor
A new instance of TextStrategy.
- #notify(**options) ⇒ Object
Constructor Details
#initialize(webhook_url, message) ⇒ TextStrategy
Returns a new instance of TextStrategy.
7 8 9 10 |
# File 'lib/dingtalk/robot/strategies/text_strategy.rb', line 7 def initialize(webhook_url, ) @webhook_url = webhook_url = end |
Instance Method Details
#notify(**options) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/dingtalk/robot/strategies/text_strategy.rb', line 14 def notify(**) at_mobiles = [:at_mobiles].to_a is_at_all = [:is_at_all] ? true : false body = generate_body(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 |