Skip to content
Snippets Groups Projects
Commit 239337fa authored by Z.J. van de Weg's avatar Z.J. van de Weg
Browse files

WIP

Former-commit-id: 80764241
parent d3085f3e
No related branches found
No related tags found
No related merge requests found
module Mattermost
class Command
class Command < Session
def self.all(team_id)
Mattermost::Mattermost.get("/teams/#{team_id}/commands/list_team_commands")
get("/api/v3/teams/#{team_id}/commands/list_team_commands")
end
 
# params should be a hash, which supplies _at least_:
Loading
Loading
@@ -9,7 +9,7 @@ module Mattermost
# - url => What is the URL to trigger here?
# - icon_url => Supply a link to the icon
def self.create(team_id, params)
params = {
command = {
auto_complete: true,
auto_complete_desc: 'List all available commands',
auto_complete_hint: '[help]',
Loading
Loading
@@ -17,10 +17,9 @@ module Mattermost
display_name: 'GitLab',
method: 'P',
user_name: 'GitLab'
}..merge(params)
}.merge(params)
 
Mattermost::Mattermost.post( "/teams/#{team_id}/commands/create", params.to_json).
parsed_response['token']
post( "/api/v3/teams/#{team_id}/commands/create", command.to_json).parsed_response['token']
end
end
end
Loading
Loading
@@ -106,7 +106,6 @@ module Mattermost
 
def normalize_uri(uri)
uri << '/' unless uri.end_with?('/')
uri << 'api/v3'
end
end
Loading
Loading
module Mattermost
class Team < Mattermost
class Team < Session
# After normalization this returns an array of hashes
#
# [{"id"=>"paf573pj9t81urupw3fanozeda", "display_name"=>"my team", <snip>}]
def self.all
@all_teams ||= get('/teams/all').parsed_response.values
get('/api/v3/teams/all').parsed_response.values
end
end
end
require 'spec_helper'
describe Mattermost::Team do
let(:session) { Mattermost::Session.new('http://localhost:8065/', nil) }
describe '.all' do
let(:result) { {id: 'abc', display_name: 'team'} }
before do
WebMock.stub_request(:get, 'http://localhost:8065/api/v3/teams/all').
and_return({ abc: result }.to_json)
end
xit 'gets the teams' do
allow(session).to receive(:with_session) { yield }
expect(described_class.all).to eq(result)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment