Merge branch 'zj-mattermost-api-update' into 'master'
Small update to the Mattermost API See merge request !8712
This commit is contained in:
commit
a89aab9c63
|
@ -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 = {})
|
||||
with_session do |session|
|
||||
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|
|
||||
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
|
||||
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue