laziness 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +0 -1
- data/Gemfile.lock +15 -10
- data/lib/laziness/api/conversations.rb +111 -0
- data/lib/laziness/api.rb +1 -0
- data/lib/laziness/conversation.rb +4 -0
- data/lib/laziness/version.rb +1 -1
- data/lib/laziness.rb +1 -0
- data/spec/laziness/api/conversations_spec.rb +178 -0
- data/spec/support/fixtures/conversations_info.json +28 -0
- data/spec/support/fixtures/conversations_list.json +30 -0
- data/spec/support/fixtures/conversations_members.json +7 -0
- metadata +13 -4
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 58788f9549042941c5cc09f811de8748bbe0e17a0cdaa2b2e95dc6fa69bf35e4
|
4
|
+
data.tar.gz: b4d8397d13b1dfa394d047073759e3b92a026cb677a93c973c14c57948e04704
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07abb19efc51e54e18b0989c1f4ebadc5a1d45fd244871bd17928cc73ca3fea2f957d24e09a64fec907600c44b83847cdf54762e556d78010387a4d5b09665ea
|
7
|
+
data.tar.gz: edebed0ac8c76951c858e439c0cdaece4c37178dd0858e3faf0fe03026586f2037eac92af158ac396b8479cbfbaee9503ce843979de48260385289d73e73bde4
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
laziness (0.2.
|
4
|
+
laziness (0.2.2)
|
5
5
|
eventmachine
|
6
6
|
faye-websocket (>= 0.8.0)
|
7
7
|
hashie
|
@@ -14,16 +14,18 @@ GEM
|
|
14
14
|
crack (0.4.2)
|
15
15
|
safe_yaml (~> 1.0.0)
|
16
16
|
diff-lcs (1.2.5)
|
17
|
-
eventmachine (1.
|
18
|
-
faye-websocket (0.10.
|
17
|
+
eventmachine (1.2.7)
|
18
|
+
faye-websocket (0.10.7)
|
19
19
|
eventmachine (>= 0.12.0)
|
20
20
|
websocket-driver (>= 0.5.1)
|
21
|
-
hashie (3.
|
22
|
-
httparty (0.
|
23
|
-
|
21
|
+
hashie (3.6.0)
|
22
|
+
httparty (0.16.4)
|
23
|
+
mime-types (~> 3.0)
|
24
24
|
multi_xml (>= 0.5.2)
|
25
|
-
|
26
|
-
|
25
|
+
mime-types (3.2.2)
|
26
|
+
mime-types-data (~> 3.2015)
|
27
|
+
mime-types-data (3.2018.0812)
|
28
|
+
multi_xml (0.6.0)
|
27
29
|
rake (10.3.2)
|
28
30
|
rspec (3.1.0)
|
29
31
|
rspec-core (~> 3.1.0)
|
@@ -41,9 +43,9 @@ GEM
|
|
41
43
|
webmock (1.18.0)
|
42
44
|
addressable (>= 2.3.6)
|
43
45
|
crack (>= 0.3.2)
|
44
|
-
websocket-driver (0.
|
46
|
+
websocket-driver (0.7.0)
|
45
47
|
websocket-extensions (>= 0.1.0)
|
46
|
-
websocket-extensions (0.1.
|
48
|
+
websocket-extensions (0.1.3)
|
47
49
|
|
48
50
|
PLATFORMS
|
49
51
|
ruby
|
@@ -53,3 +55,6 @@ DEPENDENCIES
|
|
53
55
|
rake
|
54
56
|
rspec
|
55
57
|
webmock
|
58
|
+
|
59
|
+
BUNDLED WITH
|
60
|
+
1.16.6
|
@@ -0,0 +1,111 @@
|
|
1
|
+
module Slack
|
2
|
+
module API
|
3
|
+
class Conversations < Base
|
4
|
+
def all(exclude_archived=false, types='public_channel')
|
5
|
+
response = request :get,
|
6
|
+
'conversations.list',
|
7
|
+
exclude_archived: exclude_archived ? 1 : 0,
|
8
|
+
types: types
|
9
|
+
|
10
|
+
Slack::Conversation.parse response, 'channels'
|
11
|
+
end
|
12
|
+
|
13
|
+
def archive(id)
|
14
|
+
with_nil_response { request :post, 'conversations.archive', channel: id }
|
15
|
+
end
|
16
|
+
|
17
|
+
def close(id)
|
18
|
+
with_nil_response { request :post, 'conversations.close', channel: id }
|
19
|
+
end
|
20
|
+
|
21
|
+
def create(name, is_private=false, user_ids=[])
|
22
|
+
response = request :post,
|
23
|
+
'conversations.create',
|
24
|
+
name: name,
|
25
|
+
is_private: is_private,
|
26
|
+
user_ids: user_ids
|
27
|
+
|
28
|
+
Slack::Conversation.parse response, 'channel'
|
29
|
+
end
|
30
|
+
|
31
|
+
def find(id)
|
32
|
+
response = request :get, 'conversations.info', channel: id
|
33
|
+
Slack::Conversation.parse response, 'channel'
|
34
|
+
end
|
35
|
+
|
36
|
+
def invite(id, users)
|
37
|
+
response = request :post,
|
38
|
+
'conversations.invite',
|
39
|
+
channel: id,
|
40
|
+
users: users.join(",")
|
41
|
+
|
42
|
+
Slack::Conversation.parse response, 'channel'
|
43
|
+
end
|
44
|
+
|
45
|
+
def join(id)
|
46
|
+
response = request :post,
|
47
|
+
'conversations.join',
|
48
|
+
channel: id
|
49
|
+
|
50
|
+
Slack::Conversation.parse response, 'channel'
|
51
|
+
end
|
52
|
+
|
53
|
+
def kick(id, user)
|
54
|
+
with_nil_response { request :post, 'conversations.kick', channel: id, user: user }
|
55
|
+
end
|
56
|
+
|
57
|
+
def leave(id)
|
58
|
+
with_nil_response { request :post, 'conversations.leave', channel: id }
|
59
|
+
end
|
60
|
+
|
61
|
+
def members(id)
|
62
|
+
response = request :get,
|
63
|
+
'conversations.members',
|
64
|
+
channel: id
|
65
|
+
|
66
|
+
JSON.parse(response)["members"]
|
67
|
+
end
|
68
|
+
|
69
|
+
def open(users=[], id=nil, return_im: false)
|
70
|
+
response = request :post,
|
71
|
+
'conversations.open',
|
72
|
+
channel: id,
|
73
|
+
users: (users || []).join(","),
|
74
|
+
return_im: return_im
|
75
|
+
|
76
|
+
Slack::Conversation.parse response, 'channel'
|
77
|
+
end
|
78
|
+
|
79
|
+
def rename(id, name)
|
80
|
+
response = request :post,
|
81
|
+
'conversations.rename',
|
82
|
+
channel: id,
|
83
|
+
name: name
|
84
|
+
|
85
|
+
Slack::Conversation.parse response, 'channel'
|
86
|
+
end
|
87
|
+
|
88
|
+
def set_purpose(id, purpose)
|
89
|
+
with_nil_response do
|
90
|
+
request :post,
|
91
|
+
'conversations.setPurpose',
|
92
|
+
channel: id,
|
93
|
+
purpose: purpose
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def set_topic(id, topic)
|
98
|
+
with_nil_response do
|
99
|
+
request :post,
|
100
|
+
'conversations.setTopic',
|
101
|
+
channel: id,
|
102
|
+
topic: topic
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def unarchive(id)
|
107
|
+
with_nil_response { request :post, 'conversations.unarchive', channel: id }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/lib/laziness/api.rb
CHANGED
data/lib/laziness/version.rb
CHANGED
data/lib/laziness.rb
CHANGED
@@ -0,0 +1,178 @@
|
|
1
|
+
describe Slack::API::Conversations do
|
2
|
+
let(:access_token) { "12345" }
|
3
|
+
subject { Slack::API::Conversations.new access_token }
|
4
|
+
|
5
|
+
describe '.all' do
|
6
|
+
it 'returns all the channels for a team' do
|
7
|
+
stub_slack_request :get,
|
8
|
+
"conversations.list?token=#{access_token}&exclude_archived=0&"\
|
9
|
+
"types=public_channel",
|
10
|
+
"conversations_list.json"
|
11
|
+
|
12
|
+
conversations = subject.all
|
13
|
+
expect(conversations.length).to eq 1
|
14
|
+
expect(conversations[0].id).to eq "C02BLAH"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '.archive' do
|
19
|
+
it 'marks the channel as archived' do
|
20
|
+
stub = stub_slack_request :post,
|
21
|
+
"conversations.archive?channel=C02BLAH&token=#{access_token}",
|
22
|
+
'successful_response.json'
|
23
|
+
|
24
|
+
expect(subject.archive("C02BLAH")).to be_nil
|
25
|
+
expect(stub).to have_been_requested
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '.close' do
|
30
|
+
it 'closes a direct message channel' do
|
31
|
+
stub = stub_slack_request :post,
|
32
|
+
"conversations.close?channel=G01BLAH&token=#{access_token}",
|
33
|
+
'successful_response.json'
|
34
|
+
|
35
|
+
expect(subject.close("G01BLAH")).to be_nil
|
36
|
+
expect(stub).to have_been_requested
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '.create' do
|
41
|
+
it 'creates a new channel and returns the specified channel' do
|
42
|
+
stub_slack_request :post,
|
43
|
+
"conversations.create?name=tour&is_private=false&"\
|
44
|
+
"user_ids=[]&token=#{access_token}",
|
45
|
+
'conversations_info.json'
|
46
|
+
|
47
|
+
conversation = subject.create("tour")
|
48
|
+
expect(conversation.id).to eq "C02BLAH"
|
49
|
+
expect(conversation.name).to eq "tour"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe '.find' do
|
54
|
+
it 'returns the specific channel with the specified id' do
|
55
|
+
stub_slack_request :get,
|
56
|
+
"conversations.info?channel=C02BLAH&token=#{access_token}",
|
57
|
+
'conversations_info.json'
|
58
|
+
|
59
|
+
conversation = subject.find("C02BLAH")
|
60
|
+
expect(conversation.id).to eq "C02BLAH"
|
61
|
+
expect(conversation.name).to eq "tour"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '.invite' do
|
66
|
+
it 'invites users to a channel and returns the specified channel' do
|
67
|
+
stub_slack_request :post,
|
68
|
+
"conversations.invite?channel=tour&"\
|
69
|
+
"users=U024BLAH,U025BLAH&token=#{access_token}",
|
70
|
+
'conversations_info.json'
|
71
|
+
|
72
|
+
conversation = subject.invite("tour", ["U024BLAH", "U025BLAH"])
|
73
|
+
expect(conversation.id).to eq "C02BLAH"
|
74
|
+
expect(conversation.name).to eq "tour"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '.join' do
|
79
|
+
it 'joins the current user to the specific channel' do
|
80
|
+
stub_slack_request :post,
|
81
|
+
"conversations.join?channel=C02BLAH&token=#{access_token}",
|
82
|
+
'conversations_info.json'
|
83
|
+
|
84
|
+
conversation = subject.join("C02BLAH")
|
85
|
+
expect(conversation.id).to eq "C02BLAH"
|
86
|
+
expect(conversation.name).to eq "tour"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '.kick' do
|
91
|
+
it 'removes a user from a channel' do
|
92
|
+
stub = stub_slack_request :post,
|
93
|
+
"conversations.kick?channel=G01BLAH&user=U024BLAH&token=#{access_token}",
|
94
|
+
'successful_response.json'
|
95
|
+
|
96
|
+
expect(subject.kick("G01BLAH", "U024BLAH")).to be_nil
|
97
|
+
expect(stub).to have_been_requested
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '.leave' do
|
102
|
+
it 'removes the current user from a channel' do
|
103
|
+
stub = stub_slack_request :post,
|
104
|
+
"conversations.leave?channel=G01BLAH&token=#{access_token}",
|
105
|
+
'successful_response.json'
|
106
|
+
|
107
|
+
expect(subject.leave("G01BLAH")).to be_nil
|
108
|
+
expect(stub).to have_been_requested
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '.members' do
|
113
|
+
it 'returns all the users from a channel' do
|
114
|
+
stub = stub_slack_request :get,
|
115
|
+
"conversations.members?channel=C02BLAH&token=#{access_token}",
|
116
|
+
'conversations_members.json'
|
117
|
+
|
118
|
+
members = subject.members("C02BLAH")
|
119
|
+
expect(members).to eq ["U024BLAH", "U024BLAH2"]
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '.open' do
|
124
|
+
it 'opens a direct message channel' do
|
125
|
+
stub_slack_request :post,
|
126
|
+
"conversations.open?return_im=false&users=U024BLAH,U025BLAH&token=#{access_token}",
|
127
|
+
'conversations_info.json'
|
128
|
+
|
129
|
+
conversation = subject.open(["U024BLAH", "U025BLAH"])
|
130
|
+
expect(conversation.id).to eq "C02BLAH"
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
describe '.rename' do
|
135
|
+
it 'renames the channel' do
|
136
|
+
stub_slack_request :post,
|
137
|
+
"conversations.rename?channel=C02BLAH&name=tour&token=#{access_token}",
|
138
|
+
'conversations_info.json'
|
139
|
+
|
140
|
+
conversation = subject.rename("C02BLAH", "tour")
|
141
|
+
expect(conversation.id).to eq "C02BLAH"
|
142
|
+
expect(conversation.name).to eq "tour"
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
describe '.set_purpose' do
|
147
|
+
it 'sets the purpose for a channel' do
|
148
|
+
stub = stub_slack_request :post,
|
149
|
+
"conversations.setPurpose?channel=G01BLAH&purpose=new%20purpose&token=#{access_token}",
|
150
|
+
'successful_response.json'
|
151
|
+
|
152
|
+
expect(subject.set_purpose("G01BLAH", "new purpose")).to be_nil
|
153
|
+
expect(stub).to have_been_requested
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe '.set_topic' do
|
158
|
+
it 'sets the topic for a channel' do
|
159
|
+
stub = stub_slack_request :post,
|
160
|
+
"conversations.setTopic?channel=G01BLAH&topic=new%20topic&token=#{access_token}",
|
161
|
+
'successful_response.json'
|
162
|
+
|
163
|
+
expect(subject.set_topic("G01BLAH", "new topic")).to be_nil
|
164
|
+
expect(stub).to have_been_requested
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe '.unarchive' do
|
169
|
+
it 'marks the channel as unarchived' do
|
170
|
+
stub = stub_slack_request :post,
|
171
|
+
"conversations.unarchive?channel=C02BLAH&token=#{access_token}",
|
172
|
+
'successful_response.json'
|
173
|
+
|
174
|
+
expect(subject.unarchive("C02BLAH")).to be_nil
|
175
|
+
expect(stub).to have_been_requested
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"ok": true,
|
3
|
+
"channel": {
|
4
|
+
"id": "C02BLAH",
|
5
|
+
"name": "tour",
|
6
|
+
"is_channel": true,
|
7
|
+
"created": 1403798029,
|
8
|
+
"creator": "U024BLAH",
|
9
|
+
"is_archived": false,
|
10
|
+
"is_general": false,
|
11
|
+
"is_member": true,
|
12
|
+
"members": [
|
13
|
+
"U024BLAH",
|
14
|
+
"U024BLAH2"
|
15
|
+
],
|
16
|
+
"topic": {
|
17
|
+
"value": "",
|
18
|
+
"creator": "",
|
19
|
+
"last_set": 0
|
20
|
+
},
|
21
|
+
"purpose": {
|
22
|
+
"value": "A place to discuss the upcoming tour",
|
23
|
+
"creator": "U024BLAH",
|
24
|
+
"last_set": 1403798029
|
25
|
+
},
|
26
|
+
"num_members": 2
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"ok": true,
|
3
|
+
"channels": [
|
4
|
+
{
|
5
|
+
"id": "C02BLAH",
|
6
|
+
"name": "tour",
|
7
|
+
"is_channel": true,
|
8
|
+
"created": 1403798029,
|
9
|
+
"creator": "U024BLAH",
|
10
|
+
"is_archived": false,
|
11
|
+
"is_general": false,
|
12
|
+
"is_member": true,
|
13
|
+
"members": [
|
14
|
+
"U024BLAH",
|
15
|
+
"U024BLAH2"
|
16
|
+
],
|
17
|
+
"topic": {
|
18
|
+
"value": "",
|
19
|
+
"creator": "",
|
20
|
+
"last_set": 0
|
21
|
+
},
|
22
|
+
"purpose": {
|
23
|
+
"value": "A place to discuss the upcoming tour",
|
24
|
+
"creator": "U024BLAH",
|
25
|
+
"last_set": 1403798029
|
26
|
+
},
|
27
|
+
"num_members": 2
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: laziness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -76,7 +76,6 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
|
-
- ".ruby-version"
|
80
79
|
- Gemfile
|
81
80
|
- Gemfile.lock
|
82
81
|
- LICENSE
|
@@ -89,6 +88,7 @@ files:
|
|
89
88
|
- lib/laziness/api/base.rb
|
90
89
|
- lib/laziness/api/channels.rb
|
91
90
|
- lib/laziness/api/chat.rb
|
91
|
+
- lib/laziness/api/conversations.rb
|
92
92
|
- lib/laziness/api/groups.rb
|
93
93
|
- lib/laziness/api/im.rb
|
94
94
|
- lib/laziness/api/oauth.rb
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/laziness/channel.rb
|
100
100
|
- lib/laziness/chat.rb
|
101
101
|
- lib/laziness/client.rb
|
102
|
+
- lib/laziness/conversation.rb
|
102
103
|
- lib/laziness/errors.rb
|
103
104
|
- lib/laziness/group.rb
|
104
105
|
- lib/laziness/message.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- spec/laziness/api/auth_spec.rb
|
113
114
|
- spec/laziness/api/channels_spec.rb
|
114
115
|
- spec/laziness/api/chat_spec.rb
|
116
|
+
- spec/laziness/api/conversations_spec.rb
|
115
117
|
- spec/laziness/api/groups_spec.rb
|
116
118
|
- spec/laziness/api/im_spec.rb
|
117
119
|
- spec/laziness/api/oauth_spec.rb
|
@@ -130,6 +132,9 @@ files:
|
|
130
132
|
- spec/support/fixtures/chat_delete.json
|
131
133
|
- spec/support/fixtures/chat_post_message.json
|
132
134
|
- spec/support/fixtures/chat_update.json
|
135
|
+
- spec/support/fixtures/conversations_info.json
|
136
|
+
- spec/support/fixtures/conversations_list.json
|
137
|
+
- spec/support/fixtures/conversations_members.json
|
133
138
|
- spec/support/fixtures/groups_info.json
|
134
139
|
- spec/support/fixtures/groups_list.json
|
135
140
|
- spec/support/fixtures/im_close.json
|
@@ -162,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
167
|
version: '0'
|
163
168
|
requirements: []
|
164
169
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
170
|
+
rubygems_version: 2.7.3
|
166
171
|
signing_key:
|
167
172
|
specification_version: 4
|
168
173
|
summary: A Slack API wrapper written in Ruby.
|
@@ -170,6 +175,7 @@ test_files:
|
|
170
175
|
- spec/laziness/api/auth_spec.rb
|
171
176
|
- spec/laziness/api/channels_spec.rb
|
172
177
|
- spec/laziness/api/chat_spec.rb
|
178
|
+
- spec/laziness/api/conversations_spec.rb
|
173
179
|
- spec/laziness/api/groups_spec.rb
|
174
180
|
- spec/laziness/api/im_spec.rb
|
175
181
|
- spec/laziness/api/oauth_spec.rb
|
@@ -188,6 +194,9 @@ test_files:
|
|
188
194
|
- spec/support/fixtures/chat_delete.json
|
189
195
|
- spec/support/fixtures/chat_post_message.json
|
190
196
|
- spec/support/fixtures/chat_update.json
|
197
|
+
- spec/support/fixtures/conversations_info.json
|
198
|
+
- spec/support/fixtures/conversations_list.json
|
199
|
+
- spec/support/fixtures/conversations_members.json
|
191
200
|
- spec/support/fixtures/groups_info.json
|
192
201
|
- spec/support/fixtures/groups_list.json
|
193
202
|
- spec/support/fixtures/im_close.json
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.1.4
|