Sha256: 5ca9da511e03346a9984b72987fb03d173c01fcf94899f3a55c7dfeba5eade2a
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# This file was auto-generated by lib/generators/tasks/generate.rb module Slack module Endpoint module <%= group.capitalize %> <% names.each do |name, data| %> # <% data["desc"].lines.each do |l| %> # <%= l.strip %> <% end %> # <% data["args"].reject{|k, v| k=="token"}.each do |arg_name, arg_v| %> # @option options [<%= arg_v["type"] %>] :<%= arg_name %> <% arg_v["desc"].lines.each do |l| %> # <%= l.strip %> <% end %> <% end %> # @see https://api.slack.com/methods/<%= group %>.<%= name %> # @see https://github.com/aki017/slack-api-docs/blob/master/methods/<%= group %>.<%= name %>.md # @see https://github.com/aki017/slack-api-docs/blob/master/methods/<%= group %>.<%= name %>.json def <%= group %>_<%= name %>(options={}) <% data["args"].reject{|k, v| k=="token"}.select{|k,v| v["required"]}.each do |arg_name, arg_v| %> <% if group == "chat" && name == "postMessage" && arg_name == "text" %> throw ArgumentError.new("Required arguments :text or :attachments missing") if options[:<%= arg_name %>].nil? && options[:attachments].nil? <% next %> <% end %> throw ArgumentError.new("Required arguments :<%= arg_name %> missing") if options[:<%= arg_name %>].nil? <% end %> <% if data["args"].key? "attachments" %> options[:attachments] = options[:attachments].to_json if options[:attachments].is_a?(Array) || options[:attachments].is_a?(Hash) <% end %> post("<%= group %>.<%= name %>", options) end <% end %> end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
slack-api-1.5.0 | lib/generators/templates/method.rb.erb |