summaryrefslogtreecommitdiff
path: root/lib/mattermost/command.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-12-15 20:19:42 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 12:31:51 +0100
commit0045996728308bcb7643618ab48efb7e04e7d4bf (patch)
tree91041209a3f78164afb0598f82ec9fc14667f968 /lib/mattermost/command.rb
parent99d8d6f0d48e28f5ba798d1d4461071a01435054 (diff)
downloadgitlab-ce-0045996728308bcb7643618ab48efb7e04e7d4bf.tar.gz
Add auto configure of commands
Diffstat (limited to 'lib/mattermost/command.rb')
-rw-r--r--lib/mattermost/command.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb
index e159458a788..b6446935eb6 100644
--- a/lib/mattermost/command.rb
+++ b/lib/mattermost/command.rb
@@ -1,7 +1,7 @@
module Mattermost
- class Command
+ class Command < Session
def self.all(team_id)
- Mattermost::Mattermost.get("/teams/#{team_id}/commands/list_team_commands")
+ get("/teams/#{team_id}/commands/list_team_commands").parsed_response
end
# params should be a hash, which supplies _at least_:
@@ -9,18 +9,20 @@ module Mattermost
# - url => What is the URL to trigger here?
# - icon_url => Supply a link to the icon
def self.create(team_id, params)
- params = {
+ command = {
auto_complete: true,
auto_complete_desc: 'List all available commands',
auto_complete_hint: '[help]',
description: 'Perform common operations on GitLab',
display_name: 'GitLab',
method: 'P',
- user_name: 'GitLab'
- }..merge(params)
+ user_name: 'GitLab',
+ trigger: 'gitlab',
+ }.merge(params)
- Mattermost::Mattermost.post( "/teams/#{team_id}/commands/create", params.to_json).
- parsed_response['token']
+ response = post( "/teams/#{team_id}/commands/create", body: command.to_json)
+
+ response.parsed_response['token']
end
end
end