mattermost-api4-ruby 0.0.1 → 0.0.2
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 +4 -4
- data/bin/console +1 -1
- data/lib/mattermost.rb +1 -1
- data/lib/mattermost/client.rb +21 -4
- data/lib/mattermost/endpoint/users.rb +185 -1
- data/mattermost-api4-ruby.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: facd5adfbb2f3263ccc726d605f7e99d9d5fbba7
|
4
|
+
data.tar.gz: fdd2d076cceda4c601162672ba24364651fcd7e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d77f88bbc6e8f275994f7f2b5b5d12bb01859a48ee4664e82a7f99400f12aca2df397b2fa89c6fd602e5f2f8ad465d741c313ae51b31c99bc559a1a4b67e25c5
|
7
|
+
data.tar.gz: ff8a0c1d52c7119c6d6a037a04ff5e08a975bd3fb742ed477d25ee8e606d0d26ea3e5b29a978542a540dcd0c787b9bb9d4e0bdf4854ef159f626909d4733a621
|
data/bin/console
CHANGED
data/lib/mattermost.rb
CHANGED
data/lib/mattermost/client.rb
CHANGED
@@ -5,14 +5,15 @@ require_relative 'request'
|
|
5
5
|
module Mattermost
|
6
6
|
|
7
7
|
class Client
|
8
|
-
|
9
|
-
|
8
|
+
include HTTParty
|
9
|
+
include Mattermost::Endpoint
|
10
|
+
include Mattermost::Request
|
10
11
|
|
11
12
|
attr_accessor :server, :token
|
12
13
|
|
13
14
|
def initialize(server)
|
14
15
|
self.server = server
|
15
|
-
self.base_uri
|
16
|
+
self.class.base_uri "#{server}/api/v4"
|
16
17
|
end
|
17
18
|
|
18
19
|
def login(username, password)
|
@@ -35,10 +36,26 @@ module Mattermost
|
|
35
36
|
getMe().success?
|
36
37
|
end
|
37
38
|
|
39
|
+
def get(path, options = {}, &block)
|
40
|
+
self.class.get(path, options, &block)
|
41
|
+
end
|
42
|
+
|
43
|
+
def post(path, options = {}, &block)
|
44
|
+
self.class.get(path, options, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def put(path, options = {}, &block)
|
48
|
+
self.class.get(path, options, &block)
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete(path, options = {}, &block)
|
52
|
+
self.class.delete(path, options, &block)
|
53
|
+
end
|
54
|
+
|
38
55
|
private
|
39
56
|
|
40
57
|
def update_token
|
41
|
-
self.headers
|
58
|
+
self.class.headers :Authorization => "Bearer #{token}"
|
42
59
|
end
|
43
60
|
end
|
44
61
|
end
|
@@ -1,8 +1,192 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Mattermost
|
2
4
|
module Endpoint
|
3
5
|
module Users
|
4
6
|
def getMe
|
5
|
-
|
7
|
+
get_user("me")
|
8
|
+
end
|
9
|
+
|
10
|
+
def create_user(user)
|
11
|
+
post("/users", :body => user.to_json)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get_users(options = {}, max = 60)
|
15
|
+
query = ""
|
16
|
+
|
17
|
+
query = "#{query}&in_team=#{options[:in_team]}" if options.key? :in_team
|
18
|
+
query = "#{query}¬_in_team=#{options[:not_in_team]}" if options.key? :not_in_team
|
19
|
+
|
20
|
+
query = "#{query}&in_channel=#{options[:in_channel]}" if options.key? :in_channel
|
21
|
+
query = "#{query}¬_in_channel#{options[:not_in_channel]}" if options.key? :not_in_channel
|
22
|
+
|
23
|
+
query = "#{query}&without_team=#{options[:without_team]}" if options.key? :without_team
|
24
|
+
|
25
|
+
query = "#{query}&sort=#{options[:sort]}" if options.key? :sort
|
26
|
+
|
27
|
+
get("/users?per_page=#{max}#{query}")
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_users_by_ids(user_ids = [])
|
31
|
+
post("/users/ids", :body => JSON.generate(user_ids))
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_users_by_usernames(usernames = [])
|
35
|
+
post("/users/usernames", :body => JSON.generate(usernames))
|
36
|
+
end
|
37
|
+
|
38
|
+
def search_users(term, options = {})
|
39
|
+
criteria = options.dup
|
40
|
+
criteria[:term] = term
|
41
|
+
post("/users/search", :body => criteria.to_json)
|
42
|
+
end
|
43
|
+
|
44
|
+
def autocomplete_users(name, params = {})
|
45
|
+
query = "?name=#{name}"
|
46
|
+
query = "#{query}&team_id=#{params[:team_id]}" if params.key? :team_id
|
47
|
+
query = "#{query}&channel_id=#{params[:channel_id]}" if params.key? :channel_id
|
48
|
+
|
49
|
+
get("/users/autocomplete#{query}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_user(user_id)
|
53
|
+
get("/users/#{user_id}")
|
54
|
+
end
|
55
|
+
|
56
|
+
def update_user(user_id, user)
|
57
|
+
post("/users/#{user_id}", :body => user.to_json)
|
58
|
+
end
|
59
|
+
|
60
|
+
def deativate_user_account(user_id)
|
61
|
+
delete("/users/#{user_id}")
|
62
|
+
end
|
63
|
+
|
64
|
+
def patch_user(user_id, patch = {})
|
65
|
+
put("/users/#{user_id}/patch", :body => patch.to_json)
|
66
|
+
end
|
67
|
+
|
68
|
+
def update_user_roles(user_id, roles)
|
69
|
+
put("/users/#{user_id}/roles", roles)
|
70
|
+
end
|
71
|
+
|
72
|
+
def update_user_active_status(user_id, active)
|
73
|
+
put("/users/#{user_id}/active", :body => {
|
74
|
+
:active => active
|
75
|
+
}.to_json)
|
76
|
+
end
|
77
|
+
|
78
|
+
def get_user_profile_image(user_id, file_name)
|
79
|
+
File.open(file_name, "w") do |file|
|
80
|
+
file.binmode
|
81
|
+
get(get_user_profile_image_url(user_id), stream_body: true) do |fragment|
|
82
|
+
file.write(fragment)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_user_profile_image_url(user_id)
|
88
|
+
"/users/#{user_id}/image"
|
89
|
+
end
|
90
|
+
|
91
|
+
def set_user_profile_image(user_id, image)
|
92
|
+
#post("/users/#{user_id}/image", image)
|
93
|
+
raise NotImplementedError
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_user_by_username(username)
|
97
|
+
get("/users/username/#{username}")
|
98
|
+
end
|
99
|
+
|
100
|
+
def reset_password(code, new_password)
|
101
|
+
post("/users/password/reset", :body => {
|
102
|
+
:code => code,
|
103
|
+
:new_password => new_password
|
104
|
+
}.to_json)
|
105
|
+
end
|
106
|
+
|
107
|
+
def update_user_mfa(user_id, activate, code = nil)
|
108
|
+
params = {:activate => activate}
|
109
|
+
params[:code] = code if code != nil
|
110
|
+
put("/users/#{user_id}/mfa", params.to_json)
|
111
|
+
end
|
112
|
+
|
113
|
+
def generate_mfa_secret(user_id)
|
114
|
+
post("/users/#{user_id}/mfa/generate")
|
115
|
+
end
|
116
|
+
|
117
|
+
def check_mfa(login_id)
|
118
|
+
post("/users/mfa", :body => {:login_id => login_id}.to_json)
|
119
|
+
end
|
120
|
+
|
121
|
+
def update_user_password(user_id, current_password, new_password)
|
122
|
+
put("/users/#{user_id}/password", :body => {
|
123
|
+
:current_password => current_password,
|
124
|
+
:new_password => new_password
|
125
|
+
}.to_json)
|
126
|
+
end
|
127
|
+
|
128
|
+
def send_password_reset_email(email)
|
129
|
+
post("/users/password/reset/send", :body => {:email => email}.to_json)
|
130
|
+
end
|
131
|
+
|
132
|
+
def get_user_by_email(email)
|
133
|
+
get("/users/email/#{email}")
|
134
|
+
end
|
135
|
+
|
136
|
+
def get_user_sessions(user_id)
|
137
|
+
get("/users/#{user_id}/sessions")
|
138
|
+
end
|
139
|
+
|
140
|
+
def revoke_user_session(user_id, session_id)
|
141
|
+
post("/users/#{user_id}/sessions/revoke", :body => {:session_id => session_id}.to_json)
|
142
|
+
end
|
143
|
+
|
144
|
+
def revoke_all_active_session_for_user(user_id)
|
145
|
+
post("/users/#{user_id}/sessions/revoke/all")
|
146
|
+
end
|
147
|
+
|
148
|
+
def attach_mobile_device(device_id)
|
149
|
+
put("/users/sessions/device", :body => {:device_id => device_id}.to_json)
|
150
|
+
end
|
151
|
+
|
152
|
+
def get_user_audits(user_id)
|
153
|
+
get("/users/#{user_id}/audits")
|
154
|
+
end
|
155
|
+
|
156
|
+
def verify_user_email(token)
|
157
|
+
post("/users/email/verify", :body => {:token => token}.to_json)
|
158
|
+
end
|
159
|
+
|
160
|
+
def send_verification_email(email)
|
161
|
+
post("/users/email/verify/send", :body => {:email => email}.to_json)
|
162
|
+
end
|
163
|
+
|
164
|
+
def switch_login_method(params)
|
165
|
+
post("/users/login/switch", :body => params.to_json)
|
166
|
+
end
|
167
|
+
|
168
|
+
def create_user_access_token(user_id, description)
|
169
|
+
post("/users/#{user_id}/tokens", :body => {:description => description}.to_json)
|
170
|
+
end
|
171
|
+
|
172
|
+
def get_user_access_tokens(user_id, max = 60)
|
173
|
+
get("/users/#{user_id}/tokens?per_page=#{max}")
|
174
|
+
end
|
175
|
+
|
176
|
+
def revoke_user_access_token(token)
|
177
|
+
post("/users/tokens/revoke", :body => {:token => token}.to_json)
|
178
|
+
end
|
179
|
+
|
180
|
+
def get_user_access_token(token)
|
181
|
+
get("/users/tokens/#{token}")
|
182
|
+
end
|
183
|
+
|
184
|
+
def disable_personal_access_token(token)
|
185
|
+
post("/users/tokens/disable", :body => {:token => token}.to_json)
|
186
|
+
end
|
187
|
+
|
188
|
+
def enable_personal_access_token(token)
|
189
|
+
post("/users/tokens/enable", :body => {:token => token}.to_json)
|
6
190
|
end
|
7
191
|
end
|
8
192
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mattermost-api4-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takayuki Maruyama
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|