Module: Dingtalk::Client::GroupRobotClient::NotifyText

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

Overview

Instance Method Summary collapse

Instance Method Details

#notify_text(code, content, **options) ⇒ Object

Parameters:

  • code (Symbol)

    set token_code and template_file

  • content (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: []


13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/dingtalk/client/group_robot_client/notify_text.rb', line 13

def notify_text(code, content, **options)
  options.with_defaults!(
    is_at_all: false,
    at_mobiles: []
  )
  token_code = code.to_sym
  token = fetch_token(token_code)
  content = String(content)
  is_at_all = is_at_all != false
  at_mobiles = Array(at_mobiles)
  body = get_text_body(content, is_at_all, at_mobiles)
  notify(token, body)
end