Module: Dingtalk::Client::GroupRobotClient::NotifyFeedcard

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

Overview

Instance Method Summary collapse

Instance Method Details

#notify_feedcard(code, links) ⇒ Object

Parameters:

  • code (Symbol)

    set token_code and template_file

  • links (Array<Hash>, Hash)


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dingtalk/client/group_robot_client/notify_feedcard.rb', line 10

def notify_feedcard(code, links)
  token_code = code.to_sym
  token = fetch_token(token_code)
  links = Array.wrap(links).map do |link|
    Hash(link).symbolize_keys.tap do |hash|
      required_keys = %i[title messageURL picURL]
      keys_valid = required_keys.all? { |arg| hash[arg].present? }
      raise ArgumentError, "links requires these keys present: #{required_keys.join(', ')}" unless keys_valid
    end
  end
  body = get_feedcard_body(links)
  notify(token, body)
end