Module: Mattermost::Endpoint::Users

Included in:
Mattermost::Endpoint
Defined in:
lib/mattermost/endpoint/users.rb

Instance Method Summary collapse

Instance Method Details

#attach_mobile_device(device_id) ⇒ Object



148
149
150
# File 'lib/mattermost/endpoint/users.rb', line 148

def attach_mobile_device(device_id)
	put("/users/sessions/device", :body => {:device_id => device_id}.to_json)
end

#autocomplete_users(name, params = {}) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/mattermost/endpoint/users.rb', line 44

def autocomplete_users(name, params = {})
	query = "?name=#{name}"
	query = "#{query}&team_id=#{params[:team_id]}" if params.key? :team_id
	query = "#{query}&channel_id=#{params[:channel_id]}" if params.key? :channel_id

	get("/users/autocomplete#{query}")
end

#check_mfa(login_id) ⇒ Object



117
118
119
# File 'lib/mattermost/endpoint/users.rb', line 117

def check_mfa()
	post("/users/mfa", :body => {:login_id => }.to_json)
end

#create_user(user) ⇒ Object



10
11
12
# File 'lib/mattermost/endpoint/users.rb', line 10

def create_user(user)
	post("/users", :body => user.to_json)
end

#create_user_access_token(user_id, description) ⇒ Object



168
169
170
# File 'lib/mattermost/endpoint/users.rb', line 168

def create_user_access_token(user_id, description)
	post("/users/#{user_id}/tokens", :body => {:description => description}.to_json)
end

#deativate_user_account(user_id) ⇒ Object



60
61
62
# File 'lib/mattermost/endpoint/users.rb', line 60

def (user_id)
	delete("/users/#{user_id}")
end

#disable_personal_access_token(token) ⇒ Object



184
185
186
# File 'lib/mattermost/endpoint/users.rb', line 184

def disable_personal_access_token(token)
	post("/users/tokens/disable", :body => {:token => token}.to_json)
end

#enable_personal_access_token(token) ⇒ Object



188
189
190
# File 'lib/mattermost/endpoint/users.rb', line 188

def enable_personal_access_token(token)
	post("/users/tokens/enable", :body => {:token => token}.to_json)
end

#generate_mfa_secret(user_id) ⇒ Object



113
114
115
# File 'lib/mattermost/endpoint/users.rb', line 113

def generate_mfa_secret(user_id)
	post("/users/#{user_id}/mfa/generate")
end

#get_meObject



6
7
8
# File 'lib/mattermost/endpoint/users.rb', line 6

def get_me
	get_user("me")
end

#get_user(user_id) ⇒ Object



52
53
54
# File 'lib/mattermost/endpoint/users.rb', line 52

def get_user(user_id)
	get("/users/#{user_id}")
end

#get_user_access_token(token) ⇒ Object



180
181
182
# File 'lib/mattermost/endpoint/users.rb', line 180

def get_user_access_token(token)
	get("/users/tokens/#{token}")
end

#get_user_access_tokens(user_id, max = 60) ⇒ Object



172
173
174
# File 'lib/mattermost/endpoint/users.rb', line 172

def get_user_access_tokens(user_id, max = 60)
	get("/users/#{user_id}/tokens?per_page=#{max}")
end

#get_user_audits(user_id) ⇒ Object



152
153
154
# File 'lib/mattermost/endpoint/users.rb', line 152

def get_user_audits(user_id)
	get("/users/#{user_id}/audits")
end

#get_user_by_email(email) ⇒ Object



132
133
134
# File 'lib/mattermost/endpoint/users.rb', line 132

def get_user_by_email(email)
	get("/users/email/#{email}")
end

#get_user_by_username(username) ⇒ Object



96
97
98
# File 'lib/mattermost/endpoint/users.rb', line 96

def get_user_by_username(username)
	get("/users/username/#{username}")
end

#get_user_profile_image(user_id, file_name) ⇒ Object



78
79
80
81
82
83
84
85
# File 'lib/mattermost/endpoint/users.rb', line 78

def (user_id, file_name)
	File.open(file_name, "w") do |file|
		file.binmode
		get((user_id), stream_body: true) do |fragment|
			file.write(fragment)
		end
	end
end

#get_user_profile_image_url(user_id) ⇒ Object



87
88
89
# File 'lib/mattermost/endpoint/users.rb', line 87

def (user_id)
	"/users/#{user_id}/image"
end

#get_user_sessions(user_id) ⇒ Object



136
137
138
# File 'lib/mattermost/endpoint/users.rb', line 136

def get_user_sessions(user_id)
	get("/users/#{user_id}/sessions")
end

#get_users(options = {}, max = 60) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mattermost/endpoint/users.rb', line 14

def get_users(options = {}, max = 60)
	query = ""

	query = "#{query}&in_team=#{options[:in_team]}" if options.key? :in_team
	query = "#{query}&not_in_team=#{options[:not_in_team]}" if options.key? :not_in_team

	query = "#{query}&in_channel=#{options[:in_channel]}" if options.key? :in_channel
	query = "#{query}&not_in_channel#{options[:not_in_channel]}" if options.key? :not_in_channel
	
	query = "#{query}&without_team=#{options[:without_team]}" if options.key? :without_team

	query = "#{query}&sort=#{options[:sort]}" if options.key? :sort

	get("/users?per_page=#{max}#{query}")
end

#get_users_by_ids(user_ids = []) ⇒ Object



30
31
32
# File 'lib/mattermost/endpoint/users.rb', line 30

def get_users_by_ids(user_ids = [])
	post("/users/ids", :body => JSON.generate(user_ids))
end

#get_users_by_usernames(usernames = []) ⇒ Object



34
35
36
# File 'lib/mattermost/endpoint/users.rb', line 34

def get_users_by_usernames(usernames = [])
	post("/users/usernames", :body => JSON.generate(usernames))
end

#patch_user(user_id, patch = {}) ⇒ Object



64
65
66
# File 'lib/mattermost/endpoint/users.rb', line 64

def patch_user(user_id, patch = {})
	put("/users/#{user_id}/patch", :body => patch.to_json)
end

#reset_password(code, new_password) ⇒ Object



100
101
102
103
104
105
# File 'lib/mattermost/endpoint/users.rb', line 100

def reset_password(code, new_password)
	post("/users/password/reset", :body => {
		:code => code,
		:new_password => new_password
	}.to_json)
end

#revoke_all_active_session_for_user(user_id) ⇒ Object



144
145
146
# File 'lib/mattermost/endpoint/users.rb', line 144

def revoke_all_active_session_for_user(user_id)
	post("/users/#{user_id}/sessions/revoke/all")
end

#revoke_user_access_token(token) ⇒ Object



176
177
178
# File 'lib/mattermost/endpoint/users.rb', line 176

def revoke_user_access_token(token)
	post("/users/tokens/revoke", :body => {:token => token}.to_json)
end

#revoke_user_session(user_id, session_id) ⇒ Object



140
141
142
# File 'lib/mattermost/endpoint/users.rb', line 140

def revoke_user_session(user_id, session_id)
	post("/users/#{user_id}/sessions/revoke", :body => {:session_id => session_id}.to_json)
end

#search_users(term, options = {}) ⇒ Object



38
39
40
41
42
# File 'lib/mattermost/endpoint/users.rb', line 38

def search_users(term, options = {})
	criteria = options.dup
	criteria[:term] = term
	post("/users/search", :body => criteria.to_json)
end

#send_password_reset_email(email) ⇒ Object



128
129
130
# File 'lib/mattermost/endpoint/users.rb', line 128

def send_password_reset_email(email)
	post("/users/password/reset/send", :body => {:email => email}.to_json)
end

#send_verification_email(email) ⇒ Object



160
161
162
# File 'lib/mattermost/endpoint/users.rb', line 160

def send_verification_email(email)
	post("/users/email/verify/send", :body => {:email => email}.to_json)
end

#set_user_profile_image(user_id, image) ⇒ Object

Raises:

  • (NotImplementedError)


91
92
93
94
# File 'lib/mattermost/endpoint/users.rb', line 91

def (user_id, image)
	#post("/users/#{user_id}/image", image)
	raise NotImplementedError
end

#switch_login_method(params) ⇒ Object



164
165
166
# File 'lib/mattermost/endpoint/users.rb', line 164

def (params)
	post("/users/login/switch", :body => params.to_json)
end

#update_user(user_id, user) ⇒ Object



56
57
58
# File 'lib/mattermost/endpoint/users.rb', line 56

def update_user(user_id, user)
	post("/users/#{user_id}", :body => user.to_json)
end

#update_user_active_status(user_id, active) ⇒ Object



72
73
74
75
76
# File 'lib/mattermost/endpoint/users.rb', line 72

def update_user_active_status(user_id, active)
	put("/users/#{user_id}/active", :body => {
		:active => active
	}.to_json)
end

#update_user_authentication_method(user_id, auth_service, password = "", auth_data = "") ⇒ Object



192
193
194
195
196
197
198
# File 'lib/mattermost/endpoint/users.rb', line 192

def update_user_authentication_method(user_id, auth_service, password = "", auth_data = "")
	put("/users/#{user_id}/auth", :body => {
		:auth_data => auth_data,
		:auth_service => auth_service,
		:password => password
	}.to_json)
end

#update_user_mfa(user_id, activate, code = nil) ⇒ Object



107
108
109
110
111
# File 'lib/mattermost/endpoint/users.rb', line 107

def update_user_mfa(user_id, activate, code = nil)
	params = {:activate => activate}
	params[:code] = code if code != nil
	put("/users/#{user_id}/mfa", params.to_json)
end

#update_user_password(user_id, current_password, new_password) ⇒ Object



121
122
123
124
125
126
# File 'lib/mattermost/endpoint/users.rb', line 121

def update_user_password(user_id, current_password, new_password)
	put("/users/#{user_id}/password", :body => {
		:current_password => current_password,
		:new_password => new_password
	}.to_json)
end

#update_user_roles(user_id, roles) ⇒ Object



68
69
70
# File 'lib/mattermost/endpoint/users.rb', line 68

def update_user_roles(user_id, roles)
	put("/users/#{user_id}/roles", roles)
end

#verify_user_email(token) ⇒ Object



156
157
158
# File 'lib/mattermost/endpoint/users.rb', line 156

def verify_user_email(token)
	post("/users/email/verify", :body => {:token => token}.to_json)
end