Class: Slack::API::Groups

Inherits:
Base
  • Object
show all
Defined in:
lib/laziness/api/groups.rb

Instance Attribute Summary

Attributes inherited from Base

#access_token

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Slack::API::Base

Instance Method Details

#all(exclude_archived = false, page: nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/laziness/api/groups.rb', line 4

def all(exclude_archived=false, page: nil)
  responses = with_paging(page) do |pager|
    request :get,
            'groups.list',
            exclude_archived: exclude_archived ? 1 : 0,
            **pager.to_h
  end

  Slack::Group.parse_all responses, 'groups'
end

#archive(id) ⇒ Object



15
16
17
# File 'lib/laziness/api/groups.rb', line 15

def archive(id)
  with_nil_response { request :post, 'groups.archive', channel: id }
end

#close(id) ⇒ Object



19
20
21
# File 'lib/laziness/api/groups.rb', line 19

def close(id)
  with_nil_response { request :post, 'groups.close', channel: id }
end

#copy(id) ⇒ Object



23
24
25
26
# File 'lib/laziness/api/groups.rb', line 23

def copy(id)
  response = request :post, 'groups.createChild', channel: id
  Slack::Group.parse response, 'group'
end

#create(name) ⇒ Object



28
29
30
31
# File 'lib/laziness/api/groups.rb', line 28

def create(name)
  response = request :post, 'groups.create', name: name
  Slack::Group.parse response, 'group'
end

#find(id) ⇒ Object



33
34
35
36
# File 'lib/laziness/api/groups.rb', line 33

def find(id)
  response = request :get, 'groups.info', channel: id
  Slack::Group.parse response, 'group'
end

#invite(id, user_id) ⇒ Object



38
39
40
41
# File 'lib/laziness/api/groups.rb', line 38

def invite(id, user_id)
  response = request :post, 'groups.invite', channel: id, user: user_id
  Slack::Group.parse response, 'group'
end

#kick(id, user_id) ⇒ Object



43
44
45
# File 'lib/laziness/api/groups.rb', line 43

def kick(id, user_id)
  with_nil_response { request :post, 'groups.kick', channel: id, user: user_id }
end

#leave(id) ⇒ Object



47
48
49
# File 'lib/laziness/api/groups.rb', line 47

def leave(id)
  with_nil_response { request :post, 'groups.leave', channel: id }
end

#open(id) ⇒ Object



51
52
53
# File 'lib/laziness/api/groups.rb', line 51

def open(id)
  with_nil_response { request :post, 'groups.open', channel: id }
end

#unarchive(id) ⇒ Object



55
56
57
# File 'lib/laziness/api/groups.rb', line 55

def unarchive(id)
  with_nil_response { request :post, 'groups.unarchive', channel: id }
end

#update_purpose(id, purpose) ⇒ Object



59
60
61
# File 'lib/laziness/api/groups.rb', line 59

def update_purpose(id, purpose)
  with_nil_response { request :post, 'groups.setPurpose', channel: id, purpose: purpose }
end

#update_topic(id, topic) ⇒ Object



63
64
65
# File 'lib/laziness/api/groups.rb', line 63

def update_topic(id, topic)
  with_nil_response { request :post, 'groups.setTopic', channel: id, topic: topic }
end