Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mattermost/command.rb')
-rw-r--r--lib/mattermost/command.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb
index afbf2ce3349..5c6f5861a7f 100644
--- a/lib/mattermost/command.rb
+++ b/lib/mattermost/command.rb
@@ -1,12 +1,15 @@
module Mattermost
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
+ def self.create(session, params)
+ response = session.post("/api/v3/teams/#{params[:team_id]}/commands/create",
+ body: params.to_json)
- if response.has_key?('message')
- response
+ if response.success?
+ response.parsed_response['token']
+ elsif response.parsed_response.try(:has_key?, 'message')
+ raise response.parsed_response['message']
else
- response['token']
+ raise 'Failed to create a new command'
end
end
end