Class: ActiveNotifier::NotifierAdapters::Dingtalk
- Inherits:
-
ActiveAdapter::Implement
- Object
- ActiveAdapter::Implement
- ActiveNotifier::NotifierAdapters::Dingtalk
- Defined in:
- lib/active_notifier/notifier_adapters/dingtalk.rb
Overview
Dingtalk implement for ActiveNotifier::Notifier adapter
Constant Summary collapse
- VALID_TYPES =
%i[text markdown].freeze
Instance Method Summary collapse
-
#notify(token, type, message, **options) ⇒ Object
abstract
Notify message.
Instance Method Details
#notify(token, type, message, **options) ⇒ Object
This method is abstract.
Implement through setting a real adapter, like :dingtalk
Notify message
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_notifier/notifier_adapters/dingtalk.rb', line 11 def notify(token, type, , **) webhook = "#{ActiveNotifier.config.adapters_with_base_url.fetch(:dingtalk)}#{token}" unless VALID_TYPES.include?(type) = "The Dingtalk adapter only support types: #{VALID_TYPES.join(', ')}" raise ActiveNotifier::AdapterError, end if .empty? = "Message of the Dingtalk adapter can't be blank, please check template file" raise ActiveNotifier::AdapterError, end body = get_body(type, , **) headers = { "Content-Type" => "application/json", "Accept" => "application/json" } Net::HTTP.post(URI(webhook), body.to_json, headers) end |