diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-20 02:22:10 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-20 02:22:10 +0300 |
commit | 841960f847f04da9c427bcdb19037e2112a90890 (patch) | |
tree | ff485924db7614a01d5f3f52f66dd28056097ff8 /lib/mattermost/command.rb | |
parent | 34295036e2a9ecf18ca5440a5dd6dbb0c7f05643 (diff) |
Fix flow
Diffstat (limited to 'lib/mattermost/command.rb')
-rw-r--r-- | lib/mattermost/command.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb index 5c6f5861a7f..d1e4bb0eccf 100644 --- a/lib/mattermost/command.rb +++ b/lib/mattermost/command.rb @@ -1,16 +1,10 @@ module Mattermost - class Command - def self.create(session, params) - response = session.post("/api/v3/teams/#{params[:team_id]}/commands/create", + class Command < Client + def create(params) + response = json_post("/api/v3/teams/#{params[:team_id]}/commands/create", body: params.to_json) - if response.success? - response.parsed_response['token'] - elsif response.parsed_response.try(:has_key?, 'message') - raise response.parsed_response['message'] - else - raise 'Failed to create a new command' - end + response['token'] end end end |