Class: SlackChatter::Api::Channels

Inherits:
Base
  • Object
show all
Defined in:
lib/slack_chatter/api/channels.rb

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#bool_as_i, #call_method, #channel_id_or_name, #initialize

Constructor Details

This class inherits a constructor from SlackChatter::Api::Base

Instance Method Details

#archive(channel_id) ⇒ Object



12
13
14
# File 'lib/slack_chatter/api/channels.rb', line 12

def archive channel_id
  call_method("channels", "archive", {"channel" => channel_id})
end

#create(channel_name) ⇒ Object



16
17
18
19
# File 'lib/slack_chatter/api/channels.rb', line 16

def create channel_name
  # channel_name    - name of channel to recreate
  call_method("channels", "create", {"name" => channel_name})
end

#find_by_name(name) ⇒ Object



6
7
8
9
10
# File 'lib/slack_chatter/api/channels.rb', line 6

def find_by_name name
  list.channels.detect do |channel|
    channel["name"] == name
  end["id"]
end

#history(channel_id, opts = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/slack_chatter/api/channels.rb', line 21

def history channel_id, opts={}
  # latest          - End of time range of messages to include in results
  # oldest          - Start of time range of messages to include in results
  # inclusive       - Include messages with latest or oldest timestamp in results (send 0/1)
  # count           - Number of messages to return, between 1 and 1000
  call_method("channels", "history", {"channel" => channel_id}.merge(opts))
end

#info(channel_id) ⇒ Object



29
30
31
# File 'lib/slack_chatter/api/channels.rb', line 29

def info channel_id
  call_method("channels", "info", {"channel" => channel_id})
end

#invite(channel_id, user_id) ⇒ Object



33
34
35
# File 'lib/slack_chatter/api/channels.rb', line 33

def invite channel_id, user_id
  call_method("channels", "invite", {"channel" => channel_id, "user" => user_id})
end

#join(channel_name) ⇒ Object



37
38
39
# File 'lib/slack_chatter/api/channels.rb', line 37

def join channel_name
  call_method("channels", "join", {"name" => channel_name})
end

#kick(channel_id, user_id) ⇒ Object



41
42
43
# File 'lib/slack_chatter/api/channels.rb', line 41

def kick channel_id, user_id
  call_method("channels", "kick", {"channel" => channel_id, "user" => user_id})
end

#leave(channel_id) ⇒ Object



45
46
47
# File 'lib/slack_chatter/api/channels.rb', line 45

def leave channel_id
  call_method("channels", "leave", {"channel" => channel_id})
end

#list(exclude_archived = false) ⇒ Object



49
50
51
52
# File 'lib/slack_chatter/api/channels.rb', line 49

def list exclude_archived=false
  # exclude_archives - Don't return archived channels (send 0/1)
  call_method("channels", "list", {"exclude_archived" => bool_as_i(exclude_archived)})
end

#mark(channel_id, epoch_time_stamp) ⇒ Object



54
55
56
57
# File 'lib/slack_chatter/api/channels.rb', line 54

def mark channel_id, epoch_time_stamp
  # ts               - Timestamp of the most recently seen message
  call_method("channels", "mark", {"channel" => channel_id, "ts" => epoch_time_stamp})
end

#rename(channel_id, new_name) ⇒ Object



59
60
61
62
# File 'lib/slack_chatter/api/channels.rb', line 59

def rename channel_id, new_name
  # new_name         - New name for channel
  call_method("channels", "rename", {"channel" => channel_id, "name" => new_name})
end

#set_purpose(channel_id, purpose) ⇒ Object



64
65
66
67
# File 'lib/slack_chatter/api/channels.rb', line 64

def set_purpose channel_id, purpose
  # purpose          - The new purpose for the channel
  call_method("channels", "setPurpose", {"channel" => channel_id, "purpose" => purpose})
end

#set_topic(channel_id, topic) ⇒ Object



69
70
71
72
# File 'lib/slack_chatter/api/channels.rb', line 69

def set_topic channel_id, topic
  # topic            - The new topic for the channel
  call_method("channels", "setTopic", {"channel" => channel_id, "topic" => topic})
end

#unarchive(channel_id) ⇒ Object



74
75
76
# File 'lib/slack_chatter/api/channels.rb', line 74

def unarchive channel_id
  call_method("channels", "unarchive", {"channel"=> channel_id})
end