Class: Mattermost::Client

Inherits:
Object
  • Object
show all
Extended by:
Gem::Deprecate
Includes:
Endpoint, Request
Defined in:
lib/mattermost/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Request

#delete, #get, #post, #put

Methods included from Endpoint::Webhooks

#create_incoming_webhook, #create_outgoing_webhook, #delete_outgoing_webhook, #get_incoming_webhook, #get_outgoing_webhook, #list_incoming_webhooks, #list_incoming_webhooks_for_system, #list_outgoing_webhooks, #list_outgoing_webhooks_for_system, #regenerate_outgoing_webhook_token, #update_incoming_webhook, #update_outgoing_webhook

Methods included from Endpoint::Users

#attach_mobile_device, #autocomplete_users, #check_mfa, #create_user, #create_user_access_token, #deativate_user_account, #disable_personal_access_token, #enable_personal_access_token, #generate_mfa_secret, #get_me, #get_user, #get_user_access_token, #get_user_access_tokens, #get_user_audits, #get_user_by_email, #get_user_by_username, #get_user_profile_image, #get_user_profile_image_url, #get_user_sessions, #get_users, #get_users_by_ids, #get_users_by_usernames, #patch_user, #reset_password, #revoke_all_active_session_for_user, #revoke_user_access_token, #revoke_user_session, #search_users, #send_password_reset_email, #send_verification_email, #set_user_profile_image, #switch_login_method, #update_user, #update_user_active_status, #update_user_authentication_method, #update_user_mfa, #update_user_password, #update_user_roles, #verify_user_email

Methods included from Endpoint::Teams

#add_user_to_team, #add_user_to_team_from_invite, #add_users_to_team, #create_team, #delete_team, #get_invite_info, #get_team, #get_team_by_name, #get_team_member, #get_team_members, #get_team_members_by_ids, #get_team_members_for_user, #get_team_stats, #get_team_unreads, #get_teams, #get_teams_for_user, #get_unreads_for_team, #invite_users_by_email, #patch_team, #remove_user_from_team, #search_teams, #team_exists?, #update_team, #update_team_member_role

Methods included from Endpoint::System

#add_log_message, #get_analytics, #get_audits, #get_client_configuration, #get_client_license, #get_configuration, #get_logs, #get_webrtc_token, #invalidate_server_caches, #ping, #recycle_database_connections, #reload_configuration, #remove_license_file, #send_test_email, #update_configuration, #upload_license_file

Methods included from Endpoint::Status

#get_user_status, #get_user_statuses_by_id, #update_user_status

Methods included from Endpoint::SAML

#get_certificate_status, #get_saml_metadata, #remove_idp_certificate, #remove_private_key, #remove_public_certificate, #upload_idp_certificate, #upload_private_key, #upload_public_certificate

Methods included from Endpoint::Preferences

#delete_user_preferences, #get_user_preference, #get_user_preferences, #list_user_preferences_by_category, #save_user_perferences

Methods included from Endpoint::Posts

#create_post, #delete_post, #get_file_info_for_post, #get_flagged_posts, #get_post, #get_posts_for_channel, #get_thread, #patch_post, #perform_post_action, #pin_post, #search_team_posts, #unpin_post, #update_post

Methods included from Endpoint::Plugins

#activate_plugin, #deactivate_plugin, #get_plugins, #get_webapp_plugins, #remove_plugin, #upload_plugin

Methods included from Endpoint::OAuth

#delete_oauth_app, #get_authorized_oauth_apps, #get_oauth_app, #get_oauth_app_info, #get_oauth_apps, #regenerate_oauth_app_secret, #register_oauth_app, #update_oauth_app

Methods included from Endpoint::LDAP

#sync_with_ldap, #test_ldap_configuration

Methods included from Endpoint::Jobs

#cancel_job, #create_job, #get_job, #get_jobs, #get_jobs_of_type

Methods included from Endpoint::Files

#get_file, #get_file_preview, #get_file_preview_url, #get_file_thumbnail, #get_file_thumbnail_url, #get_file_url, #get_metadata_for_file, #get_public_file_link, #upload_file

Methods included from Endpoint::Emoji

#create_custom_emoji, #delete_custom_emoji, #get_custom_emoji, #get_custom_emoji_image, #get_custom_emoji_image_url, #get_custom_emoji_list

Methods included from Endpoint::Elasticsearch

#purge_elasticsearch_indexes, #test_elasticsearch_configuration

Methods included from Endpoint::DataRetention

#get_data_retention_policy_details

Methods included from Endpoint::Compliance

#create_compliance_report, #download_compliance_report, #download_compliance_report_url, #get_compliance_report, #get_compliance_reports

Methods included from Endpoint::Commands

#create_command, #delete_command, #execute_command, #list_autocomplete_commands, #list_commands, #regenerate_command_token, #update_command

Methods included from Endpoint::Cluster

#get_cluster_status

Methods included from Endpoint::Channels

#add_user_to_channel, #create_channel, #create_direct_channel, #create_group_message, #delete_channel, #get_channel, #get_channel_by_name, #get_channel_by_name_and_team_name, #get_channel_list_by_ids, #get_channel_member, #get_channel_members, #get_channel_members_by_ids, #get_channel_members_for_user, #get_channel_stats, #get_channels_for_user, #get_deleted_channels, #get_pinned_posts, #get_public_channels, #get_unread_messages, #patch_channel, #remove_user_from_channel, #restore_channel, #search_channels, #update_channel, #update_channel_notifications, #update_channel_roles, #view_channel

Methods included from Endpoint::Brand

#get_brand_image, #get_brand_image_url, #upload_brand_image

Constructor Details

#initialize(server) ⇒ Client

Returns a new instance of Client.



20
21
22
23
24
# File 'lib/mattermost/client.rb', line 20

def initialize(server)
	self.server = URI.join(server, '/').to_s
	self.subdir = URI(server).path
	self.headers = {:Accept => "application/json"}
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



12
13
14
# File 'lib/mattermost/client.rb', line 12

def headers
  @headers
end

#serverObject

Returns the value of attribute server.



12
13
14
# File 'lib/mattermost/client.rb', line 12

def server
  @server
end

#subdirObject

Returns the value of attribute subdir.



12
13
14
# File 'lib/mattermost/client.rb', line 12

def subdir
  @subdir
end

#tokenObject

Returns the value of attribute token.



12
13
14
# File 'lib/mattermost/client.rb', line 12

def token
  @token
end

Instance Method Details

#base_uriObject

DEPRECATED I’ll remove this method soon



15
16
17
# File 'lib/mattermost/client.rb', line 15

def base_uri
	"#{server}/api/v4"
end

#connect_websocket {|@ws_client| ... } ⇒ Object

Yields:



47
48
49
50
51
52
# File 'lib/mattermost/client.rb', line 47

def connect_websocket
	# TODO raise exception then connected? == false
	@ws_client = WebSocketClient.new "#{base_uri}/websocket", token, {:headers => self.headers}
	yield @ws_client if block_given?
	@ws_client
end

#connected?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/mattermost/client.rb', line 43

def connected?
	get_me.success?
end

#login(username, password) ⇒ Object



26
27
28
29
30
# File 'lib/mattermost/client.rb', line 26

def (username, password)
	 = post('/users/login', :body => {:login_id => username, :password => password}.to_json)
	self.token = .headers['token']
	update_token
end

#logoutObject



32
33
34
35
36
# File 'lib/mattermost/client.rb', line 32

def logout
	post("/users/logout")
	self.token = nil
	update_token
end

#use_access_token(token) ⇒ Object



38
39
40
41
# File 'lib/mattermost/client.rb', line 38

def use_access_token(token)
	self.token = token
	update_token
end

#ws_clientObject



54
55
56
# File 'lib/mattermost/client.rb', line 54

def ws_client
	@ws_client
end