summaryrefslogtreecommitdiff
path: root/lib/mattermost/command.rb
blob: 108a2a47a4bd5d7ce6e8e317099c63d9a3552c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Mattermost
  class Command < Session
    def self.create(team_id, trigger: 'gitlab', url:, icon_url:)
      command = {
        auto_complete: true,
        auto_complete_desc: 'List all available commands',
        auto_complete_hint: '[help]',
        description: 'Perform common operations on GitLab',
        display_name: 'GitLab Slash Commands',
        method: 'P',
        user_name: 'GitLab',
        trigger: trigger,
        url: url,
        icon_url: icon_url
      }

      response = post( "/teams/#{team_id}/commands/create", body: command.to_json)

      response.parsed_response['token']
    end
  end
end