summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-01-24 12:47:22 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2017-01-24 12:47:22 +0000
commita89aab9c630593524b8a210746d2eb680ac5d102 (patch)
tree4cf453f95c9f5c3ee9fc65ba23a1684c362ffa55
parent01fa19edfe2646ad904db6ff50047c2eab61e9d9 (diff)
parentf187cc59d6c5a293ca4a1152fad3a0794e25e3ed (diff)
downloadgitlab-ce-a89aab9c630593524b8a210746d2eb680ac5d102.tar.gz
Merge branch 'zj-mattermost-api-update' into 'master'
Small update to the Mattermost API See merge request !8712
-rw-r--r--lib/mattermost/client.rb22
-rw-r--r--lib/mattermost/command.rb2
-rw-r--r--lib/mattermost/team.rb2
3 files changed, 18 insertions, 8 deletions
diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb
index ec2903b7ec6..e55c0d6ac49 100644
--- a/lib/mattermost/client.rb
+++ b/lib/mattermost/client.rb
@@ -8,21 +8,31 @@ module Mattermost
@user = user
end
- private
-
def with_session(&blk)
Mattermost::Session.new(user).with_session(&blk)
end
- def json_get(path, options = {})
+ private
+
+ # Should be used in a session manually
+ def get(session, path, options = {})
+ json_response session.get(path, options)
+ end
+
+ # Should be used in a session manually
+ def post(session, path, options = {})
+ json_response session.post(path, options)
+ end
+
+ def session_get(path, options = {})
with_session do |session|
- json_response session.get(path, options)
+ get(session, path, options)
end
end
- def json_post(path, options = {})
+ def session_post(path, options = {})
with_session do |session|
- json_response session.post(path, options)
+ post(session, path, options)
end
end
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb
index d1e4bb0eccf..33e450d7f0a 100644
--- a/lib/mattermost/command.rb
+++ b/lib/mattermost/command.rb
@@ -1,7 +1,7 @@
module Mattermost
class Command < Client
def create(params)
- response = json_post("/api/v3/teams/#{params[:team_id]}/commands/create",
+ response = session_post("/api/v3/teams/#{params[:team_id]}/commands/create",
body: params.to_json)
response['token']
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb
index 784eca6ab5a..09dfd082b3a 100644
--- a/lib/mattermost/team.rb
+++ b/lib/mattermost/team.rb
@@ -1,7 +1,7 @@
module Mattermost
class Team < Client
def all
- json_get('/api/v3/teams/all')
+ session_get('/api/v3/teams/all')
end
end
end