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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 353b8c42facc5a505560e6b414990779a3f323cc
4
- data.tar.gz: c3f63565b0e52a3f6795cf8e0795888ba5cb453a
3
+ metadata.gz: 0d03de728223b8fc71dd0deaa814277eda205ddb
4
+ data.tar.gz: afcf4aa6800e0dfac0aef8437e749096fb23e199
5
5
  SHA512:
6
- metadata.gz: d958f1c1afd12cd0a172e7d44b67c60ad8d35282d029950a301c48ea189ee34099a92f55ca2c1e50e0fc947ef95a48a71bbb8cbe3b153c186a23ce0005a69c50
7
- data.tar.gz: 8e6f9f9e7f6f03605864daad3dcaf7cd41a9ab045555ef8271b556aa10b2efef8244bc4363952ceafe489657d15265ad9f2e2421a45a6cab32f726782917e583
6
+ metadata.gz: 9e13214874f82abb910f65e202c0dbe65a3c9c71e901ec0088914923a52bc6770f1cb6c7e86a66dbb33d935f2c06a74b1441f314a86a9119b1c32f8e75366e3e
7
+ data.tar.gz: d2efbf4dce2d412f238c77ce27bcb4ee4c76f9430159f7f638c596199d7f9b39a71b3ef7c954f2e64726f0558d18e09172c3acd7c33bce7d129f5c7982d79300
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- laziness (0.1.6)
4
+ laziness (0.1.7)
5
5
  eventmachine
6
6
  faye-websocket (>= 0.8.0)
7
7
  hashie
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
@@ -3,6 +3,7 @@ require 'httparty'
3
3
  require 'laziness/api/base'
4
4
  require 'laziness/api/auth'
5
5
  require 'laziness/api/channels'
6
+ require 'laziness/api/chat'
6
7
  require 'laziness/api/groups'
7
8
  require 'laziness/api/oauth'
8
9
  require 'laziness/api/rtm'
@@ -0,0 +1,4 @@
1
+ module Slack
2
+ class Chat < Base
3
+ end
4
+ end
@@ -14,6 +14,10 @@ module Slack
14
14
  @channels ||= Slack::API::Channels.new(access_token)
15
15
  end
16
16
 
17
+ def chat
18
+ @chat ||= Slack::API::Chat.new(access_token)
19
+ end
20
+
17
21
  def groups
18
22
  @groups ||= Slack::API::Groups.new(access_token)
19
23
  end
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/laziness.rb CHANGED
@@ -3,6 +3,7 @@ require 'laziness/api'
3
3
  require 'laziness/base'
4
4
  require 'laziness/auth'
5
5
  require 'laziness/channel'
6
+ require 'laziness/chat'
6
7
  require 'laziness/client'
7
8
  require 'laziness/errors'
8
9
  require 'laziness/group'
@@ -1,4 +1,4 @@
1
- describe Slack::API:: Channels do
1
+ describe Slack::API::Channels do
2
2
  let(:access_token) { "12345" }
3
3
  subject { Slack::API::Channels.new access_token }
4
4
 
@@ -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
@@ -0,0 +1,5 @@
1
+ {
2
+ "ok": true,
3
+ "ts": "1447299140.000002",
4
+ "channel": "C02BLAH"
5
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "ok": true,
3
+ "channel": "C02BLAH",
4
+ "message": {
5
+ "text": "Hello world",
6
+ "username": "bot_user",
7
+ "type": "message"
8
+ }
9
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "ok": true,
3
+ "channel": "C02BLAH",
4
+ "message": {
5
+ "text": "Hello again",
6
+ "ts": "1447299140.000002",
7
+ "username": "bot_user",
8
+ "type": "message"
9
+ }
10
+ }
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.6
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-06 00:00:00.000000000 Z
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