Sha256: 4b023bb4a5bc37d863e96d90b2d2d11457bf4b052294bcb8d3ca21705f68d08e

Contents?: true

Size: 1.79 KB

Versions: 13

Compression:

Stored size: 1.79 KB

Contents

# This file was auto-generated by lib/tasks/web.rake

module Slack
  module Web
    module Api
      module Endpoints
        module <%= group.gsub(".", "_").camelize %>
<% names.each_with_index do |(name, data), index| %>
<% next if data['mixin'] %>
<% if index > 0 %>

<% end %>
          #
<% data['desc'].split("\n").each do |line| %>
          # <%= line %>
<% end %>
          #
<% data['args'].each do |arg_name, arg_v| %>
          # @option options [<%= arg_v['type'] %>] :<%= arg_name %>
<% arg_v['desc'].lines.each do |l| %>
<% if l.strip.length > 0 %>
          #   <%= l.strip %>
<% else %>
          #
<% end %>
<% end %>
<% end %>
          # @see https://api.slack.com/methods/<%= group %>.<%= name %>
          # @see https://github.com/dblock/slack-api-ref/blob/master/methods/<%= group %>/<%= group %>.<%= name %>.json
          def <%= group.gsub(".", "_") %>_<%= name %>(options = {})
<% data['args'].select{ |k, v| v['required'] }.each do |arg_name, arg_v| %>
            throw ArgumentError.new('Required arguments :<%= arg_name %> missing') if options[:<%= arg_name %>].nil?
<% end %>
<% if data['group'] == 'groups' && data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
            options = options.merge(channel: groups_id(options)['group']['id']) if options[:channel]
<% elsif data['args']['channel'] && !data['args']['channel']['desc'].include?('Can be an encoded ID, or a name.') %>
            options = options.merge(channel: channels_id(options)['channel']['id']) if options[:channel]
<% end %>
<% if data['args']['user'] %>
            options = options.merge(user: users_id(options)['user']['id']) if options[:user]
<% end %>
            post('<%= group %>.<%= name %>', options)
          end
<% end %>
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
slack-ruby-client-0.9.1 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.9.0 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.8.1 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.8.0 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.9 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.8 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.7 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.6 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.5 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.4 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.3 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.2 lib/slack/web/api/templates/method.erb
slack-ruby-client-0.7.1 lib/slack/web/api/templates/method.erb