slack.rb 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/README.md +2 -2
- data/lib/slack/client.rb +8 -5
- data/lib/slack/configurable.rb +4 -4
- data/lib/slack/default.rb +9 -3
- data/lib/slack/payload.rb +14 -10
- data/lib/slack/structs.rb +18 -0
- data/lib/slack/version.rb +1 -1
- data/spec/cassettes/Slack_Client/_channels/returns_all_channels.json +1 -1
- data/spec/cassettes/Slack_Client/_post_message/posts_a_message_to_one_channel.json +1 -1
- data/spec/cassettes/Slack_Client/_post_message/posts_a_message_with_an_attachment.json +1 -0
- data/spec/cassettes/Slack_Client/_post_message/returns_channel_not_found_error.json +1 -1
- data/spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_GET_request.json +1 -1
- data/spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_POST_request.json +1 -1
- data/spec/cassettes/Slack_Client/when_making_requests/sets_a_default_user_agent.json +1 -1
- data/spec/slack/client_spec.rb +17 -4
- data/spec/slack/payload_spec.rb +10 -0
- data/spec/spec_helper.rb +9 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61a9f3e05ee807304c8a97273801b6d9af6dfcba
|
4
|
+
data.tar.gz: 466ec509400d4ae7e2db6e5e48dfefde145f8160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67628286f10e7add1c6086237e42da7e33da75b37169d01a8ff27d09520e6d962ce55a85f0b03e237f23a2ab4a3733afb869ee744185068eb826482e62676870
|
7
|
+
data.tar.gz: 84a1401ee6d82be4219697e7771c539a8108cc4d3764a8d4fecd1f96aa556d7a0245958fe452565e30e4483a0a5af1665c557b4cefb48a27c9ffcfffb3d9c0b7
|
data/Gemfile
CHANGED
@@ -11,9 +11,9 @@ end
|
|
11
11
|
group :test do
|
12
12
|
gem 'coveralls', :require => false
|
13
13
|
gem 'json', '~> 1.8.1'
|
14
|
-
gem 'rspec', '~> 3.0.0
|
14
|
+
gem 'rspec', '~> 3.0.0'
|
15
15
|
gem 'simplecov', :require => false
|
16
|
-
gem 'vcr', '~> 2.
|
16
|
+
gem 'vcr', '~> 2.9.2'
|
17
17
|
gem 'webmock', '~> 1.9.3'
|
18
18
|
end
|
19
19
|
|
data/README.md
CHANGED
@@ -40,7 +40,7 @@ Every writable attribute in {Slack::Configurable} can be set one at a time:
|
|
40
40
|
```ruby
|
41
41
|
Slack.api_endpoint = 'https://slack.dev/api'
|
42
42
|
Slack.default_channel = '#lol-cats'
|
43
|
-
Slack.
|
43
|
+
Slack.username = 'Yoda'
|
44
44
|
```
|
45
45
|
|
46
46
|
or in batch:
|
@@ -49,7 +49,7 @@ or in batch:
|
|
49
49
|
Slack.configure do |c|
|
50
50
|
c.api_endpoint = 'https://slack.dev/api'
|
51
51
|
c.default_channel = '#lol-cats'
|
52
|
-
c.
|
52
|
+
c.username = 'Yoda'
|
53
53
|
end
|
54
54
|
```
|
55
55
|
|
data/lib/slack/client.rb
CHANGED
@@ -4,6 +4,7 @@ require 'slack/configurable'
|
|
4
4
|
require "slack/error"
|
5
5
|
require "slack/connection"
|
6
6
|
require "slack/payload"
|
7
|
+
require "slack/structs"
|
7
8
|
|
8
9
|
module Slack
|
9
10
|
class Client
|
@@ -23,10 +24,12 @@ module Slack
|
|
23
24
|
|
24
25
|
def post_message(text, channel, options = {})
|
25
26
|
payload = Slack::Payload.new(
|
26
|
-
text:
|
27
|
-
channel:
|
28
|
-
username:
|
29
|
-
token:
|
27
|
+
text: text,
|
28
|
+
channel: channel,
|
29
|
+
username: @username,
|
30
|
+
token: @token,
|
31
|
+
icon_url: @icon_url,
|
32
|
+
attachments: options[:attachments]
|
30
33
|
)
|
31
34
|
|
32
35
|
response = post('chat.postMessage', payload)
|
@@ -46,7 +49,7 @@ module Slack
|
|
46
49
|
|
47
50
|
def valid_response?(response)
|
48
51
|
body = JSON.parse(response.body)
|
49
|
-
[
|
52
|
+
[true, 1].include? body['ok']
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
data/lib/slack/configurable.rb
CHANGED
@@ -2,9 +2,8 @@ module Slack
|
|
2
2
|
|
3
3
|
module Configurable
|
4
4
|
|
5
|
-
attr_accessor :token, :team, :api_endpoint, :default_media_type,
|
6
|
-
:user_agent, :default_channel, :
|
7
|
-
:connection_options, :middleware
|
5
|
+
attr_accessor :token, :team, :username, :icon_url, :api_endpoint, :default_media_type,
|
6
|
+
:user_agent, :default_channel, :connection_options, :middleware
|
8
7
|
attr_writer :api_endpoint
|
9
8
|
|
10
9
|
class << self
|
@@ -15,12 +14,13 @@ module Slack
|
|
15
14
|
@keys ||= [
|
16
15
|
:token,
|
17
16
|
:team,
|
17
|
+
:username,
|
18
|
+
:icon_url,
|
18
19
|
:api_endpoint,
|
19
20
|
:user_agent,
|
20
21
|
:connection_options,
|
21
22
|
:default_media_type,
|
22
23
|
:default_channel,
|
23
|
-
:default_username,
|
24
24
|
:middleware
|
25
25
|
]
|
26
26
|
end
|
data/lib/slack/default.rb
CHANGED
@@ -71,10 +71,16 @@ module Slack
|
|
71
71
|
ENV['SLACK_DEFAULT_CHANNEL'] || DEFAULT_CHANNEL
|
72
72
|
end
|
73
73
|
|
74
|
-
#
|
74
|
+
# Username from ENV or {DEFAULT_USERNAME}
|
75
75
|
# @return [String]
|
76
|
-
def
|
77
|
-
ENV['
|
76
|
+
def username
|
77
|
+
ENV['SLACK_USERNAME'] || DEFAULT_USERNAME
|
78
|
+
end
|
79
|
+
|
80
|
+
# Icon URL from ENV
|
81
|
+
# @return [String]
|
82
|
+
def icon_url
|
83
|
+
ENV['SLACK_ICON_URL']
|
78
84
|
end
|
79
85
|
|
80
86
|
# Default options for Faraday::Connection
|
data/lib/slack/payload.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
module Slack
|
2
2
|
class Payload
|
3
|
-
attr_accessor :username, :channel, :text, :token
|
3
|
+
attr_accessor :username, :channel, :text, :token, :icon_url, :attachments
|
4
4
|
|
5
5
|
def initialize(options = {})
|
6
|
-
@username
|
7
|
-
@channel
|
8
|
-
@text
|
9
|
-
@token
|
6
|
+
@username = options[:username] || Slack.username
|
7
|
+
@channel = options[:channel] || Slack.default_channel
|
8
|
+
@text = options[:text]
|
9
|
+
@token = options[:token]
|
10
|
+
@icon_url = options[:icon_url]
|
11
|
+
@attachments = options[:attachments]
|
10
12
|
|
11
13
|
unless channel[0] =~ /^(#|@)/
|
12
14
|
@channel = "##{@channel}"
|
@@ -15,13 +17,15 @@ module Slack
|
|
15
17
|
|
16
18
|
def to_hash
|
17
19
|
hash = {
|
18
|
-
text:
|
19
|
-
username:
|
20
|
-
channel:
|
21
|
-
token:
|
20
|
+
text: text,
|
21
|
+
username: username,
|
22
|
+
channel: channel,
|
23
|
+
token: token,
|
24
|
+
icon_url: icon_url,
|
25
|
+
attachments: attachments.to_json
|
22
26
|
}
|
23
27
|
|
24
|
-
hash.delete_if { |_,v| v.nil? }
|
28
|
+
hash.delete_if { |_,v| v.nil? || v == "null"}
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Struct
|
4
|
+
def to_map
|
5
|
+
map = Hash.new
|
6
|
+
self.members.each { |m| map[m] = self[m] }
|
7
|
+
map
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_json(*a)
|
11
|
+
to_map.to_json(*a)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Slack
|
16
|
+
Attachment = Struct.new(:fallback, :text, :pretext, :color, :mrkdwn_in, :fields)
|
17
|
+
AttachmentField = Struct.new(:title, :value, :short)
|
18
|
+
end
|
data/lib/slack/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"http_interactions":[{"request":{"method":"get","uri":"https://slack.com/api/channels.list?token=<SLACK_TOKEN>","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://slack.com/api/channels.list?token=<SLACK_TOKEN>","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.5"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Sat, 21 Jun 2014 22:16:26 GMT"],"Expires":["Mon, 26 Jul 1997 05:00:00 GMT"],"Pragma":["no-cache"],"Server":["Apache"],"Vary":["Accept-Encoding"],"X-Accepted-Oauth-Scopes":["read"],"X-Oauth-Scopes":["identify,read,post,client,admin"],"X-Xss-Protection":["0"],"Content-Length":["1172"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":true,\"channels\":[{\"id\":\"C028YP7A7\",\"name\":\"the-cashfloor-room\",\"created\":\"1397727847\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":5,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C02979RU8\",\"name\":\"the-cat-room\",\"created\":\"1398335768\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":true,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZB8CN\",\"name\":\"the-danger-room\",\"created\":\"1397727226\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":9,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"A place for non-work banter, links, articles of interest, humor or anything else which you'd like concentrated in some place other than work-related channels.\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W8U\",\"name\":\"the-design-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W8W\",\"name\":\"the-downloads-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"Please use this room to run download scripts\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294790\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W90\",\"name\":\"the-dyce-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W92\",\"name\":\"the-flowting-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"Website\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294791\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZBLNN\",\"name\":\"the-github-channel\",\"created\":\"1397728177\",\"creator\":\"U028YNXGR\",\"is_archived\":true,\"is_member\":false,\"num_members\":0,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W94\",\"name\":\"the-gusho-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029VDT6Q\",\"name\":\"the-h1-room\",\"created\":\"1399895957\",\"creator\":\"U0296FHNR\",\"is_archived\":false,\"is_member\":true,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029DP011\",\"name\":\"the-hubot-room\",\"created\":\"1398843936\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZBJBJ\",\"name\":\"the-<SLACK_TEAM>-room\",\"created\":\"1397727940\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":6,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W9A\",\"name\":\"the-ops-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028YQ38F\",\"name\":\"the-papertrail-room\",\"created\":\"1397729261\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZB8CL\",\"name\":\"the-serious-room\",\"created\":\"1397727226\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":10,\"is_general\":true,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"This channel is for team-wide communication and announcements. All team members are in this channel.\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029ZPUFA\",\"name\":\"the-sharepoint-room\",\"created\":\"1400100659\",\"creator\":\"U0296TX09\",\"is_archived\":false,\"is_member\":false,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W9C\",\"name\":\"the-skynet-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"Central hub for our army of robots. \\napi.<SLACK_TEAM>.de\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294791\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029K6YKF\",\"name\":\"the-social-media-room\",\"created\":\"1399282691\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":false,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"To collect relevant links for social media postings and to discuss everything around social media. Please always advise what we think about the topic at hand, e.g. Topic = Ruby is less and less used for new Repositories on GitHub. We think = What a pity.\",\"creator\":\"U028ZCM22\",\"last_set\":\"1399288365\"}},{\"id\":\"C029YRCUU\",\"name\":\"the-sp-dataroom-room\",\"created\":\"1400061897\",\"creator\":\"U0296TX09\",\"is_archived\":false,\"is_member\":false,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"All topics regarding (product-)development in CS-SP-Dataroom repository.\",\"creator\":\"U0296TX09\",\"last_set\":\"1400061897\"}},{\"id\":\"C0296KR2Z\",\"name\":\"the-sp-reporting-room\",\"created\":\"1398341726\",\"creator\":\"U0296FHNR\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C0297DTL6\",\"name\":\"website-redesign-room\",\"created\":\"1398344050\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":true,\"num_members\":7,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029G8WDA\",\"name\":\"yoda-quotes\",\"created\":\"1398939627\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}}]}"},"http_version":null},"recorded_at":"Sat, 21 Jun 2014 22:16:27 GMT"}],"recorded_with":"VCR 2.4.0"}
|
@@ -1 +1 @@
|
|
1
|
-
{"http_interactions":[{"request":{"method":"post","uri":"https://slack.com/api/chat.postMessage?channel=%23yoda-quotes&text=May%20the%20force%20be%20with%20you&token=<SLACK_TOKEN>&username=My%20Bot","body":{"encoding":"UTF-8","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.
|
1
|
+
{"http_interactions":[{"request":{"method":"post","uri":"https://slack.com/api/chat.postMessage?channel=%23yoda-quotes&text=May%20the%20force%20be%20with%20you&token=<SLACK_TOKEN>&username=My%20Bot","body":{"encoding":"UTF-8","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.5"],"Content-Length":["0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Sat, 21 Jun 2014 22:16:29 GMT"],"Expires":["Mon, 26 Jul 1997 05:00:00 GMT"],"Pragma":["no-cache"],"Server":["Apache"],"Vary":["Accept-Encoding"],"X-Accepted-Oauth-Scopes":["post"],"X-Oauth-Scopes":["identify,read,post,client,admin"],"X-Xss-Protection":["0"],"Content-Length":["56"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":1,\"timestamp\":\"1403388989000003\"}"},"http_version":null},"recorded_at":"Sat, 21 Jun 2014 22:16:30 GMT"}],"recorded_with":"VCR 2.4.0"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"post","uri":"https://slack.com/api/chat.postMessage?attachments=%5B%7B%22fallback%22:%22fallback%22,%22text%22:%22text-world%22,%22pretext%22:%22pre-hello%22,%22color%22:%22good%22,%22mrkdwn_in%22:%5B%22text%22,%22title%22,%22fallback%22%5D,%22fields%22:%5B%7B%22title%22:%22field1%22,%22value%22:%22value1%22,%22short%22:false%7D,%7B%22title%22:%22field1%22,%22value%22:%22value1%22,%22short%22:false%7D,%7B%22title%22:%22field1%22,%22value%22:%22value1%22,%22short%22:false%7D%5D%7D%5D&channel=%23slack-test&token=<SLACK_TOKEN>&username=My%20Bot","body":{"encoding":"UTF-8","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.5"],"Content-Length":["0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Sat, 21 Jun 2014 22:16:30 GMT"],"Expires":["Mon, 26 Jul 1997 05:00:00 GMT"],"Pragma":["no-cache"],"Server":["Apache"],"Vary":["Accept-Encoding"],"X-Accepted-Oauth-Scopes":["post"],"X-Oauth-Scopes":["identify,read,post,client,admin"],"X-Xss-Protection":["0"],"Content-Length":["55"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":1,\"timestamp\":\"1403388990000003\"}"},"http_version":null},"recorded_at":"Sat, 21 Jun 2014 22:16:30 GMT"}],"recorded_with":"VCR 2.4.0"}
|
@@ -1 +1 @@
|
|
1
|
-
{"http_interactions":[{"request":{"method":"post","uri":"https://slack.com/api/chat.postMessage?channel=%23channel-name&text=May%20the%20force%20be%20with%20you&token=<SLACK_TOKEN>&username=My%20Bot","body":{"encoding":"UTF-8","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.
|
1
|
+
{"http_interactions":[{"request":{"method":"post","uri":"https://slack.com/api/chat.postMessage?channel=%23channel-name&text=May%20the%20force%20be%20with%20you&token=<SLACK_TOKEN>&username=My%20Bot","body":{"encoding":"UTF-8","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.5"],"Content-Length":["0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Sat, 21 Jun 2014 22:16:31 GMT"],"Expires":["Mon, 26 Jul 1997 05:00:00 GMT"],"Pragma":["no-cache"],"Server":["Apache"],"Vary":["Accept-Encoding"],"X-Accepted-Oauth-Scopes":["post"],"X-Oauth-Scopes":["identify,read,post,client,admin"],"X-Xss-Protection":["0"],"Content-Length":["60"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":false,\"error\":\"channel_not_found\"}"},"http_version":null},"recorded_at":"Sat, 21 Jun 2014 22:16:31 GMT"}],"recorded_with":"VCR 2.4.0"}
|
data/spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_GET_request.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"http_interactions":[{"request":{"method":"get","uri":"https://slack.com/api/channels.list?token=<SLACK_TOKEN>","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Mozilla/5.0 I am Spartacus!"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://slack.com/api/channels.list?token=<SLACK_TOKEN>","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Mozilla/5.0 I am Spartacus!"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Sat, 21 Jun 2014 22:16:28 GMT"],"Expires":["Mon, 26 Jul 1997 05:00:00 GMT"],"Pragma":["no-cache"],"Server":["Apache"],"Vary":["Accept-Encoding"],"X-Accepted-Oauth-Scopes":["read"],"X-Oauth-Scopes":["identify,read,post,client,admin"],"X-Xss-Protection":["0"],"Content-Length":["1172"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":true,\"channels\":[{\"id\":\"C028YP7A7\",\"name\":\"the-cashfloor-room\",\"created\":\"1397727847\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":5,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C02979RU8\",\"name\":\"the-cat-room\",\"created\":\"1398335768\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":true,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZB8CN\",\"name\":\"the-danger-room\",\"created\":\"1397727226\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":9,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"A place for non-work banter, links, articles of interest, humor or anything else which you'd like concentrated in some place other than work-related channels.\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W8U\",\"name\":\"the-design-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W8W\",\"name\":\"the-downloads-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"Please use this room to run download scripts\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294790\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W90\",\"name\":\"the-dyce-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W92\",\"name\":\"the-flowting-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"Website\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294791\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZBLNN\",\"name\":\"the-github-channel\",\"created\":\"1397728177\",\"creator\":\"U028YNXGR\",\"is_archived\":true,\"is_member\":false,\"num_members\":0,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W94\",\"name\":\"the-gusho-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029VDT6Q\",\"name\":\"the-h1-room\",\"created\":\"1399895957\",\"creator\":\"U0296FHNR\",\"is_archived\":false,\"is_member\":true,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029DP011\",\"name\":\"the-hubot-room\",\"created\":\"1398843936\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZBJBJ\",\"name\":\"the-<SLACK_TEAM>-room\",\"created\":\"1397727940\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":6,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W9A\",\"name\":\"the-ops-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028YQ38F\",\"name\":\"the-papertrail-room\",\"created\":\"1397729261\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZB8CL\",\"name\":\"the-serious-room\",\"created\":\"1397727226\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":10,\"is_general\":true,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"This channel is for team-wide communication and announcements. All team members are in this channel.\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029ZPUFA\",\"name\":\"the-sharepoint-room\",\"created\":\"1400100659\",\"creator\":\"U0296TX09\",\"is_archived\":false,\"is_member\":false,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W9C\",\"name\":\"the-skynet-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"Central hub for our army of robots. \\napi.<SLACK_TEAM>.de\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294791\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029K6YKF\",\"name\":\"the-social-media-room\",\"created\":\"1399282691\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":false,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"To collect relevant links for social media postings and to discuss everything around social media. Please always advise what we think about the topic at hand, e.g. Topic = Ruby is less and less used for new Repositories on GitHub. We think = What a pity.\",\"creator\":\"U028ZCM22\",\"last_set\":\"1399288365\"}},{\"id\":\"C029YRCUU\",\"name\":\"the-sp-dataroom-room\",\"created\":\"1400061897\",\"creator\":\"U0296TX09\",\"is_archived\":false,\"is_member\":false,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"All topics regarding (product-)development in CS-SP-Dataroom repository.\",\"creator\":\"U0296TX09\",\"last_set\":\"1400061897\"}},{\"id\":\"C0296KR2Z\",\"name\":\"the-sp-reporting-room\",\"created\":\"1398341726\",\"creator\":\"U0296FHNR\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C0297DTL6\",\"name\":\"website-redesign-room\",\"created\":\"1398344050\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":true,\"num_members\":7,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029G8WDA\",\"name\":\"yoda-quotes\",\"created\":\"1398939627\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}}]}"},"http_version":null},"recorded_at":"Sat, 21 Jun 2014 22:16:28 GMT"}],"recorded_with":"VCR 2.4.0"}
|
data/spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_POST_request.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"http_interactions":[{"request":{"method":"post","uri":"https://slack.com/api/chat.postMessage?channel=%23yoda-quotes&text=May%20the%20force%20be%20with%20you&token=<SLACK_TOKEN>&username=My%20Bot","body":{"encoding":"UTF-8","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Mozilla/5.0 I am Spartacus!"],"Content-Length":["0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["
|
1
|
+
{"http_interactions":[{"request":{"method":"post","uri":"https://slack.com/api/chat.postMessage?channel=%23yoda-quotes&text=May%20the%20force%20be%20with%20you&token=<SLACK_TOKEN>&username=My%20Bot","body":{"encoding":"UTF-8","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Mozilla/5.0 I am Spartacus!"],"Content-Length":["0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Sat, 21 Jun 2014 22:16:29 GMT"],"Expires":["Mon, 26 Jul 1997 05:00:00 GMT"],"Pragma":["no-cache"],"Server":["Apache"],"Vary":["Accept-Encoding"],"X-Accepted-Oauth-Scopes":["post"],"X-Oauth-Scopes":["identify,read,post,client,admin"],"X-Xss-Protection":["0"],"Content-Length":["56"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":1,\"timestamp\":\"1403388988000002\"}"},"http_version":null},"recorded_at":"Sat, 21 Jun 2014 22:16:29 GMT"}],"recorded_with":"VCR 2.4.0"}
|
@@ -1 +1 @@
|
|
1
|
-
{"http_interactions":[{"request":{"method":"get","uri":"https://slack.com/api/channels.list?token=<SLACK_TOKEN>","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://slack.com/api/channels.list?token=<SLACK_TOKEN>","body":{"encoding":"US-ASCII","string":""},"headers":{"Accept":["application/json"],"User-Agent":["Slack Ruby Gem 0.0.5"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Access-Control-Allow-Origin":["*"],"Cache-Control":["private, no-cache, no-store, must-revalidate"],"Content-Type":["application/json; charset=utf-8"],"Date":["Sat, 21 Jun 2014 22:16:27 GMT"],"Expires":["Mon, 26 Jul 1997 05:00:00 GMT"],"Pragma":["no-cache"],"Server":["Apache"],"Vary":["Accept-Encoding"],"X-Accepted-Oauth-Scopes":["read"],"X-Oauth-Scopes":["identify,read,post,client,admin"],"X-Xss-Protection":["0"],"Content-Length":["1172"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":true,\"channels\":[{\"id\":\"C028YP7A7\",\"name\":\"the-cashfloor-room\",\"created\":\"1397727847\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":5,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C02979RU8\",\"name\":\"the-cat-room\",\"created\":\"1398335768\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":true,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZB8CN\",\"name\":\"the-danger-room\",\"created\":\"1397727226\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":9,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"A place for non-work banter, links, articles of interest, humor or anything else which you'd like concentrated in some place other than work-related channels.\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W8U\",\"name\":\"the-design-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W8W\",\"name\":\"the-downloads-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"Please use this room to run download scripts\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294790\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W90\",\"name\":\"the-dyce-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W92\",\"name\":\"the-flowting-room\",\"created\":\"1399294790\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"Website\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294791\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZBLNN\",\"name\":\"the-github-channel\",\"created\":\"1397728177\",\"creator\":\"U028YNXGR\",\"is_archived\":true,\"is_member\":false,\"num_members\":0,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W94\",\"name\":\"the-gusho-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029VDT6Q\",\"name\":\"the-h1-room\",\"created\":\"1399895957\",\"creator\":\"U0296FHNR\",\"is_archived\":false,\"is_member\":true,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029DP011\",\"name\":\"the-hubot-room\",\"created\":\"1398843936\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZBJBJ\",\"name\":\"the-<SLACK_TEAM>-room\",\"created\":\"1397727940\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":6,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W9A\",\"name\":\"the-ops-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028YQ38F\",\"name\":\"the-papertrail-room\",\"created\":\"1397729261\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C028ZB8CL\",\"name\":\"the-serious-room\",\"created\":\"1397727226\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":10,\"is_general\":true,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"This channel is for team-wide communication and announcements. All team members are in this channel.\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029ZPUFA\",\"name\":\"the-sharepoint-room\",\"created\":\"1400100659\",\"creator\":\"U0296TX09\",\"is_archived\":false,\"is_member\":false,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029L6W9C\",\"name\":\"the-skynet-room\",\"created\":\"1399294791\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":2,\"is_general\":false,\"topic\":{\"value\":\"Central hub for our army of robots. \\napi.<SLACK_TEAM>.de\",\"creator\":\"U028ZB8CG\",\"last_set\":\"1399294791\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029K6YKF\",\"name\":\"the-social-media-room\",\"created\":\"1399282691\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":false,\"num_members\":4,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"To collect relevant links for social media postings and to discuss everything around social media. Please always advise what we think about the topic at hand, e.g. Topic = Ruby is less and less used for new Repositories on GitHub. We think = What a pity.\",\"creator\":\"U028ZCM22\",\"last_set\":\"1399288365\"}},{\"id\":\"C029YRCUU\",\"name\":\"the-sp-dataroom-room\",\"created\":\"1400061897\",\"creator\":\"U0296TX09\",\"is_archived\":false,\"is_member\":false,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"All topics regarding (product-)development in CS-SP-Dataroom repository.\",\"creator\":\"U0296TX09\",\"last_set\":\"1400061897\"}},{\"id\":\"C0296KR2Z\",\"name\":\"the-sp-reporting-room\",\"created\":\"1398341726\",\"creator\":\"U0296FHNR\",\"is_archived\":false,\"is_member\":true,\"num_members\":3,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C0297DTL6\",\"name\":\"website-redesign-room\",\"created\":\"1398344050\",\"creator\":\"U028ZCM22\",\"is_archived\":false,\"is_member\":true,\"num_members\":7,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}},{\"id\":\"C029G8WDA\",\"name\":\"yoda-quotes\",\"created\":\"1398939627\",\"creator\":\"U028ZB8CG\",\"is_archived\":false,\"is_member\":true,\"num_members\":1,\"is_general\":false,\"topic\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"},\"purpose\":{\"value\":\"\",\"creator\":\"\",\"last_set\":\"0\"}}]}"},"http_version":null},"recorded_at":"Sat, 21 Jun 2014 22:16:27 GMT"}],"recorded_with":"VCR 2.4.0"}
|
data/spec/slack/client_spec.rb
CHANGED
@@ -40,7 +40,9 @@ describe Slack::Client do
|
|
40
40
|
:connection_options => {:ssl => {:verify => false}},
|
41
41
|
:api_endpoint => "https://slack.dev/api",
|
42
42
|
:token => "abcdef",
|
43
|
-
:team => "netflower"
|
43
|
+
:team => "netflower",
|
44
|
+
:username => "yoda",
|
45
|
+
:icon_url => "http://lorempixel.com/48/48"
|
44
46
|
}
|
45
47
|
end
|
46
48
|
|
@@ -49,6 +51,8 @@ describe Slack::Client do
|
|
49
51
|
expect(client.api_endpoint).to eq("https://slack.dev/api")
|
50
52
|
expect(client.token).to eq("abcdef")
|
51
53
|
expect(client.instance_variable_get(:"@team")).to eq("netflower")
|
54
|
+
expect(client.username).to eq("yoda")
|
55
|
+
expect(client.icon_url).to eq("http://lorempixel.com/48/48")
|
52
56
|
expect(client.default_media_type).to eq(Slack.default_media_type)
|
53
57
|
expect(client.user_agent).to eq(Slack.user_agent)
|
54
58
|
end
|
@@ -63,6 +67,8 @@ describe Slack::Client do
|
|
63
67
|
expect(client.api_endpoint).to eq("https://slack.dev/api")
|
64
68
|
expect(client.token).to eq("abcdef")
|
65
69
|
expect(client.instance_variable_get(:"@team")).to eq("netflower")
|
70
|
+
expect(client.username).to eq("yoda")
|
71
|
+
expect(client.icon_url).to eq("http://lorempixel.com/48/48")
|
66
72
|
expect(client.default_media_type).to eq(Slack.default_media_type)
|
67
73
|
expect(client.user_agent).to eq(Slack.user_agent)
|
68
74
|
end
|
@@ -117,7 +123,7 @@ describe Slack::Client do
|
|
117
123
|
client = auth_client({:user_agent => user_agent})
|
118
124
|
client.post_message("May the force be with you", "yoda-quotes")
|
119
125
|
|
120
|
-
params = {text: "May the force be with you", channel: "#yoda-quotes", token: test_slack_token, username: Slack.
|
126
|
+
params = {text: "May the force be with you", channel: "#yoda-quotes", token: test_slack_token, username: Slack.username}
|
121
127
|
assert_requested :post, slack_url_with_params("/chat.postMessage", params), :headers => {:user_agent => user_agent}
|
122
128
|
end
|
123
129
|
end
|
@@ -126,7 +132,14 @@ describe Slack::Client do
|
|
126
132
|
it "posts a message to one channel" do
|
127
133
|
result = @client.post_message("May the force be with you", "yoda-quotes")
|
128
134
|
expect(result).to be true
|
129
|
-
params = {text: "May the force be with you", channel: "#yoda-quotes", token: test_slack_token, username: Slack.
|
135
|
+
params = {text: "May the force be with you", channel: "#yoda-quotes", token: test_slack_token, username: Slack.username}
|
136
|
+
assert_requested :post, slack_url_with_params("/chat.postMessage", params)
|
137
|
+
end
|
138
|
+
|
139
|
+
it "posts a message with an attachment" do
|
140
|
+
result = @client.post_message(nil, "slack-test", {attachments: attachments})
|
141
|
+
expect(result).to be true
|
142
|
+
params = {attachments: attachments.to_json, channel: "#slack-test", token: test_slack_token, username: Slack.username}
|
130
143
|
assert_requested :post, slack_url_with_params("/chat.postMessage", params)
|
131
144
|
end
|
132
145
|
|
@@ -135,7 +148,7 @@ describe Slack::Client do
|
|
135
148
|
@client.post_message("May the force be with you", "channel-name")
|
136
149
|
}.to raise_error(Slack::ChannelNotFound)
|
137
150
|
|
138
|
-
params = {text: "May the force be with you", channel: "#channel-name", token: test_slack_token, username: Slack.
|
151
|
+
params = {text: "May the force be with you", channel: "#channel-name", token: test_slack_token, username: Slack.username}
|
139
152
|
assert_requested :post, slack_url_with_params("/chat.postMessage", params)
|
140
153
|
end
|
141
154
|
end
|
data/spec/slack/payload_spec.rb
CHANGED
@@ -79,5 +79,15 @@ describe Slack::Payload do
|
|
79
79
|
expect(hash.keys).not_to include "channel"
|
80
80
|
end
|
81
81
|
end
|
82
|
+
|
83
|
+
context "when attachment is not set" do
|
84
|
+
before do
|
85
|
+
options[:attachments] = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
it "excludes attachments" do
|
89
|
+
expect(hash.keys).not_to include "attachments"
|
90
|
+
end
|
91
|
+
end
|
82
92
|
end
|
83
93
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -75,6 +75,15 @@ def auth_client(options={})
|
|
75
75
|
Slack::Client.new({team: ENV.fetch('SLACK_TEST_TEAM'), token: ENV.fetch('SLACK_TEST_TOKEN')}.merge(options))
|
76
76
|
end
|
77
77
|
|
78
|
+
def attachments
|
79
|
+
field1 = Slack::AttachmentField.new("field1", "value1", false)
|
80
|
+
field2 = Slack::AttachmentField.new("field2", "value2", true)
|
81
|
+
field3 = Slack::AttachmentField.new("field3", "value3", true)
|
82
|
+
fields = [field1, field1, field1]
|
83
|
+
|
84
|
+
[Slack::Attachment.new("fallback", "text-world", "pre-hello", "good", ["text", "title", "fallback"], fields)]
|
85
|
+
end
|
86
|
+
|
78
87
|
def parameterize(params)
|
79
88
|
URI.escape(params.collect{|k,v| "#{k}=#{v}"}.join('&'))
|
80
89
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bastian Bartmann
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/slack/error.rb
|
63
63
|
- lib/slack/payload.rb
|
64
64
|
- lib/slack/response/raise_error.rb
|
65
|
+
- lib/slack/structs.rb
|
65
66
|
- lib/slack/version.rb
|
66
67
|
- script/bootstrap
|
67
68
|
- script/cibuild
|
@@ -72,6 +73,7 @@ files:
|
|
72
73
|
- slack.rb.gemspec
|
73
74
|
- spec/cassettes/Slack_Client/_channels/returns_all_channels.json
|
74
75
|
- spec/cassettes/Slack_Client/_post_message/posts_a_message_to_one_channel.json
|
76
|
+
- spec/cassettes/Slack_Client/_post_message/posts_a_message_with_an_attachment.json
|
75
77
|
- spec/cassettes/Slack_Client/_post_message/returns_channel_not_found_error.json
|
76
78
|
- spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_GET_request.json
|
77
79
|
- spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_POST_request.json
|
@@ -100,13 +102,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
102
|
version: '0'
|
101
103
|
requirements: []
|
102
104
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.2.2
|
104
106
|
signing_key:
|
105
107
|
specification_version: 4
|
106
108
|
summary: Simple wrapper for the Slack API
|
107
109
|
test_files:
|
108
110
|
- spec/cassettes/Slack_Client/_channels/returns_all_channels.json
|
109
111
|
- spec/cassettes/Slack_Client/_post_message/posts_a_message_to_one_channel.json
|
112
|
+
- spec/cassettes/Slack_Client/_post_message/posts_a_message_with_an_attachment.json
|
110
113
|
- spec/cassettes/Slack_Client/_post_message/returns_channel_not_found_error.json
|
111
114
|
- spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_GET_request.json
|
112
115
|
- spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_POST_request.json
|