laziness 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d03de728223b8fc71dd0deaa814277eda205ddb
4
- data.tar.gz: afcf4aa6800e0dfac0aef8437e749096fb23e199
3
+ metadata.gz: ce0c66afb39c65e3221314a5a2de1d78b279f49e
4
+ data.tar.gz: 5660fed1096bdac03511550603d90f61ad1d6e60
5
5
  SHA512:
6
- metadata.gz: 9e13214874f82abb910f65e202c0dbe65a3c9c71e901ec0088914923a52bc6770f1cb6c7e86a66dbb33d935f2c06a74b1441f314a86a9119b1c32f8e75366e3e
7
- data.tar.gz: d2efbf4dce2d412f238c77ce27bcb4ee4c76f9430159f7f638c596199d7f9b39a71b3ef7c954f2e64726f0558d18e09172c3acd7c33bce7d129f5c7982d79300
6
+ metadata.gz: 013f4938d48b420f586b1e3cfd43a536ec10f02a4ccad1a61e8faab9adceb689950497803b4161b9d47805f606b1edca1b7e1fee1a0d77ba019969aa55fe22a5
7
+ data.tar.gz: 029f2c56b23cdfeb7a9b07167092fb449a5eea661e142fdc2e9157f19aecbac04907aefc07efe80029e75385bc874e978b58c11e4e692d3c3ef00751704786fc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- laziness (0.1.7)
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.0)
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.2)
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
- ### Presence
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
  ```
@@ -5,6 +5,7 @@ require 'laziness/api/auth'
5
5
  require 'laziness/api/channels'
6
6
  require 'laziness/api/chat'
7
7
  require 'laziness/api/groups'
8
+ require 'laziness/api/im'
8
9
  require 'laziness/api/oauth'
9
10
  require 'laziness/api/rtm'
10
11
  require 'laziness/api/users'
@@ -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
@@ -18,6 +18,10 @@ module Slack
18
18
  @chat ||= Slack::API::Chat.new(access_token)
19
19
  end
20
20
 
21
+ def im
22
+ @im ||= Slack::API::IM.new(access_token)
23
+ end
24
+
21
25
  def groups
22
26
  @groups ||= Slack::API::Groups.new(access_token)
23
27
  end
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -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
@@ -0,0 +1,5 @@
1
+ {
2
+ "ok": true,
3
+ "no_op": true,
4
+ "already_closed": true
5
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "ok": true,
3
+ "ims": [
4
+ {
5
+ "id": "D02BLAH",
6
+ "is_im": true,
7
+ "user": "U024BLAH",
8
+ "created": 1372105335,
9
+ "is_user_deleted": false
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "ok": true
3
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "ok": true,
3
+ "no_op": true,
4
+ "already_open": true,
5
+ "channel": {
6
+ "id": "D02BLAH"
7
+ }
8
+ }
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.7
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-12 00:00:00.000000000 Z
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