mattermost 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +30 -0
- data/LICENSE +21 -0
- data/README.md +63 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mattermost.rb +41 -0
- data/lib/mattermost/client.rb +18 -0
- data/lib/mattermost/dsl.rb +64 -0
- data/lib/mattermost/request_builder.rb +133 -0
- data/lib/mattermost/resource_name.rb +30 -0
- data/lib/mattermost/resources/base.rb +20 -0
- data/lib/mattermost/resources/channel.rb +11 -0
- data/lib/mattermost/resources/team.rb +51 -0
- data/lib/mattermost/resources/user.rb +85 -0
- data/lib/mattermost/version.rb +3 -0
- data/mattermost.gemspec +28 -0
- metadata +118 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e7f10f5417d0d540624ada8368d8946046da3ccd
|
4
|
+
data.tar.gz: e07a277a4c5533801f0d7851845bb6daf6d97bcc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 68a92ac6c5b99010b19625e720266622e422469ec1e5021644c22b9938108547312b0cb4b2d2c789265680aa49da2d3ad0727d2aed04825f339ad99637963560
|
7
|
+
data.tar.gz: 797960faa2b5c5c10673e3d534fba1511ac72d881a74d0a315b1bc913b6fbd4b3d9dfd2c414ae58844f4cbd6020e9d9c27d96ce8e9c2b36530fd09512d746278
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mattermost (0.1.0)
|
5
|
+
httparty
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.2)
|
11
|
+
httparty (0.15.6)
|
12
|
+
multi_xml (>= 0.5.2)
|
13
|
+
method_source (0.9.0)
|
14
|
+
multi_xml (0.6.0)
|
15
|
+
pry (0.11.3)
|
16
|
+
coderay (~> 1.1.0)
|
17
|
+
method_source (~> 0.9.0)
|
18
|
+
rake (10.5.0)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
bundler (~> 1.16)
|
25
|
+
mattermost!
|
26
|
+
pry
|
27
|
+
rake (~> 10.0)
|
28
|
+
|
29
|
+
BUNDLED WITH
|
30
|
+
1.16.1
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Josh Brody
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Mattermost
|
2
|
+
|
3
|
+
A rewrite of Mattermost-Ruby to be more elegant. And it's kind of cool.
|
4
|
+
|
5
|
+
## Notes
|
6
|
+
|
7
|
+
This is for v4 and forward. For v3, please use the original Mattermost-Ruby.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'mattermost'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install mattermost
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Don't use this yet. But it requires Mattermost version 4.
|
28
|
+
|
29
|
+
## Authentication
|
30
|
+
|
31
|
+
You'll want to create a user that has some system-wide roles within Mattermost.
|
32
|
+
|
33
|
+
Mattermost.configure do |c|
|
34
|
+
c.server = 'great-company.com'
|
35
|
+
c.protocol = 'https'
|
36
|
+
c.username = 'joshmn'
|
37
|
+
c.password = 'password'
|
38
|
+
end
|
39
|
+
|
40
|
+
Mattermost.connect!
|
41
|
+
|
42
|
+
Without calling `connect!` you won't have the headers required to make the API calls, so call it somewhere once.
|
43
|
+
|
44
|
+
## Conventions
|
45
|
+
|
46
|
+
Inspired by the Active Record pattern ActionDispatch routes (member/collection), you can,
|
47
|
+
|
48
|
+
User.find(user_id).teams
|
49
|
+
|
50
|
+
to get a User's teams.
|
51
|
+
|
52
|
+
Or,
|
53
|
+
|
54
|
+
User.create(mattermost_params)
|
55
|
+
|
56
|
+
to create a user.
|
57
|
+
|
58
|
+
All the corresponding methods are defined inside lib/mattermost/resources. Of note,
|
59
|
+
|
60
|
+
* Methods that have an `as` of `self` are class-level methods, and `member` are instance-level methods.
|
61
|
+
* The `args` option allows this client to map the passed arguments to a variable for usage in the HTTP request (`body` does the same thing, but for the body of the request)
|
62
|
+
* If an `endpoint` option has `:variable`, that's indicative of needing to pass an argument to the method.
|
63
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mm"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/mattermost.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'mattermost/version'
|
2
|
+
require 'mattermost/client'
|
3
|
+
require 'mattermost/dsl'
|
4
|
+
require 'mattermost/request_builder'
|
5
|
+
require 'mattermost/resource_name'
|
6
|
+
require 'mattermost/resources/base'
|
7
|
+
require 'mattermost/resources/team'
|
8
|
+
require 'mattermost/resources/user'
|
9
|
+
|
10
|
+
module Mattermost
|
11
|
+
|
12
|
+
class << self
|
13
|
+
attr_accessor :configuration
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configure
|
17
|
+
self.configuration ||= Config.new
|
18
|
+
yield(configuration)
|
19
|
+
end
|
20
|
+
|
21
|
+
class Config
|
22
|
+
attr_accessor :server, :protocol, :username, :password
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
@server = ""
|
26
|
+
@protocol = "https"
|
27
|
+
@username = ""
|
28
|
+
@password = ""
|
29
|
+
end
|
30
|
+
|
31
|
+
def raw_host
|
32
|
+
"#{Mattermost.configuration.protocol}://#{Mattermost.configuration.server}"
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.connect!
|
38
|
+
Client.connect!
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Mattermost
|
4
|
+
class Client
|
5
|
+
include HTTParty
|
6
|
+
|
7
|
+
def self.connect!
|
8
|
+
req = HTTParty.post("#{Mattermost.configuration.protocol}://#{Mattermost.configuration.server}/api/v4/users/login", :body => {:login_id => Mattermost.configuration.username, :password => Mattermost.configuration.password}.to_json)
|
9
|
+
if req.success?
|
10
|
+
class_eval do
|
11
|
+
base_uri "#{Mattermost.configuration.protocol}://#{Mattermost.configuration.server}/api/v4"
|
12
|
+
headers 'Cookie' => req.headers['set-cookie'], 'X-Requested-With' => 'XMLHttpRequest'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Mattermost
|
2
|
+
module DSL
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def get(endpoint_name, options = {})
|
10
|
+
options[:resource] = self.resource_name
|
11
|
+
create_api_method(:get, endpoint_name, options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def post(endpoint_name, options = {})
|
15
|
+
options[:resource] = self.resource_name
|
16
|
+
create_api_method(:post, endpoint_name, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def put(endpoint_name, options = {})
|
20
|
+
options[:resource] = self.resource_name
|
21
|
+
create_api_method(:post, endpoint_name, options.merge(:http_method => :put))
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete(endpoint_name, options = {})
|
25
|
+
create_api_method(:delete, endpoint_name, options)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# /teams/name/:first_name/exists/:last_name
|
31
|
+
# arg should be :first_name, :last_name (in the order they appear)
|
32
|
+
def create_api_method(http_method, method_name, options = {})
|
33
|
+
options = normalize_options(options)
|
34
|
+
options[:http_method] ||= http_method
|
35
|
+
define_api_method(method_name, options)
|
36
|
+
end
|
37
|
+
|
38
|
+
def define_api_method(method_name, opts)
|
39
|
+
if opts[:as] == :self
|
40
|
+
define_singleton_method(method_name) do |*args|
|
41
|
+
builder = RequestBuilder.new(self, method_name, args, opts)
|
42
|
+
request = Client.send(opts[:http_method], "#{Mattermost.configuration.raw_host}/api/v4#{builder.endpoint}", builder.request_options)
|
43
|
+
request
|
44
|
+
end
|
45
|
+
else
|
46
|
+
define_method(method_name) do |*args|
|
47
|
+
builder = RequestBuilder.new(self, method_name, args, opts)
|
48
|
+
request = Client.send(opts[:http_method], "#{Mattermost.configuration.raw_host}/api/v4#{builder.endpoint}", builder.request_options)
|
49
|
+
request
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def normalize_options(options)
|
55
|
+
options[:args] ||= []
|
56
|
+
options
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module Mattermost
|
2
|
+
class RequestBuilder
|
3
|
+
|
4
|
+
def initialize(resource, method_name, args, options)
|
5
|
+
@resource = resource
|
6
|
+
@method_name = method_name
|
7
|
+
@args = args
|
8
|
+
@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def interpolated_endpoint
|
12
|
+
raw = raw_endpoint
|
13
|
+
route_params = raw.scan(%r{(:\w*)}).flatten
|
14
|
+
route_params.each do |route_param|
|
15
|
+
rp = route_param[1..-1]
|
16
|
+
if @resource.respond_to?(rp.to_sym)
|
17
|
+
raw.gsub!(route_param, @resource.send(rp.to_sym))
|
18
|
+
elsif parameters[rp.to_sym]
|
19
|
+
raw.gsub!(route_param, parameters[rp.to_sym])
|
20
|
+
elsif endpoint_args_map[rp.to_sym]
|
21
|
+
raw.gsub!(route_param, endpoint_args_map[rp.to_sym])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
unless query_params.empty?
|
25
|
+
raw += "?#{URI.encode_www_form(query_params)}"
|
26
|
+
end
|
27
|
+
raw
|
28
|
+
end
|
29
|
+
|
30
|
+
def request_options
|
31
|
+
if request_body
|
32
|
+
return {:body => request_body.to_json}
|
33
|
+
end
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
|
37
|
+
alias_method :endpoint, :interpolated_endpoint
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def raw_endpoint
|
42
|
+
if as == :member
|
43
|
+
return "/#{@options[:resource].plural}/:#{@options[:resource].param_key}/#{@method_name}" if @options[:endpoint].nil?
|
44
|
+
if @options[:endpoint] == ''
|
45
|
+
return "/#{@options[:resource].plural}/:#{@options[:resource].param_key}"
|
46
|
+
elsif @options[:endpoint].to_s[0] != '/'
|
47
|
+
return "/#{@options[:resource].plural}/:#{@options[:resource].param_key}/#{@options[:endpoint]}"
|
48
|
+
end
|
49
|
+
elsif as == :self
|
50
|
+
return "/#{@options[:resource].plural}/#{@method_name}" if @options[:endpoint].nil?
|
51
|
+
if @options[:endpoint] == ''
|
52
|
+
return "/#{@options[:resource].plural}"
|
53
|
+
elsif @options[:endpoint].to_s[0] != '/'
|
54
|
+
return "/#{@options[:resource].plural}/#{@options[:endpoint]}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def parameters
|
60
|
+
if @args[0].is_a?(Hash)
|
61
|
+
@args[0]
|
62
|
+
else
|
63
|
+
extract_args
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def args_from_options
|
68
|
+
if @options[:args].is_a?(Symbol)
|
69
|
+
[@options[:args]]
|
70
|
+
else
|
71
|
+
@options[:args]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def endpoint_args_map
|
76
|
+
map = {}
|
77
|
+
raw_endpoint.scan(%r{(:\w*)}).flatten.map { |p| p[1..-1].to_sym }.each_with_index do |arg, ind|
|
78
|
+
map[arg] = @args[ind]
|
79
|
+
end
|
80
|
+
map
|
81
|
+
end
|
82
|
+
|
83
|
+
def extract_args
|
84
|
+
arg_map = {}
|
85
|
+
args_from_options.each_with_index do |arg, ind|
|
86
|
+
arg_map[arg] = @args[ind]
|
87
|
+
end
|
88
|
+
arg_map
|
89
|
+
end
|
90
|
+
|
91
|
+
def supports_query_params?
|
92
|
+
@options[:http_method] == :get
|
93
|
+
end
|
94
|
+
|
95
|
+
def query_params
|
96
|
+
return {} unless supports_query_params?
|
97
|
+
return {} if @args.empty?
|
98
|
+
if @args[0].is_a?(Hash)
|
99
|
+
return @args[0]
|
100
|
+
end
|
101
|
+
{}
|
102
|
+
end
|
103
|
+
|
104
|
+
def body_map
|
105
|
+
if @options[:body]
|
106
|
+
arg_map = {}
|
107
|
+
[@options[:body]].each_with_index do |arg, ind|
|
108
|
+
arg_map[arg] = @args[ind]
|
109
|
+
end
|
110
|
+
return arg_map
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def request_body
|
115
|
+
if @options[:body]
|
116
|
+
return body_map
|
117
|
+
end
|
118
|
+
if @args[0].is_a?(Hash)
|
119
|
+
return @args[0]
|
120
|
+
end
|
121
|
+
if @args[0].is_a?(String) && @args.is_a?(Array)
|
122
|
+
if as == :self
|
123
|
+
return @args
|
124
|
+
end
|
125
|
+
end
|
126
|
+
nil
|
127
|
+
end
|
128
|
+
|
129
|
+
def as
|
130
|
+
@options[:as]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Mattermost
|
2
|
+
class ResourceName
|
3
|
+
|
4
|
+
attr_reader :klass
|
5
|
+
def initialize(klass)
|
6
|
+
@klass = if klass.name.index("::")
|
7
|
+
klass.name.split("::").last
|
8
|
+
else
|
9
|
+
klass.name
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def singular
|
14
|
+
@klass.downcase
|
15
|
+
end
|
16
|
+
|
17
|
+
def plural
|
18
|
+
"#{@klass}s".downcase
|
19
|
+
end
|
20
|
+
|
21
|
+
def path
|
22
|
+
plural.downcase
|
23
|
+
end
|
24
|
+
|
25
|
+
def param_key
|
26
|
+
"#{singular}_id".downcase.to_sym
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Mattermost
|
2
|
+
class BaseResource
|
3
|
+
|
4
|
+
include Mattermost::DSL
|
5
|
+
|
6
|
+
attr_reader :id
|
7
|
+
def initialize(id)
|
8
|
+
@id = id
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find(id)
|
12
|
+
new(id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.resource_name
|
16
|
+
ResourceName.new(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Mattermost
|
2
|
+
class Channel < BaseResource
|
3
|
+
|
4
|
+
alias_method :channel_id, :id
|
5
|
+
|
6
|
+
# Creates a channel
|
7
|
+
# Channel.create(:team_id => "long-team-id", :name => "michaels-party", :display_name => "Michael's Party", :type => 'O')
|
8
|
+
post :create, :as => :self
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Mattermost
|
2
|
+
class Team < BaseResource
|
3
|
+
|
4
|
+
alias_method :team_id, :id
|
5
|
+
|
6
|
+
# Returns the given team
|
7
|
+
# Team.find("long-team-id").raw
|
8
|
+
get :raw, :as => :member, :endpoint => ''
|
9
|
+
|
10
|
+
# Returns stats of a team
|
11
|
+
# Team.find("long-team-id").stats
|
12
|
+
get :stats, :as => :member
|
13
|
+
|
14
|
+
# Returns a user by their name
|
15
|
+
# Team.by_name("development")
|
16
|
+
get :by_name, :as => :self, :endpoint => 'name/:team_name', :args => :team_name
|
17
|
+
|
18
|
+
# Returns whether or not the team exists
|
19
|
+
# Team.exists("party-planning-committee")
|
20
|
+
get :exists, :as => :self, :endpoint => 'name/:team_name/exists', :args => :team_name
|
21
|
+
|
22
|
+
# Returns all the teams on the instance
|
23
|
+
# Team.all
|
24
|
+
get :all, :as => :self, :endpoint => ''
|
25
|
+
|
26
|
+
# Creates a team
|
27
|
+
# Team.create(:name => "party-planning-committee", :display_name => "Party Planning Committee", type => 'I')
|
28
|
+
post :create, :as => :self, :endpoint => ''
|
29
|
+
|
30
|
+
# Search teams
|
31
|
+
# Team.search("party")
|
32
|
+
post :search, :as => :self, :body => :term
|
33
|
+
|
34
|
+
# Gets members of a team
|
35
|
+
# Team.find("long-team-id").members
|
36
|
+
get :members, :as => :member
|
37
|
+
|
38
|
+
# Adds a user to a Team
|
39
|
+
# Team.find("long-team-id").add_member(:team_id => "long-team-id", :user_id => "long-user-id", :roles => "team_admin")
|
40
|
+
post :add_member, :as => :member, :endpoint => 'members'
|
41
|
+
|
42
|
+
# Gets the member status of a user of a particiular team
|
43
|
+
# Team.find("long-team-id").member_by_user_id("long-user-id")
|
44
|
+
get :member_by_user_id, :as => :member, :endpoint => 'members/:user_id', :args => :user_id
|
45
|
+
|
46
|
+
# Updates a team
|
47
|
+
# Team.find("long-team-id").update_attributes(:display_name => "Former Party Planning Committee")
|
48
|
+
put :update_attributes, :as => :member, :endpoint => 'patch'
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Mattermost
|
2
|
+
class User < BaseResource
|
3
|
+
|
4
|
+
alias_method :user_id, :id
|
5
|
+
|
6
|
+
# Creates a user
|
7
|
+
# User.create(:email => "ryan@dundermifflin.com", :username => "ryanhoward", :password => "ilovekelly")
|
8
|
+
post :create, :as => :self, :endpoint => ''
|
9
|
+
|
10
|
+
# Gets all users
|
11
|
+
# User.all
|
12
|
+
get :all, :as => :self, :endpoint => ''
|
13
|
+
|
14
|
+
# Gets users by their user IDs
|
15
|
+
# User.by_ids("long-user-id-1", "long-user-id-2")
|
16
|
+
post :by_ids, :as => :self, :endpoint => 'ids'
|
17
|
+
|
18
|
+
# Gets users by their usernames
|
19
|
+
# User.by_usernames("long-username-1", "long-username-2")
|
20
|
+
post :by_usernames, :as => :self, :endpoint => 'usernames'
|
21
|
+
|
22
|
+
# Opens an autocomplete endpoint
|
23
|
+
# Requires :name; optional params are :team_id, :channel_id
|
24
|
+
# :name can be a username, nickname, first name, or last name
|
25
|
+
# User.autocomplete(:name => "something")
|
26
|
+
get :autocomplete, :as => :self
|
27
|
+
|
28
|
+
# Returns the given user
|
29
|
+
# User.find("long-user-id").raw
|
30
|
+
get :raw, :as => :member, :endpoint => ''
|
31
|
+
|
32
|
+
# Updates a user
|
33
|
+
# User.find("long-user-id").update_attributes(:email => "ceo@dundermifflin.com")
|
34
|
+
put :update_attributes, :as => :member, :endpoint => 'patch'
|
35
|
+
|
36
|
+
# Updates the user's roles
|
37
|
+
# User.find("long-user-id").roles("team_admin")
|
38
|
+
put :roles, :as => :member, :endpoint => 'roles', :args => :roles
|
39
|
+
|
40
|
+
# Gets the member's avatar/display pic thing
|
41
|
+
# User.find("long-user-id").image
|
42
|
+
get :image, :as => :member
|
43
|
+
|
44
|
+
# Gets users by their username
|
45
|
+
# User.by_username("ryan")
|
46
|
+
get :by_username, :as => :self, :endpoint => 'username/:username'
|
47
|
+
|
48
|
+
# Gets users with a matching email
|
49
|
+
get :by_email, :as => :self, :endpoint => 'email/:email'
|
50
|
+
|
51
|
+
# Gets current user sessions
|
52
|
+
get :sessions, :as => :member
|
53
|
+
|
54
|
+
# Revokes a given session
|
55
|
+
# User.find("long-user-id").revoke("session-id")
|
56
|
+
post :revoke_session, :as => :member, :endpoint => 'sessions/revoke', :args => :session_id
|
57
|
+
|
58
|
+
# Revokes all sessionds
|
59
|
+
post :revoke_all_sessions, :as => :member, :endpoint => 'sessions/revoke'
|
60
|
+
|
61
|
+
# Does an audit on the user
|
62
|
+
get :audits, :as => :member
|
63
|
+
|
64
|
+
# Verify the email used by a user to sign-up with
|
65
|
+
# User.verify("token")
|
66
|
+
post :verify_email, :as => :self, :endpoint => 'email/verify'
|
67
|
+
|
68
|
+
# Resend verification email
|
69
|
+
# User.send_verification_email("ryan@dundermifflin.com")
|
70
|
+
post :send_verification_email, :as => :self, :endpoint => 'email/verify/send', :body => :email
|
71
|
+
|
72
|
+
# Get the teams a user is a member of
|
73
|
+
# User.find("long-user-id").teams
|
74
|
+
get :teams, :as => :member
|
75
|
+
|
76
|
+
# ...
|
77
|
+
get :team_members, :as => :member, :endpoint => 'teams/members'
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
# These probably don't work
|
82
|
+
post :search, :as => :self, :endpoint => 'search' # this takes lots of args, should probably look at it
|
83
|
+
post :image, :as => :member # i haven't done files yet...this probably won't work
|
84
|
+
end
|
85
|
+
end
|
data/mattermost.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "mattermost/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "mattermost"
|
7
|
+
spec.version = Mattermost::VERSION
|
8
|
+
spec.authors = ["Josh Brody"]
|
9
|
+
spec.email = ["josh@josh.mn"]
|
10
|
+
|
11
|
+
spec.summary = "A slick Mattermost API client"
|
12
|
+
spec.description = "A slick Mattermost API client"
|
13
|
+
spec.homepage = "https://github.com/joshmn/mattermost"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency 'httparty'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
26
|
+
spec.add_development_dependency "pry"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mattermost
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Brody
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: A slick Mattermost API client
|
70
|
+
email:
|
71
|
+
- josh@josh.mn
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- lib/mattermost.rb
|
85
|
+
- lib/mattermost/client.rb
|
86
|
+
- lib/mattermost/dsl.rb
|
87
|
+
- lib/mattermost/request_builder.rb
|
88
|
+
- lib/mattermost/resource_name.rb
|
89
|
+
- lib/mattermost/resources/base.rb
|
90
|
+
- lib/mattermost/resources/channel.rb
|
91
|
+
- lib/mattermost/resources/team.rb
|
92
|
+
- lib/mattermost/resources/user.rb
|
93
|
+
- lib/mattermost/version.rb
|
94
|
+
- mattermost.gemspec
|
95
|
+
homepage: https://github.com/joshmn/mattermost
|
96
|
+
licenses: []
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.6.13
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: A slick Mattermost API client
|
118
|
+
test_files: []
|