From 841960f847f04da9c427bcdb19037e2112a90890 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 20 Dec 2016 00:22:10 +0100 Subject: Fix flow --- lib/mattermost/command.rb | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'lib/mattermost/command.rb') 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 -- cgit v1.2.3