laziness 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +20 -1
- data/lib/laziness/api.rb +1 -0
- data/lib/laziness/api/im.rb +23 -0
- data/lib/laziness/client.rb +4 -0
- data/lib/laziness/version.rb +1 -1
- data/spec/laziness/api/im_spec.rb +37 -0
- data/spec/support/fixtures/im_close.json +5 -0
- data/spec/support/fixtures/im_list.json +12 -0
- data/spec/support/fixtures/im_mark.json +3 -0
- data/spec/support/fixtures/im_open.json +8 -0
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce0c66afb39c65e3221314a5a2de1d78b279f49e
|
4
|
+
data.tar.gz: 5660fed1096bdac03511550603d90f61ad1d6e60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 013f4938d48b420f586b1e3cfd43a536ec10f02a4ccad1a61e8faab9adceb689950497803b4161b9d47805f606b1edca1b7e1fee1a0d77ba019969aa55fe22a5
|
7
|
+
data.tar.gz: 029f2c56b23cdfeb7a9b07167092fb449a5eea661e142fdc2e9157f19aecbac04907aefc07efe80029e75385bc874e978b58c11e4e692d3c3ef00751704786fc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
laziness (0.1.
|
4
|
+
laziness (0.1.8)
|
5
5
|
eventmachine
|
6
6
|
faye-websocket (>= 0.8.0)
|
7
7
|
hashie
|
@@ -15,7 +15,7 @@ GEM
|
|
15
15
|
safe_yaml (~> 1.0.0)
|
16
16
|
diff-lcs (1.2.5)
|
17
17
|
eventmachine (1.0.8)
|
18
|
-
faye-websocket (0.10.
|
18
|
+
faye-websocket (0.10.1)
|
19
19
|
eventmachine (>= 0.12.0)
|
20
20
|
websocket-driver (>= 0.5.1)
|
21
21
|
hashie (3.4.3)
|
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
webmock (1.18.0)
|
42
42
|
addressable (>= 2.3.6)
|
43
43
|
crack (>= 0.3.2)
|
44
|
-
websocket-driver (0.6.
|
44
|
+
websocket-driver (0.6.3)
|
45
45
|
websocket-extensions (>= 0.1.0)
|
46
46
|
websocket-extensions (0.1.2)
|
47
47
|
|
data/README.md
CHANGED
@@ -100,6 +100,21 @@ client.groups.update_topic(group_id, topic) # updates the topic for the specific
|
|
100
100
|
|
101
101
|
### IM
|
102
102
|
|
103
|
+
```
|
104
|
+
client.im.all # lists all the direct message channels available for your account
|
105
|
+
client.im.open # opens a direct message channel with a specific user
|
106
|
+
client.im.close # closes a direct message channel
|
107
|
+
client.im.mark # specifies where the channel's messages were last read
|
108
|
+
```
|
109
|
+
|
110
|
+
#### TODO:
|
111
|
+
|
112
|
+
- [ ] [im.history](https://api.slack.com/methods/im.history)
|
113
|
+
|
114
|
+
### MPIM
|
115
|
+
|
116
|
+
### API
|
117
|
+
|
103
118
|
### Auth
|
104
119
|
|
105
120
|
```
|
@@ -112,7 +127,9 @@ client.auth.test # get info about a specific oauth token
|
|
112
127
|
client.oauth.access(client_id, client_secret, code, redirect_uri) # exchange api token for code
|
113
128
|
```
|
114
129
|
|
115
|
-
###
|
130
|
+
### Pins
|
131
|
+
|
132
|
+
### Reactions
|
116
133
|
|
117
134
|
### RTM
|
118
135
|
|
@@ -124,6 +141,8 @@ client.rtm.start # get an rtm session back with a url for connecting
|
|
124
141
|
|
125
142
|
### Stars
|
126
143
|
|
144
|
+
### Teams
|
145
|
+
|
127
146
|
### Users
|
128
147
|
|
129
148
|
```
|
data/lib/laziness/api.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Slack
|
2
|
+
module API
|
3
|
+
class IM < Base
|
4
|
+
def all
|
5
|
+
response = request :get, 'im.list'
|
6
|
+
Slack::Channel.parse response, 'ims'
|
7
|
+
end
|
8
|
+
|
9
|
+
def close(channel)
|
10
|
+
with_nil_response { request :post, 'im.close', channel: channel }
|
11
|
+
end
|
12
|
+
|
13
|
+
def mark(channel, timestamp)
|
14
|
+
with_nil_response { request :post, 'im.mark', channel: channel, ts: timestamp }
|
15
|
+
end
|
16
|
+
|
17
|
+
def open(user_id)
|
18
|
+
response = request :post, 'im.open', { user: user_id }
|
19
|
+
Slack::Channel.parse response, 'channel'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/laziness/client.rb
CHANGED
data/lib/laziness/version.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
describe Slack::API::IM do
|
2
|
+
let(:access_token) { "12345" }
|
3
|
+
subject { Slack::API::IM.new access_token }
|
4
|
+
|
5
|
+
describe ".all" do
|
6
|
+
it "returns all the direct message channels for an account" do
|
7
|
+
stub_slack_request :get, "im.list?token=#{access_token}", "im_list.json"
|
8
|
+
channels = subject.all
|
9
|
+
expect(channels.length).to eq 1
|
10
|
+
expect(channels[0].id).to eq "D02BLAH"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".close" do
|
15
|
+
it "closes a direct message channel" do
|
16
|
+
stub = stub_slack_request :post, "im.close?channel=D02BLAH&token=#{access_token}", "im_close.json"
|
17
|
+
expect(subject.close("D02BLAH")).to be_nil
|
18
|
+
expect(stub).to have_been_requested
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe ".mark" do
|
23
|
+
it "moves the read cursor to the specified timestamp in a direct message channel" do
|
24
|
+
stub = stub_slack_request :post, "im.mark?channel=D02BLAH&ts=1234567890.123456&token=#{access_token}", "im_mark.json"
|
25
|
+
expect(subject.mark("D02BLAH", "1234567890.123456")).to be_nil
|
26
|
+
expect(stub).to have_been_requested
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".open" do
|
31
|
+
it "opens a direct message channel and returns the channel information" do
|
32
|
+
stub_slack_request :post, "im.open?user=D024BLAH&token=#{access_token}", "im_open.json"
|
33
|
+
channel = subject.open("D024BLAH")
|
34
|
+
expect(channel.id).to eq "D02BLAH"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
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.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Wright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/laziness/api/channels.rb
|
91
91
|
- lib/laziness/api/chat.rb
|
92
92
|
- lib/laziness/api/groups.rb
|
93
|
+
- lib/laziness/api/im.rb
|
93
94
|
- lib/laziness/api/oauth.rb
|
94
95
|
- lib/laziness/api/rtm.rb
|
95
96
|
- lib/laziness/api/users.rb
|
@@ -112,6 +113,7 @@ files:
|
|
112
113
|
- spec/laziness/api/channels_spec.rb
|
113
114
|
- spec/laziness/api/chat_spec.rb
|
114
115
|
- spec/laziness/api/groups_spec.rb
|
116
|
+
- spec/laziness/api/im_spec.rb
|
115
117
|
- spec/laziness/api/oauth_spec.rb
|
116
118
|
- spec/laziness/api/rtm_spec.rb
|
117
119
|
- spec/laziness/api/users_spec.rb
|
@@ -130,6 +132,10 @@ files:
|
|
130
132
|
- spec/support/fixtures/chat_update.json
|
131
133
|
- spec/support/fixtures/groups_info.json
|
132
134
|
- spec/support/fixtures/groups_list.json
|
135
|
+
- spec/support/fixtures/im_close.json
|
136
|
+
- spec/support/fixtures/im_list.json
|
137
|
+
- spec/support/fixtures/im_mark.json
|
138
|
+
- spec/support/fixtures/im_open.json
|
133
139
|
- spec/support/fixtures/oauth_access.json
|
134
140
|
- spec/support/fixtures/rtm_start.json
|
135
141
|
- spec/support/fixtures/successful_response.json
|
@@ -165,6 +171,7 @@ test_files:
|
|
165
171
|
- spec/laziness/api/channels_spec.rb
|
166
172
|
- spec/laziness/api/chat_spec.rb
|
167
173
|
- spec/laziness/api/groups_spec.rb
|
174
|
+
- spec/laziness/api/im_spec.rb
|
168
175
|
- spec/laziness/api/oauth_spec.rb
|
169
176
|
- spec/laziness/api/rtm_spec.rb
|
170
177
|
- spec/laziness/api/users_spec.rb
|
@@ -183,6 +190,10 @@ test_files:
|
|
183
190
|
- spec/support/fixtures/chat_update.json
|
184
191
|
- spec/support/fixtures/groups_info.json
|
185
192
|
- spec/support/fixtures/groups_list.json
|
193
|
+
- spec/support/fixtures/im_close.json
|
194
|
+
- spec/support/fixtures/im_list.json
|
195
|
+
- spec/support/fixtures/im_mark.json
|
196
|
+
- spec/support/fixtures/im_open.json
|
186
197
|
- spec/support/fixtures/oauth_access.json
|
187
198
|
- spec/support/fixtures/rtm_start.json
|
188
199
|
- spec/support/fixtures/successful_response.json
|