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
# File 'lib/http-client/webapi.rb', line 7

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

.post_ephemeral(msg) ⇒ Object



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

def self.post_ephemeral(msg)
  m = 'chat.postEphemeral'
  url = BaseURL + m
  head = {authorization: "Bearer #{MosEisley.config.bot_access_token}"}
  HTTPClient.post_json(url: url, params: msg, head: head) do |h|
    MosEisley.logger.info('POSTed chat.postEphemeral')
    MosEisley.logger.debug("chat.postEphemeral echo:\n#{h.response}")
  end
end

.post_message(msg) ⇒ Object



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

def self.post_message(msg)
  m = 'chat.postMessage'
  url = BaseURL + m
  head = {authorization: "Bearer #{MosEisley.config.bot_access_token}"}
  HTTPClient.post_json(url: url, params: msg, head: head) do |h|
    MosEisley.logger.info('POSTed chat.postMessage')
    MosEisley.logger.debug("chat.postMessage echo:\n#{h.response}")
  end
end