Module: Dingtalk::Client::GroupRobotClient::NotifyMarkdown

Included in:
Dingtalk::Client::GroupRobotClient
Defined in:
lib/dingtalk/client/group_robot_client/notify_markdown.rb

Overview

Instance Method Summary collapse

Instance Method Details

#notify_markdown(code, title, **options) { ... } ⇒ Object

Parameters:

  • code (Symbol)

    set token_code and template_file

  • title (String)
  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • template_file (String) — default: code

    without file suffix

  • is_at_all (Boolean) — default: false
  • at_mobiles (Array) — default: []

Yields:

  • a block which will execute in template locale environment



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dingtalk/client/group_robot_client/notify_markdown.rb', line 14

def notify_markdown(code, title, **options, &block)
  options.with_defaults!(
    template_file: code,
    is_at_all: false,
    at_mobiles: []
  )
  token_code = code.to_sym
  token = fetch_token(token_code)
  title = String(title)
  template_file = String(options[:template_file])
  is_at_all = is_at_all != false
  at_mobiles = Array(at_mobiles)
  content = get_markdown_content(template_file, &block)
  body = get_markdown_body(title, content, is_at_all, at_mobiles)
  notify(token, body)
end