laziness 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/lib/laziness/api/chat.rb +20 -0
- data/lib/laziness/api.rb +1 -0
- data/lib/laziness/chat.rb +4 -0
- data/lib/laziness/client.rb +4 -0
- data/lib/laziness/version.rb +1 -1
- data/lib/laziness.rb +1 -0
- data/spec/laziness/api/channels_spec.rb +1 -1
- data/spec/laziness/api/chat_spec.rb +33 -0
- data/spec/support/fixtures/chat_delete.json +5 -0
- data/spec/support/fixtures/chat_post_message.json +9 -0
- data/spec/support/fixtures/chat_update.json +10 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d03de728223b8fc71dd0deaa814277eda205ddb
|
4
|
+
data.tar.gz: afcf4aa6800e0dfac0aef8437e749096fb23e199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e13214874f82abb910f65e202c0dbe65a3c9c71e901ec0088914923a52bc6770f1cb6c7e86a66dbb33d935f2c06a74b1441f314a86a9119b1c32f8e75366e3e
|
7
|
+
data.tar.gz: d2efbf4dce2d412f238c77ce27bcb4ee4c76f9430159f7f638c596199d7f9b39a71b3ef7c954f2e64726f0558d18e09172c3acd7c33bce7d129f5c7982d79300
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -63,6 +63,12 @@ client.channels.invite(channel_id, user_id) # invites the specific user to the s
|
|
63
63
|
|
64
64
|
### Chat
|
65
65
|
|
66
|
+
```
|
67
|
+
message = client.chat.create("Hello world", channel_id) # creates a new message
|
68
|
+
message = client.chat.update("Hello again", channel_id, message.ts) # updates the message with the specified timestamp
|
69
|
+
client.chat.delete(channel_id, message.ts) # deletes the message with the specified timestamp
|
70
|
+
```
|
71
|
+
|
66
72
|
### Emoji
|
67
73
|
|
68
74
|
### Files
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Slack
|
2
|
+
module API
|
3
|
+
class Chat < Base
|
4
|
+
def create(text, channel, options={})
|
5
|
+
response = request :post, 'chat.postMessage', { text: text, channel: channel }.merge(options)
|
6
|
+
Slack::Chat.parse response, 'message'
|
7
|
+
end
|
8
|
+
|
9
|
+
def delete(channel, timestamp)
|
10
|
+
with_nil_response { request :post, 'chat.delete', ts: timestamp, channel: channel }
|
11
|
+
end
|
12
|
+
|
13
|
+
def update(text, channel, timestamp, options={})
|
14
|
+
response = request :post, 'chat.update',
|
15
|
+
{ text: text, channel: channel, ts: timestamp }.merge(options)
|
16
|
+
Slack::Chat.parse response, 'message'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/laziness/api.rb
CHANGED
data/lib/laziness/client.rb
CHANGED
data/lib/laziness/version.rb
CHANGED
data/lib/laziness.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
describe Slack::API::Chat do
|
2
|
+
let(:access_token) { "12345" }
|
3
|
+
subject { Slack::API::Chat.new access_token }
|
4
|
+
|
5
|
+
describe '.create' do
|
6
|
+
it 'creates a new chat message and returns the specified message' do
|
7
|
+
stub_slack_request :post, "chat.postMessage?channel=C02BLAH&text=Hello%20world&username=bot_user&as_user=false&token=#{access_token}", 'chat_post_message.json'
|
8
|
+
|
9
|
+
message = subject.create("Hello world", "C02BLAH", username: "bot_user", as_user: false)
|
10
|
+
expect(message.text).to eq "Hello world"
|
11
|
+
expect(message.username).to eq "bot_user"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.delete' do
|
16
|
+
it 'deletes a chat message' do
|
17
|
+
stub = stub_slack_request :post, "chat.delete?channel=C02BLAH&ts=1447299140.000002&token=#{access_token}", 'chat_delete.json'
|
18
|
+
|
19
|
+
expect(subject.delete("C02BLAH", "1447299140.000002")).to be_nil
|
20
|
+
expect(stub).to have_been_requested
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.update' do
|
25
|
+
it 'updates a chat message and returns the updated message' do
|
26
|
+
stub_slack_request :post, "chat.update?channel=C02BLAH&ts=1447299140.000002&text=Hello%20again&token=#{access_token}", 'chat_update.json'
|
27
|
+
|
28
|
+
message = subject.update("Hello again", "C02BLAH", "1447299140.000002")
|
29
|
+
expect(message.text).to eq "Hello again"
|
30
|
+
expect(message.ts).to eq "1447299140.000002"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
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.7
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: eventmachine
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/laziness/api/auth.rb
|
89
89
|
- lib/laziness/api/base.rb
|
90
90
|
- lib/laziness/api/channels.rb
|
91
|
+
- lib/laziness/api/chat.rb
|
91
92
|
- lib/laziness/api/groups.rb
|
92
93
|
- lib/laziness/api/oauth.rb
|
93
94
|
- lib/laziness/api/rtm.rb
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- lib/laziness/auth.rb
|
96
97
|
- lib/laziness/base.rb
|
97
98
|
- lib/laziness/channel.rb
|
99
|
+
- lib/laziness/chat.rb
|
98
100
|
- lib/laziness/client.rb
|
99
101
|
- lib/laziness/errors.rb
|
100
102
|
- lib/laziness/group.rb
|
@@ -108,6 +110,7 @@ files:
|
|
108
110
|
- lib/laziness/version.rb
|
109
111
|
- spec/laziness/api/auth_spec.rb
|
110
112
|
- spec/laziness/api/channels_spec.rb
|
113
|
+
- spec/laziness/api/chat_spec.rb
|
111
114
|
- spec/laziness/api/groups_spec.rb
|
112
115
|
- spec/laziness/api/oauth_spec.rb
|
113
116
|
- spec/laziness/api/rtm_spec.rb
|
@@ -122,6 +125,9 @@ files:
|
|
122
125
|
- spec/support/fixtures/auth_test.json
|
123
126
|
- spec/support/fixtures/channels_info.json
|
124
127
|
- spec/support/fixtures/channels_list.json
|
128
|
+
- spec/support/fixtures/chat_delete.json
|
129
|
+
- spec/support/fixtures/chat_post_message.json
|
130
|
+
- spec/support/fixtures/chat_update.json
|
125
131
|
- spec/support/fixtures/groups_info.json
|
126
132
|
- spec/support/fixtures/groups_list.json
|
127
133
|
- spec/support/fixtures/oauth_access.json
|
@@ -157,6 +163,7 @@ summary: A Slack API wrapper written in Ruby.
|
|
157
163
|
test_files:
|
158
164
|
- spec/laziness/api/auth_spec.rb
|
159
165
|
- spec/laziness/api/channels_spec.rb
|
166
|
+
- spec/laziness/api/chat_spec.rb
|
160
167
|
- spec/laziness/api/groups_spec.rb
|
161
168
|
- spec/laziness/api/oauth_spec.rb
|
162
169
|
- spec/laziness/api/rtm_spec.rb
|
@@ -171,6 +178,9 @@ test_files:
|
|
171
178
|
- spec/support/fixtures/auth_test.json
|
172
179
|
- spec/support/fixtures/channels_info.json
|
173
180
|
- spec/support/fixtures/channels_list.json
|
181
|
+
- spec/support/fixtures/chat_delete.json
|
182
|
+
- spec/support/fixtures/chat_post_message.json
|
183
|
+
- spec/support/fixtures/chat_update.json
|
174
184
|
- spec/support/fixtures/groups_info.json
|
175
185
|
- spec/support/fixtures/groups_list.json
|
176
186
|
- spec/support/fixtures/oauth_access.json
|