diff options
Diffstat (limited to 'lib/mattermost/command.rb')
-rw-r--r-- | lib/mattermost/command.rb | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb index 9c37d0b0d79..afbf2ce3349 100644 --- a/lib/mattermost/command.rb +++ b/lib/mattermost/command.rb @@ -1,14 +1,13 @@ module Mattermost - class Command < Session - def self.create(team_id, trigger: 'gitlab', url:, icon_url:) + class Command + def self.create(session, team_id, command) + response = session.post("/api/v3/teams/#{team_id}/commands/create", body: command.to_json).parsed_response - post_command(command)['token'] - end - - private - - def post_command(command) - post( "/teams/#{team_id}/commands/create", body: command.to_json).parsed_response + if response.has_key?('message') + response + else + response['token'] + end end end end |