slack.rb 0.0.4 → 0.0.5

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: ad9860bb84883992baebd1ab9b5ebafcc03964db
4
- data.tar.gz: ae0b5bdff9a86994253721fc96285559b2c26ed4
3
+ metadata.gz: cac3153d08a4736993d769c13801392302e7c0c4
4
+ data.tar.gz: bb41359000b47d37ad0583d50bd51a54df5bcba9
5
5
  SHA512:
6
- metadata.gz: a54b6d2120b7a5d5cea8d0f514070d7f0bcda377e1f445baae3041800556780a2c680f877a3145e9672d292c4e736c35ed4f25663fec3198090450b0c5a875cd
7
- data.tar.gz: 41ce86e35e2d96720f7c2323c88296429ac66c18e24ab5213b34cf2eb3dcd37440c2f18ae527c259b3be3b15f47a90e706122292db0a47046f122242a96d596d
6
+ metadata.gz: 6f02be327a9c01e1c6cc70e4a86e3b4b8e2ccdb33623aee85e1e8146e313edf313ef56ec3afa10855ea6966d5d96a0b9f6f743428b602c40c9855beb4f121916
7
+ data.tar.gz: 29e6e54d702364dfddf9a7606daede9227c9c705a5df0c2525c13c974ffedaf774aff3c59bd197c79fecec43ea47e510055a700d0bba1fa6b7fcf51c045ce2fc
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ script: ./script/cibuild
6
+ env:
7
+ - SLACK_TEST_TOKEN="xoxp-2305382422-2305382424-2320625597-8dc14b" SLACK_TEST_TEAM="netflower"
8
+ notifications:
9
+ slack:
10
+ secure: MoVXtQqiV/9IEWZcaVB4sF/oEoPWqXWu6fOaxt0hFYktEXMqiTQEeL+a9lbqH06F/Xfb9oH+asC5IPRugcxg9nSY48IV+cvVikPCAQEfe6FffNpAYTlnWArINAOf5Ad6dvInvT9qsDYjA5Bmb+nzndCfrE5qluvS0Nxz3Gk7mQA=
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Ruby toolkit for working with the Slack API
4
4
 
5
+ [![Build Status](https://travis-ci.org/netflower/slack.rb.svg?branch=master)](https://travis-ci.org/netflower/slack.rb)
6
+ [![Code Climate](https://codeclimate.com/github/netflower/slack.rb.png)](https://codeclimate.com/github/netflower/slack.rb)
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -22,13 +24,48 @@ Or install it yourself as:
22
24
 
23
25
  ```ruby
24
26
  # Provide authentication credentials
25
- client = Slack::Client.new('team', 'api_token')
27
+ client = Slack::Client.new(team: 'netflower', token: 'xxxx-xxxxxxxxx-xxxx')
26
28
  # Post a message
27
29
  client.post_message("May the force be with you", "yoda-quotes")
28
30
  # List all channels
29
31
  client.channels
30
32
  ```
31
33
 
34
+ ## Configuration and defaults
35
+
36
+ ### Configuring module defaults
37
+
38
+ Every writable attribute in {Slack::Configurable} can be set one at a time:
39
+
40
+ ```ruby
41
+ Slack.api_endpoint = 'https://slack.dev/api'
42
+ Slack.default_channel = '#lol-cats'
43
+ Slack.default_username = 'Yoda'
44
+ ```
45
+
46
+ or in batch:
47
+
48
+ ```ruby
49
+ Slack.configure do |c|
50
+ c.api_endpoint = 'https://slack.dev/api'
51
+ c.default_channel = '#lol-cats'
52
+ c.default_username = 'Yoda'
53
+ end
54
+ ```
55
+
56
+ ### Using ENV variables
57
+
58
+ Default configuration values are specified in {Slack::Default}. Many
59
+ attributes will look for a default value from the ENV before returning
60
+ Slack's default.
61
+
62
+ ```ruby
63
+ # Given $SLACK_API_ENDPOINT is "https://slack.dev/api"
64
+ Slack.api_endpoint
65
+
66
+ # => "https://slack.dev/api"
67
+ ```
68
+
32
69
  ## Contributing
33
70
 
34
71
  1. Fork it ( http://github.com/<my-github-username>/slack/fork )
data/lib/slack.rb CHANGED
@@ -1,47 +1,32 @@
1
- require "slack/version"
1
+ require 'slack/client'
2
+ require 'slack/default'
2
3
 
3
4
  module Slack
4
- require 'slack/response/raise_error'
5
- require "slack/error"
6
- require "slack/connection"
7
- require "slack/payload"
8
- require "slack/client"
9
5
 
10
- # Default API endpoint
11
- API_ENDPOINT = "https://slack.com/api/".freeze
12
-
13
- # Default User Agent header string
14
- USER_AGENT = "Slack Ruby Gem #{Slack::VERSION}".freeze
15
-
16
- # Default media type
17
- MEDIA_TYPE = "application/json"
18
-
19
- # Default API endpoint from ENV or {API_ENDPOINT}
20
- # @return [String]
21
- def api_endpoint
22
- ENV['SLACK_API_ENDPOINT'] || API_ENDPOINT
23
- end
24
-
25
- # Default media type from ENV or {MEDIA_TYPE}
26
- # @return [String]
27
- def default_media_type
28
- ENV['SLACK_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
29
- end
30
-
31
- # Default User-Agent header string from ENV or {USER_AGENT}
32
- # @return [String]
33
- def user_agent
34
- ENV['SLACK_USER_AGENT'] || USER_AGENT
35
- end
36
-
37
- # Default options for Faraday::Connection
38
- # @return [Hash]
39
- def connection_options
40
- {
41
- :headers => {
42
- :accept => default_media_type,
43
- :user_agent => user_agent
44
- }
45
- }
6
+ class << self
7
+ include Slack::Configurable
8
+
9
+ # API client based on configured options {Configurable}
10
+ #
11
+ # @return [Slack::Client] API wrapper
12
+ def client
13
+ @client = Slack::Client.new(options) unless defined?(@client) && @client.same_options?(options)
14
+ @client
15
+ end
16
+
17
+ # see: http://robots.thoughtbot.com/always-define-respond-to-missing-when-overriding
18
+ # @private
19
+ def respond_to_missing?(method_name, include_private=false)
20
+ client.respond_to?(method_name, include_private)
21
+ end
22
+
23
+ private
24
+
25
+ def method_missing(method_name, *args, &block)
26
+ return super unless client.respond_to?(method_name)
27
+ client.send(method_name, *args, &block)
28
+ end
46
29
  end
47
30
  end
31
+
32
+ Slack.setup
data/lib/slack/client.rb CHANGED
@@ -1,17 +1,24 @@
1
1
  require "json"
2
2
  require "faraday"
3
+ require 'slack/configurable'
4
+ require "slack/error"
5
+ require "slack/connection"
6
+ require "slack/payload"
3
7
 
4
8
  module Slack
5
9
  class Client
10
+ include Slack::Configurable
6
11
  include Slack::Connection
7
12
 
8
- def initialize(team, token, options = {})
9
- @team = team
10
- @token = token
11
- @username = options[:username]
12
- @channel = options[:channel]
13
+ def initialize(options = {})
14
+ # Use options passed in, but fall back to module defaults
15
+ Slack::Configurable.keys.each do |key|
16
+ instance_variable_set(:"@#{key}", options[key] || Slack.instance_variable_get(:"@#{key}"))
17
+ end
18
+ end
13
19
 
14
- validate_arguments
20
+ def same_options?(opts)
21
+ opts.hash == options.hash
15
22
  end
16
23
 
17
24
  def post_message(text, channel, options = {})
@@ -22,7 +29,8 @@ module Slack
22
29
  token: @token
23
30
  )
24
31
 
25
- post('chat.postMessage', payload)
32
+ response = post('chat.postMessage', payload)
33
+ valid_response?(response)
26
34
  end
27
35
 
28
36
  def channels
@@ -31,19 +39,14 @@ module Slack
31
39
 
32
40
  private
33
41
 
34
- def validate_arguments
35
- raise ArgumentError, "Team name required" if @team.nil?
36
- raise ArgumentError, "Token required" if @token.nil?
37
- raise ArgumentError, "Invalid team name" unless valid_team_name?
38
- end
39
-
40
- def valid_team_name?
41
- @team =~ /^[a-z\d\-]+$/ ? true : false
42
- end
43
-
44
42
  def _channels
45
43
  response = get('channels.list')
46
- response['channels']
44
+ JSON.parse(response.body)['channels']
45
+ end
46
+
47
+ def valid_response?(response)
48
+ body = JSON.parse(response.body)
49
+ ["true", 1].include? body['ok']
47
50
  end
48
51
  end
49
52
  end
@@ -0,0 +1,49 @@
1
+ module Slack
2
+
3
+ module Configurable
4
+
5
+ attr_accessor :token, :team, :api_endpoint, :default_media_type,
6
+ :user_agent, :default_channel, :default_username,
7
+ :connection_options, :middleware
8
+ attr_writer :api_endpoint
9
+
10
+ class << self
11
+
12
+ # List of configurable keys for {Octokit::Client}
13
+ # @return [Array] of option keys
14
+ def keys
15
+ @keys ||= [
16
+ :token,
17
+ :team,
18
+ :api_endpoint,
19
+ :user_agent,
20
+ :connection_options,
21
+ :default_media_type,
22
+ :default_channel,
23
+ :default_username,
24
+ :middleware
25
+ ]
26
+ end
27
+ end
28
+
29
+ # Set configuration options using a block
30
+ def configure
31
+ yield self
32
+ end
33
+
34
+ # Reset configuration options to default values
35
+ def reset!
36
+ Slack::Configurable.keys.each do |key|
37
+ instance_variable_set(:"@#{key}", Slack::Default.options[key])
38
+ end
39
+ self
40
+ end
41
+ alias setup reset!
42
+
43
+ private
44
+
45
+ def options
46
+ Hash[Slack::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}]
47
+ end
48
+ end
49
+ end
@@ -4,7 +4,7 @@ module Slack
4
4
  response = connection.get method, { token: @token }
5
5
 
6
6
  if response.success?
7
- JSON.parse(response.body)
7
+ response
8
8
  else
9
9
  raise UnknownResponseCode, "Unexpected #{response.code}"
10
10
  end
@@ -13,29 +13,13 @@ module Slack
13
13
  def post(method, payload)
14
14
  response = connection.post do |req|
15
15
  req.url method, payload.to_hash
16
- req.headers['Content-Type'] = 'application/json'
17
- #req.body = JSON.dump(payload.to_hash)
18
16
  end
19
-
20
- handle_response(response)
21
- end
22
-
23
- def base_url
24
- #"https://#{@team}.slack.com/api/"
25
- "https://slack.com/api/"
26
17
  end
27
18
 
28
19
  def connection
29
- Faraday.new(base_url) do |c|
30
- c.use(Faraday::Request::UrlEncoded)
31
- c.use(Slack::Response::RaiseError)
32
- c.adapter(Faraday.default_adapter)
33
- end
34
- end
35
-
36
- def handle_response(response)
37
- body = JSON.parse(response.body)
38
- true if ["true", 1].include? body['ok']
20
+ _connection = Faraday.new(@api_endpoint, @connection_options)
21
+ _connection.headers = {'Accept' => @default_media_type, 'User-Agent' => @user_agent}
22
+ _connection
39
23
  end
40
24
  end
41
25
  end
@@ -0,0 +1,100 @@
1
+ require 'slack/response/raise_error'
2
+ require 'slack/version'
3
+
4
+ module Slack
5
+
6
+ module Default
7
+
8
+ # Default API entpoint
9
+ API_ENDPOINT = "https://slack.com/api/".freeze
10
+
11
+ # Default User Agent header string
12
+ USER_AGENT = "Slack Ruby Gem #{Slack::VERSION}".freeze
13
+
14
+ # Default media type
15
+ MEDIA_TYPE = "application/json"
16
+
17
+ # Default channel type
18
+ DEFAULT_CHANNEL = "#general"
19
+
20
+ # Default username
21
+ DEFAULT_USERNAME = "My Bot"
22
+
23
+ # Default Faraday middleware stack
24
+ MIDDLEWARE = Faraday::RackBuilder.new do |builder|
25
+ builder.use(Faraday::Request::UrlEncoded)
26
+ builder.use Slack::Response::RaiseError
27
+ builder.adapter Faraday.default_adapter
28
+ end
29
+
30
+ class << self
31
+
32
+ # Configuration options
33
+ # @return [Hash]
34
+ def options
35
+ Hash[Slack::Configurable.keys.map{|key| [key, send(key)]}]
36
+ end
37
+
38
+ # Default token from ENV
39
+ # @return [String]
40
+ def token
41
+ ENV['SLACK_TOKEN']
42
+ end
43
+
44
+ # Default team from ENV
45
+ # @return [String]
46
+ def team
47
+ ENV['SLACK_TEAM']
48
+ end
49
+
50
+ # Default API endpoint from ENV or {API_ENDPOINT}
51
+ # @return [String]
52
+ def api_endpoint
53
+ ENV['SLACK_API_ENDPOINT'] || API_ENDPOINT
54
+ end
55
+
56
+ # Default media type from ENV or {MEDIA_TYPE}
57
+ # @return [String]
58
+ def default_media_type
59
+ ENV['SLACK_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
60
+ end
61
+
62
+ # Default User-Agent header string from ENV or {USER_AGENT}
63
+ # @return [String]
64
+ def user_agent
65
+ ENV['SLACK_USER_AGENT'] || USER_AGENT
66
+ end
67
+
68
+ # Default Channel from ENV or {DEFAULT_CHANNEL}
69
+ # @return [String]
70
+ def default_channel
71
+ ENV['SLACK_DEFAULT_CHANNEL'] || DEFAULT_CHANNEL
72
+ end
73
+
74
+ # Default Username from ENV or {DEFAULT_USERNAME}
75
+ # @return [String]
76
+ def default_username
77
+ ENV['SLACK_DEFAULT_USERNAME'] || DEFAULT_USERNAME
78
+ end
79
+
80
+ # Default options for Faraday::Connection
81
+ # @return [Hash]
82
+ def connection_options
83
+ {
84
+ :headers => {
85
+ :accept => default_media_type,
86
+ :user_agent => user_agent
87
+ },
88
+ :builder => middleware
89
+ }
90
+ end
91
+
92
+ # Default middleware stack for Faraday::Connection
93
+ # from {MIDDLEWARE}
94
+ # @return [String]
95
+ def middleware
96
+ MIDDLEWARE
97
+ end
98
+ end
99
+ end
100
+ end
data/lib/slack/payload.rb CHANGED
@@ -3,8 +3,8 @@ module Slack
3
3
  attr_accessor :username, :channel, :text, :token
4
4
 
5
5
  def initialize(options = {})
6
- @username = options[:username]
7
- @channel = options[:channel]
6
+ @username = options[:username] || Slack.default_username
7
+ @channel = options[:channel] || Slack.default_channel
8
8
  @text = options[:text]
9
9
  @token = options[:token]
10
10
 
data/lib/slack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = "0.0.4".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
@@ -1 +1 @@
1
- {"http_interactions":[{"request":{"method":"get","uri":"https://slack.com/api/channels.list?token=<SLACK_TOKEN>","body":{"encoding":"US-ASCII","string":""},"headers":{"User-Agent":["Faraday v0.9.0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"]}},"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":["Thu, 01 May 2014 10:53:36 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"],"X-Xss-Protection":["0"],"Content-Length":["638"],"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\":4,\"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\":3,\"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\":6,\"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\":\"C028ZBLNN\",\"name\":\"the-github-channel\",\"created\":\"1397728177\",\"creator\":\"U028YNXGR\",\"is_archived\":false,\"is_member\":false,\"num_members\":2,\"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\":2,\"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\":4,\"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\":6,\"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\":\"C0296KR2Z\",\"name\":\"the-sharepoint-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\":6,\"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":"Thu, 01 May 2014 10:53:37 GMT"}],"recorded_with":"VCR 2.4.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.4"],"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":["Fri, 09 May 2014 18:26:24 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"],"X-Xss-Protection":["0"],"Content-Length":["1024"],"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\":4,\"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\":10,\"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\":2,\"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\":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\":5,\"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\":2,\"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\":\"C0296KR2Z\",\"name\":\"the-sharepoint-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\":\"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\":3,\"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\":\"C0297DTL6\",\"name\":\"website-redesign-room\",\"created\":\"1398344050\",\"creator\":\"U028ZCM22\",\"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\":\"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":"Fri, 09 May 2014 18:26: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>","body":{"encoding":"UTF-8","string":""},"headers":{"User-Agent":["Faraday v0.9.0"],"Content-Type":["application/json"],"Content-Length":["0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"]}},"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":["Thu, 01 May 2014 10:53:36 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"],"X-Xss-Protection":["0"],"Content-Length":["56"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":1,\"timestamp\":\"1398941616000006\"}"},"http_version":null},"recorded_at":"Thu, 01 May 2014 10:53:38 GMT"}],"recorded_with":"VCR 2.4.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.4"],"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":["Fri, 09 May 2014 18:26:25 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"],"X-Xss-Protection":["0"],"Content-Length":["56"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":1,\"timestamp\":\"1399659985000006\"}"},"http_version":null},"recorded_at":"Fri, 09 May 2014 18:26:28 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>","body":{"encoding":"UTF-8","string":""},"headers":{"User-Agent":["Faraday v0.9.0"],"Content-Type":["application/json"],"Content-Length":["0"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],"Accept":["*/*"]}},"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":["Thu, 01 May 2014 10:57:52 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"],"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":"Thu, 01 May 2014 10:57:53 GMT"}],"recorded_with":"VCR 2.4.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.4"],"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":["Fri, 09 May 2014 18:26:25 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"],"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":"Fri, 09 May 2014 18:26:29 GMT"}],"recorded_with":"VCR 2.4.0"}
@@ -0,0 +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":["Fri, 09 May 2014 18:41:37 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"],"X-Xss-Protection":["0"],"Content-Length":["1024"],"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\":4,\"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\":10,\"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\":2,\"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\":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\":5,\"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\":2,\"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\":\"C0296KR2Z\",\"name\":\"the-sharepoint-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\":\"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\":3,\"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\":\"C0297DTL6\",\"name\":\"website-redesign-room\",\"created\":\"1398344050\",\"creator\":\"U028ZCM22\",\"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\":\"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":"Fri, 09 May 2014 18:41:41 GMT"}],"recorded_with":"VCR 2.4.0"}
@@ -0,0 +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":["Fri, 09 May 2014 18:31:58 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"],"X-Xss-Protection":["0"],"Content-Length":["56"],"Connection":["keep-alive"]},"body":{"encoding":"UTF-8","string":"{\"ok\":1,\"timestamp\":\"1399660318000007\"}"},"http_version":null},"recorded_at":"Fri, 09 May 2014 18:32:02 GMT"}],"recorded_with":"VCR 2.4.0"}
@@ -0,0 +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.4"],"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":["Fri, 09 May 2014 18:45:52 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"],"X-Xss-Protection":["0"],"Content-Length":["1024"],"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\":4,\"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\":10,\"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\":2,\"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\":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\":5,\"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\":2,\"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\":\"C0296KR2Z\",\"name\":\"the-sharepoint-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\":\"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\":3,\"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\":\"C0297DTL6\",\"name\":\"website-redesign-room\",\"created\":\"1398344050\",\"creator\":\"U028ZCM22\",\"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\":\"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":"Fri, 09 May 2014 18:45:56 GMT"}],"recorded_with":"VCR 2.4.0"}
@@ -3,35 +3,130 @@ require "spec_helper"
3
3
  describe Slack::Client do
4
4
 
5
5
  before do
6
+ Slack.reset!
6
7
  @client = auth_client
7
8
  end
8
9
 
9
- describe "#initialize" do
10
- it "requires team name" do
11
- expect { described_class.new(nil, nil) }.
12
- to raise_error ArgumentError, "Team name required"
10
+ after do
11
+ Slack.reset!
12
+ end
13
+
14
+ describe "module configuration" do
15
+
16
+ before do
17
+ Slack.reset!
18
+ Slack.configure do |config|
19
+ Slack::Configurable.keys.each do |key|
20
+ config.send("#{key}=", "Some #{key}")
21
+ end
22
+ end
13
23
  end
14
24
 
15
- it "requires token" do
16
- expect { described_class.new("foobar", nil) }.
17
- to raise_error ArgumentError, "Token required"
25
+ after do
26
+ Slack.reset!
27
+ end
28
+
29
+ it "inherits the module configuration" do
30
+ client = Slack::Client.new
31
+ Slack::Configurable.keys.each do |key|
32
+ expect(client.instance_variable_get(:"@#{key}")).to eq("Some #{key}")
33
+ end
34
+ end
35
+
36
+ describe "with class level configuration" do
37
+
38
+ before do
39
+ @opts = {
40
+ :connection_options => {:ssl => {:verify => false}},
41
+ :api_endpoint => "https://slack.dev/api",
42
+ :token => "abcdef",
43
+ :team => "netflower"
44
+ }
45
+ end
46
+
47
+ it "overrides module configuration" do
48
+ client = Slack::Client.new(@opts)
49
+ expect(client.api_endpoint).to eq("https://slack.dev/api")
50
+ expect(client.token).to eq("abcdef")
51
+ expect(client.instance_variable_get(:"@team")).to eq("netflower")
52
+ expect(client.default_media_type).to eq(Slack.default_media_type)
53
+ expect(client.user_agent).to eq(Slack.user_agent)
54
+ end
55
+
56
+ it "can set configuration after initialization" do
57
+ client = Slack::Client.new
58
+ client.configure do |config|
59
+ @opts.each do |key, value|
60
+ config.send("#{key}=", value)
61
+ end
62
+ end
63
+ expect(client.api_endpoint).to eq("https://slack.dev/api")
64
+ expect(client.token).to eq("abcdef")
65
+ expect(client.instance_variable_get(:"@team")).to eq("netflower")
66
+ expect(client.default_media_type).to eq(Slack.default_media_type)
67
+ expect(client.user_agent).to eq(Slack.user_agent)
68
+ end
18
69
  end
70
+ end
19
71
 
20
- it "raises error on invalid team name" do
21
- names = ["foo bar", "foo $bar", "foo.bar"]
72
+ describe ".client" do
73
+ it "creates an Slack::Client" do
74
+ expect(Slack.client).to be_kind_of Slack::Client
75
+ end
76
+ it "caches the client when the same options are passed" do
77
+ expect(Slack.client).to eq(Slack.client)
78
+ end
79
+ it "returns a fresh client when options are not the same" do
80
+ client = Slack.client
81
+ Slack.token = "abcdefabcdefabcdefabcdef"
82
+ client_two = Slack.client
83
+ client_three = Slack.client
84
+ expect(client).not_to eq(client_two)
85
+ expect(client_three).to eq(client_two)
86
+ end
87
+ end
22
88
 
23
- names.each do |name|
24
- expect { described_class.new(name, "token") }.
25
- to raise_error "Invalid team name"
89
+ describe ".configure" do
90
+ Slack::Configurable.keys.each do |key|
91
+ it "sets the #{key.to_s.gsub('_', ' ')}" do
92
+ Slack.configure do |config|
93
+ config.send("#{key}=", key)
94
+ end
95
+ expect(Slack.instance_variable_get(:"@#{key}")).to eq(key)
26
96
  end
27
97
  end
28
98
  end
29
99
 
100
+ describe "when making requests", :vcr do
101
+ it "sets a default user agent" do
102
+ @client.channels
103
+
104
+ assert_requested :get, auth_slack_url("/channels.list"), :headers => {:user_agent => Slack::Default.user_agent}
105
+
106
+ end
107
+ it "sets a custom user agent for GET request" do
108
+ user_agent = "Mozilla/5.0 I am Spartacus!"
109
+ client = auth_client({:user_agent => user_agent})
110
+ client.channels
111
+
112
+ assert_requested :get, auth_slack_url("/channels.list"), :headers => {:user_agent => user_agent}
113
+ end
114
+
115
+ it "sets a custom user agent for POST request" do
116
+ user_agent = "Mozilla/5.0 I am Spartacus!"
117
+ client = auth_client({:user_agent => user_agent})
118
+ client.post_message("May the force be with you", "yoda-quotes")
119
+
120
+ params = {text: "May the force be with you", channel: "#yoda-quotes", token: test_slack_token, username: Slack.default_username}
121
+ assert_requested :post, slack_url_with_params("/chat.postMessage", params), :headers => {:user_agent => user_agent}
122
+ end
123
+ end
124
+
30
125
  describe "#post_message", :vcr do
31
126
  it "posts a message to one channel" do
32
127
  result = @client.post_message("May the force be with you", "yoda-quotes")
33
128
  expect(result).to be true
34
- params = {text: "May the force be with you", channel: "#yoda-quotes", token: test_slack_token}
129
+ params = {text: "May the force be with you", channel: "#yoda-quotes", token: test_slack_token, username: Slack.default_username}
35
130
  assert_requested :post, slack_url_with_params("/chat.postMessage", params)
36
131
  end
37
132
 
@@ -40,7 +135,7 @@ describe Slack::Client do
40
135
  @client.post_message("May the force be with you", "channel-name")
41
136
  }.to raise_error(Slack::ChannelNotFound)
42
137
 
43
- params = {text: "May the force be with you", channel: "#channel-name", token: test_slack_token}
138
+ params = {text: "May the force be with you", channel: "#channel-name", token: test_slack_token, username: Slack.default_username}
44
139
  assert_requested :post, slack_url_with_params("/chat.postMessage", params)
45
140
  end
46
141
  end
@@ -0,0 +1,83 @@
1
+ require "spec_helper"
2
+
3
+ describe Slack::Payload do
4
+ let(:options) do
5
+ {
6
+ username: "foo",
7
+ channel: "#bar",
8
+ text: "hola"
9
+ }
10
+ end
11
+
12
+ describe "#initialize" do
13
+ let(:payload) { described_class.new(options) }
14
+
15
+ context "with options" do
16
+ it "sets username" do
17
+ expect(payload.username).to eq "foo"
18
+ end
19
+
20
+ it "sets channel" do
21
+ expect(payload.channel).to eq "#bar"
22
+ end
23
+
24
+ it "sets text" do
25
+ expect(payload.text).to eq "hola"
26
+ end
27
+
28
+ context "on missing pound in channel" do
29
+ let(:options) do
30
+ { channel: "foo" }
31
+ end
32
+
33
+ it "adds pound symbol" do
34
+ expect(payload.channel).to eq "#foo"
35
+ end
36
+ end
37
+
38
+ context "on direct message" do
39
+ let(:options) do
40
+ { channel: "@dan" }
41
+ end
42
+
43
+ it "keeps the symbol" do
44
+ expect(payload.channel).to eq "@dan"
45
+ end
46
+ end
47
+ end
48
+
49
+ context "without options" do
50
+ let(:options) { Hash.new }
51
+
52
+ it "sets username" do
53
+ expect(payload.username).to eq "My Bot"
54
+ end
55
+
56
+ it "sets channel" do
57
+ expect(payload.channel).to eq "#general"
58
+ end
59
+ end
60
+ end
61
+
62
+ describe "#to_hash" do
63
+ let(:hash) { described_class.new(options).to_hash }
64
+
65
+ it "includes basic attributes" do
66
+ expect(hash).to eq({
67
+ channel: "#bar",
68
+ text: "hola",
69
+ username: "foo"
70
+ })
71
+ end
72
+
73
+ context "when channel is not set" do
74
+ before do
75
+ options[:channel] = nil
76
+ end
77
+
78
+ it "excludes channel" do
79
+ expect(hash.keys).not_to include "channel"
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Slack do
4
+ before do
5
+ Slack.reset!
6
+ end
7
+
8
+ after do
9
+ Slack.reset!
10
+ end
11
+
12
+ it "sets defaults" do
13
+ Slack::Configurable.keys.each do |key|
14
+ expect(Slack.instance_variable_get(:"@#{key}")).to eq(Slack::Default.send(key))
15
+ end
16
+ end
17
+ end
data/spec/spec_helper.rb CHANGED
@@ -39,16 +39,40 @@ def slack_url(path)
39
39
  "https://slack.com/api#{path}"
40
40
  end
41
41
 
42
- def slack_url_with_params(path, params=nil)
42
+ def slack_url_with_params(path, params={})
43
43
  "https://slack.com/api#{path}?#{parameterize(params)}"
44
44
  end
45
45
 
46
- def auth_slack_url(path)
47
- "https://slack.com/api#{path}?token=#{test_slack_token}"
46
+ def auth_slack_url(path, params={})
47
+ slack_url_with_params(path, {token: test_slack_token}.merge(params))
48
48
  end
49
49
 
50
- def auth_client
51
- Slack::Client.new(ENV.fetch('SLACK_TEST_TEAM'), ENV.fetch('SLACK_TEST_TOKEN'))
50
+ def stub_delete(url)
51
+ stub_request(:delete, auth_slack_url(url))
52
+ end
53
+
54
+ def stub_get(url)
55
+ stub_request(:get, auth_slack_url(url))
56
+ end
57
+
58
+ def stub_head(url)
59
+ stub_request(:head, auth_slack_url(url))
60
+ end
61
+
62
+ def stub_patch(url)
63
+ stub_request(:patch, auth_slack_url(url))
64
+ end
65
+
66
+ def stub_post(url, params)
67
+ stub_request(:post, auth_slack_url(url, params))
68
+ end
69
+
70
+ def stub_put(url)
71
+ stub_request(:put, auth_slack_url(url))
72
+ end
73
+
74
+ def auth_client(options={})
75
+ Slack::Client.new({team: ENV.fetch('SLACK_TEST_TEAM'), token: ENV.fetch('SLACK_TEST_TOKEN')}.merge(options))
52
76
  end
53
77
 
54
78
  def parameterize(params)
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
4
+ version: 0.0.5
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-05-01 00:00:00.000000000 Z
12
+ date: 2014-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -49,13 +49,16 @@ extra_rdoc_files: []
49
49
  files:
50
50
  - .gitignore
51
51
  - .rspec
52
+ - .travis.yml
52
53
  - Gemfile
53
54
  - LICENSE.txt
54
55
  - README.md
55
56
  - Rakefile
56
57
  - lib/slack.rb
57
58
  - lib/slack/client.rb
59
+ - lib/slack/configurable.rb
58
60
  - lib/slack/connection.rb
61
+ - lib/slack/default.rb
59
62
  - lib/slack/error.rb
60
63
  - lib/slack/payload.rb
61
64
  - lib/slack/response/raise_error.rb
@@ -70,7 +73,12 @@ files:
70
73
  - spec/cassettes/Slack_Client/_channels/returns_all_channels.json
71
74
  - spec/cassettes/Slack_Client/_post_message/posts_a_message_to_one_channel.json
72
75
  - spec/cassettes/Slack_Client/_post_message/returns_channel_not_found_error.json
76
+ - spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_GET_request.json
77
+ - spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_POST_request.json
78
+ - spec/cassettes/Slack_Client/when_making_requests/sets_a_default_user_agent.json
73
79
  - spec/slack/client_spec.rb
80
+ - spec/slack/payload_spec.rb
81
+ - spec/slack_spec.rb
74
82
  - spec/spec_helper.rb
75
83
  homepage: https://github.com/netflower/slack.rb
76
84
  licenses:
@@ -100,6 +108,11 @@ test_files:
100
108
  - spec/cassettes/Slack_Client/_channels/returns_all_channels.json
101
109
  - spec/cassettes/Slack_Client/_post_message/posts_a_message_to_one_channel.json
102
110
  - spec/cassettes/Slack_Client/_post_message/returns_channel_not_found_error.json
111
+ - spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_GET_request.json
112
+ - spec/cassettes/Slack_Client/when_making_requests/sets_a_custom_user_agent_for_POST_request.json
113
+ - spec/cassettes/Slack_Client/when_making_requests/sets_a_default_user_agent.json
103
114
  - spec/slack/client_spec.rb
115
+ - spec/slack/payload_spec.rb
116
+ - spec/slack_spec.rb
104
117
  - spec/spec_helper.rb
105
118
  has_rdoc: