Class: Lita::Adapters::Slack::API Private

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/adapters/slack/api.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(config, stubs = nil) ⇒ API

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of API.



13
14
15
16
# File 'lib/lita/adapters/slack/api.rb', line 13

def initialize(config, stubs = nil)
  @config = config
  @stubs = stubs
end

Instance Method Details

#im_open(user_id) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
21
22
# File 'lib/lita/adapters/slack/api.rb', line 18

def im_open(user_id)
  response_data = call_api("im.open", user: user_id)

  SlackIM.new(response_data["channel"]["id"], user_id)
end

#rtm_startObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/lita/adapters/slack/api.rb', line 37

def rtm_start
  response_data = call_api("rtm.start")

  TeamData.new(
    SlackIM.from_data_array(response_data["ims"]),
    SlackUser.from_data(response_data["self"]),
    SlackUser.from_data_array(response_data["users"]),
    SlackChannel.from_data_array(response_data["channels"]) +
      SlackChannel.from_data_array(response_data["groups"]),
    response_data["url"],
  )
end

#send_attachments(room_or_user, attachments) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
28
29
30
31
# File 'lib/lita/adapters/slack/api.rb', line 24

def send_attachments(room_or_user, attachments)
  call_api(
    "chat.postMessage",
    as_user: true,
    channel: room_or_user.id,
    attachments: MultiJson.dump(attachments.map(&:to_hash)),
  )
end

#set_topic(channel, topic) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



33
34
35
# File 'lib/lita/adapters/slack/api.rb', line 33

def set_topic(channel, topic)
  call_api("channels.setTopic", channel: channel, topic: topic)
end