Class: MosEisley::WebAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/http-client/webapi.rb

Constant Summary collapse

BaseURL =
'https://slack.com/api/'

Class Method Summary collapse

Class Method Details

.auth_testObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/http-client/webapi.rb', line 7

def self.auth_test
  MosEisley.logger.debug('auth_test')
  m = 'auth.test'
  url = BaseURL + m
  params = {token: MosEisley.config.bot_access_token}
  MosEisley.logger.debug("#{url}\n#{params}")
  HTTPClient.post_form(url: url, params: params) do |h|
    MosEisley.config.meta.merge!(S3PO.parse_json(h.response))
    MosEisley.logger.debug("meta data updated:\n#{MosEisley.config.meta}")
  end
end

.post_ephemeral(msg) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/http-client/webapi.rb', line 28

def self.post_ephemeral(msg)
  m = 'chat.postEphemeral'
  url = BaseURL + m
  msg[:token] = MosEisley.config.bot_access_token
  HTTPClient.post_form(url: url, params: msg) do |h|
    MosEisley.logger.debug("chat.postEphemeral POSTed: #{h.response}")
  end
end

.post_message(msg) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/http-client/webapi.rb', line 19

def self.post_message(msg)
  m = 'chat.postMessage'
  url = BaseURL + m
  msg[:token] = MosEisley.config.bot_access_token
  HTTPClient.post_form(url: url, params: msg) do |h|
    MosEisley.logger.debug("chat.postMessage POSTed: #{h.response}")
  end
end