slack-ruby-client 0.3.1 → 0.4.0

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: d12ef0347f8c84a91ad907b2ae329f5ca2abe1cd
4
- data.tar.gz: 8377fe5d8228f8c7abdcbfb66c0b7953dc5a54df
3
+ metadata.gz: cdfb697bdb471743bc8c46c29e685af650570952
4
+ data.tar.gz: 0e0b770c177930831491961f36097cf6fc1c1c17
5
5
  SHA512:
6
- metadata.gz: 1de719bc5339ae3022e36b7ed197d5a4e1e70f611824cca3f042fc588dd8d89ef65c27dc5825d68d876b1f14b89b8d8c36ea3123d5790fd8bfafbc3f878af314
7
- data.tar.gz: a2b144b55158facc2c0db9fad0f16cab541817c3ac6d74d81ac77fb5a42d3e42f500ef165bd28ae2234c121b5de72f88d6fb27c8a4048f3106f96a4406f118ef
6
+ metadata.gz: 1e79611aef6f955e67f2a250a7c0a48080634ba61066375cbca7882897b41e5f0043f60d5bd878dddaa67ca0b8cc66bde5a48cb4edc9bb82c567b5e216aa8c59
7
+ data.tar.gz: 38d866a7132a1981866bb055a24ef8ba6ee8661007b46662dc97e669f335850fa69c01bdd57dd84c2caa0278afff6e70a7eb669e20d2307cff83bef5f836aa9b
data/.rubocop_todo.yml CHANGED
@@ -1,38 +1,49 @@
1
- # This configuration was generated by `rubocop --auto-gen-config`
2
- # on 2015-09-01 18:02:38 -0400 using RuboCop version 0.32.1.
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-11-08 16:15:14 -0500 using RuboCop version 0.35.0.
3
4
  # The point is for the user to remove these configuration records
4
5
  # one by one as the offenses are removed from the code base.
5
6
  # Note that changes in the inspected code, or installation of new
6
7
  # versions of RuboCop, may require this file to be generated again.
7
8
 
8
- # Offense count: 2
9
+ # Offense count: 3
9
10
  Metrics/AbcSize:
10
- Max: 21
11
+ Max: 19
11
12
 
12
- # Offense count: 152
13
+ # Offense count: 178
13
14
  # Configuration parameters: AllowURI, URISchemes.
14
15
  Metrics/LineLength:
15
- Max: 149
16
+ Max: 174
16
17
 
17
18
  # Offense count: 3
18
19
  # Configuration parameters: CountComments.
19
20
  Metrics/MethodLength:
20
21
  Max: 19
21
22
 
22
- # Offense count: 35
23
+ # Offense count: 1
24
+ Style/AsciiComments:
25
+ Exclude:
26
+ - 'lib/slack/web/api/endpoints/team.rb'
27
+
28
+ # Offense count: 36
29
+ # Configuration parameters: Exclude.
23
30
  Style/Documentation:
24
31
  Enabled: false
25
32
 
26
33
  # Offense count: 1
27
34
  # Configuration parameters: Exclude.
28
35
  Style/FileName:
29
- Enabled: false
36
+ Exclude:
37
+ - 'lib/slack-ruby-client.rb'
30
38
 
31
- # Offense count: 10
39
+ # Offense count: 11
32
40
  # Configuration parameters: EnforcedStyle, SupportedStyles.
33
41
  Style/MethodName:
34
42
  Enabled: false
35
43
 
36
44
  # Offense count: 3
37
45
  Style/ModuleFunction:
38
- Enabled: false
46
+ Exclude:
47
+ - 'lib/slack/config.rb'
48
+ - 'lib/slack/real_time/config.rb'
49
+ - 'lib/slack/web/config.rb'
data/CHANGELOG.md CHANGED
@@ -1,20 +1,30 @@
1
+ ### 0.4.0 (11/8/2015)
2
+
3
+ * Added `team_integrationLogs` to Web API - [@dblock](https://github.com/dblock).
4
+ * [#11](https://github.com/dblock/slack-ruby-client/pull/11) - Web API `chat_postMessage` errors only if both `attachments` and `text` are missing - [@dblock](https://github.com/dblock).
5
+ * [#20](https://github.com/dblock/slack-ruby-client/issues/20) - Web API `chat_postMessage` will automatically `to_json` attachments - [@dblock](https://github.com/dblock).
6
+ * Added `mpim_aware` to `rtm_start` to Web API - [@dblock](https://github.com/dblock).
7
+ * Added `mpim_close`, `mpim_history`, `mpim_list`, `mpim_mark` and `mpim_open` to Web API - [@dblock](https://github.com/dblock).
8
+ * Added `unreads` to `channels_history`, `groups_history` and `im_history` to Web API - [@dblock](https://github.com/dblock).
9
+ * Added `stars_add` and `stars_remove` to Web API - [@dblock](https://github.com/dblock).
10
+
1
11
  ### 0.3.1 (10/16/2015)
2
12
 
3
- * Added `stars.list`, `add` and `remove` - [@dblock](https://github.com/dblock).
4
- * Added `attachments`, `parse` and `link_names` to `chat.update` - [@dblock](https://github.com/dblock).
13
+ * Added `stars_list`, `stars_add` and `stars_remove` to Web API - [@dblock](https://github.com/dblock).
14
+ * Added `attachments`, `parse` and `link_names` to `chat_update` in Web API - [@dblock](https://github.com/dblock).
5
15
 
6
16
  ### 0.3.0 (9/1/2015)
7
17
 
8
- * Added `team.info` and `accessLogs` - [@dblock](https://github.com/dblock).
9
- * Removed obsolete `presence` API - [@dblock](https://github.com/dblock).
10
- * Added `pins.add`, `list` and `remove` - [@dblock](https://github.com/dblock).
11
- * Added `users.list#presence` - [@dblock](https://github.com/dblock).
12
- * Added `groups.info` - [@dblock](https://github.com/dblock).
13
- * Added `groups.history#inclusive` and `im.history#inclusive` - [@dblock](https://github.com/dblock).
14
- * Added `files.delete` - [@dblock](https://github.com/dblock).
15
- * Added `chat.postMessage#as_user` - [@dblock](https://github.com/dblock).
18
+ * Added `team.info` and `accessLogs` to Web API - [@dblock](https://github.com/dblock).
19
+ * Removed obsolete `presence` Web API - [@dblock](https://github.com/dblock).
20
+ * Added `pins_add`, `pins_list` and `pins_remove` from Web API - [@dblock](https://github.com/dblock).
21
+ * Added `presence` to `users_list` in Web API - [@dblock](https://github.com/dblock).
22
+ * Added `groups_info` to Web API - [@dblock](https://github.com/dblock).
23
+ * Added `inclusive` to `groups_history` and `im_history` in Web API - [@dblock](https://github.com/dblock).
24
+ * Added `files_delete` to Web API - [@dblock](https://github.com/dblock).
25
+ * Added `as_user` to `chat_postMessage` in Web API - [@dblock](https://github.com/dblock).
16
26
  * Use API reference schema from [github.com/dblock/slack-api-ref](https://github.com/dblock/slack-api-ref) - [@dblock](https://github.com/dblock).
17
- * Added `reactions.add`, `.list`, `.get` and `.remove` - [@jakedahn](https://github.com/jakedahn)
27
+ * Added `reactions_add`, `reactions_list`, `reactions_get` and `reactions_remove` to Web API - [@jakedahn](https://github.com/jakedahn)
18
28
 
19
29
  ### 0.2.1 (8/2/2015)
20
30
 
data/CONTRIBUTING.md CHANGED
@@ -63,6 +63,26 @@ Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `
63
63
 
64
64
  Make sure that `bundle exec rake` completes without errors.
65
65
 
66
+ ### Update Slack Web API
67
+
68
+ Slack Web API is updated from https://github.com/dblock/slack-api-ref, a maintained, machine-readable version of Slack API Docs, generated by scraping [api.slack.com](https://api.slack.com). To update the Web API from the latest definition run the following Rake task.
69
+
70
+ ```
71
+ rake slack:web:api:update
72
+ ```
73
+
74
+ #### Patching Slack Web API
75
+
76
+ Sometimes it's necessary to patch auto-generated Slack Web API methods. For example, we want to help clients with calling `to_json` on the `attachments` parameter sent to `chat_postMessage`. See [#20](https://github.com/dblock/slack-ruby-client/issues/20).
77
+
78
+ Make a change to a generated file, for example `lib/slack/web/api/endpoints/chat.rb` and generate a patch.
79
+
80
+ ```
81
+ git diff HEAD lib/slack/web/api/endpoints/chat.rb > lib/slack/web/api/patches/chat.1.patch
82
+ ```
83
+
84
+ Run `rake slack:web:api:update` to ensure that the patch is cleanly applied. Implement a test for the added or modified functionality and commit the patch file.
85
+
66
86
  ### Write Documentation
67
87
 
68
88
  Document any external behavior in the [README](README.md).
data/README.md CHANGED
@@ -4,7 +4,11 @@ Slack Ruby Client
4
4
  [![Gem Version](https://badge.fury.io/rb/slack-ruby-client.svg)](http://badge.fury.io/rb/slack-ruby-client)
5
5
  [![Build Status](https://travis-ci.org/dblock/slack-ruby-client.svg?branch=master)](https://travis-ci.org/dblock/slack-ruby-client)
6
6
 
7
- A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messaging](https://api.slack.com/rtm) APIs.
7
+ A Ruby client for the Slack [Web](https://api.slack.com/web) and [RealTime Messaging](https://api.slack.com/rtm) APIs.
8
+
9
+ Writing a bot? Try [slack-ruby-bot](https://github.com/dblock/slack-ruby-bot) instead.
10
+
11
+ ![](slack.png)
8
12
 
9
13
  ## Installation
10
14
 
@@ -9,6 +9,4 @@ client = Slack::Web::Client.new
9
9
 
10
10
  client.auth_test
11
11
 
12
- general_channel = client.channels_list['channels'].detect { |c| c['name'] == 't3' }
13
-
14
- client.chat_postMessage(channel: general_channel['id'], text: 'Hello World', as_user: true)
12
+ client.chat_postMessage(channel: '#general', text: 'Hello World', as_user: true)
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'slack-ruby-client', path: '../..'
@@ -0,0 +1,25 @@
1
+ require 'slack-ruby-client'
2
+
3
+ Slack.configure do |config|
4
+ config.token = ENV['SLACK_API_TOKEN']
5
+ fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token
6
+ end
7
+
8
+ client = Slack::Web::Client.new
9
+
10
+ client.auth_test
11
+
12
+ client.chat_postMessage(
13
+ channel: '#general',
14
+ as_user: true,
15
+ attachments: [
16
+ {
17
+ fallback: "Ticket #1943: Can't rest my password - https://groove.hq/path/to/ticket/1943",
18
+ pretext: 'New ticket from Andrea Lee',
19
+ title: "Ticket #1943: Can't reset my password",
20
+ title_link: 'https://groove.hq/path/to/ticket/1943',
21
+ text: 'Help! I tried to reset my password but nothing happened!',
22
+ color: '#7CD197'
23
+ }
24
+ ]
25
+ )
@@ -4,6 +4,7 @@ require 'slack/config'
4
4
  # Web API
5
5
  require 'faraday'
6
6
  require 'faraday_middleware'
7
+ require 'json'
7
8
  require 'slack/web/config'
8
9
  require 'slack/web/api/error'
9
10
  require 'slack/web/faraday/response/raise_error'
data/lib/slack/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Slack
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -8,6 +8,7 @@ require 'slack/web/api/endpoints/emoji'
8
8
  require 'slack/web/api/endpoints/files'
9
9
  require 'slack/web/api/endpoints/groups'
10
10
  require 'slack/web/api/endpoints/im'
11
+ require 'slack/web/api/endpoints/mpim'
11
12
  require 'slack/web/api/endpoints/oauth'
12
13
  require 'slack/web/api/endpoints/pins'
13
14
  require 'slack/web/api/endpoints/reactions'
@@ -29,6 +30,7 @@ module Slack
29
30
  include Files
30
31
  include Groups
31
32
  include Im
33
+ include Mpim
32
34
  include Oauth
33
35
  include Pins
34
36
  include Reactions
@@ -42,6 +42,8 @@ module Slack
42
42
  # Start of time range of messages to include in results.
43
43
  # @option options [Object] :inclusive
44
44
  # Include messages with latest or oldest timestamp in results.
45
+ # @option options [Object] :unreads
46
+ # Include unread_count_display in the output?.
45
47
  # @see https://api.slack.com/methods/channels.history
46
48
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/channels.history.json
47
49
  def channels_history(options = {})
@@ -49,7 +49,13 @@ module Slack
49
49
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat.postMessage.json
50
50
  def chat_postMessage(options = {})
51
51
  throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
52
- throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
52
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
53
+ # attachments must be passed as an encoded JSON string
54
+ if options.key?(:attachments)
55
+ attachments = options[:attachments]
56
+ attachments = JSON.dump(attachments) unless attachments.is_a?(String)
57
+ options = options.merge(attachments: attachments)
58
+ end
53
59
  post('chat.postMessage', options)
54
60
  end
55
61
 
@@ -66,6 +66,8 @@ module Slack
66
66
  # Start of time range of messages to include in results.
67
67
  # @option options [Object] :inclusive
68
68
  # Include messages with latest or oldest timestamp in results.
69
+ # @option options [Object] :unreads
70
+ # Include unread_count_display in the output?.
69
71
  # @see https://api.slack.com/methods/groups.history
70
72
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/groups.history.json
71
73
  def groups_history(options = {})
@@ -30,6 +30,8 @@ module Slack
30
30
  # Start of time range of messages to include in results.
31
31
  # @option options [Object] :inclusive
32
32
  # Include messages with latest or oldest timestamp in results.
33
+ # @option options [Object] :unreads
34
+ # Include unread_count_display in the output?.
33
35
  # @see https://api.slack.com/methods/im.history
34
36
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/im.history.json
35
37
  def im_history(options = {})
@@ -0,0 +1,81 @@
1
+ # This file was auto-generated by lib/slack/web/api/tasks/generate.rake
2
+
3
+ module Slack
4
+ module Web
5
+ module Api
6
+ module Endpoints
7
+ module Mpim
8
+ #
9
+ # This method closes a multiparty direct message channel.
10
+ #
11
+ # @option options [channel] :channel
12
+ # MPIM to close.
13
+ # @see https://api.slack.com/methods/mpim.close
14
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.close.json
15
+ def mpim_close(options = {})
16
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
17
+ post('mpim.close', options)
18
+ end
19
+
20
+ #
21
+ # This method returns a portion of messages/events from the specified multiparty direct message channel.
22
+ # To read the entire history for a multiparty direct message, call the method with no latest or
23
+ # oldest arguments, and then continue paging using the instructions below.
24
+ #
25
+ # @option options [channel] :channel
26
+ # Multiparty direct message to fetch history for.
27
+ # @option options [timestamp] :latest
28
+ # End of time range of messages to include in results.
29
+ # @option options [timestamp] :oldest
30
+ # Start of time range of messages to include in results.
31
+ # @option options [Object] :inclusive
32
+ # Include messages with latest or oldest timestamp in results.
33
+ # @option options [Object] :unreads
34
+ # Include unread_count_display in the output?.
35
+ # @see https://api.slack.com/methods/mpim.history
36
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.history.json
37
+ def mpim_history(options = {})
38
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
39
+ post('mpim.history', options)
40
+ end
41
+
42
+ #
43
+ # This method returns a list of all multiparty direct message channels that the user has.
44
+ #
45
+ # @see https://api.slack.com/methods/mpim.list
46
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.list.json
47
+ def mpim_list(options = {})
48
+ post('mpim.list', options)
49
+ end
50
+
51
+ #
52
+ # This method moves the read cursor in a multiparty direct message channel.
53
+ #
54
+ # @option options [channel] :channel
55
+ # multiparty direct message channel to set reading cursor in.
56
+ # @option options [timestamp] :ts
57
+ # Timestamp of the most recently seen message.
58
+ # @see https://api.slack.com/methods/mpim.mark
59
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.mark.json
60
+ def mpim_mark(options = {})
61
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
62
+ throw ArgumentError.new('Required arguments :ts missing') if options[:ts].nil?
63
+ post('mpim.mark', options)
64
+ end
65
+
66
+ #
67
+ # This method opens a multiparty direct message.
68
+ #
69
+ # @option options [Object] :users
70
+ # Comma separated lists of users. The ordering of the users is preserved whenever a MPIM group is returned.
71
+ # @see https://api.slack.com/methods/mpim.open
72
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/mpim.open.json
73
+ def mpim_open(options = {})
74
+ throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
75
+ post('mpim.open', options)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -13,6 +13,8 @@ module Slack
13
13
  # Return timestamp only for latest message object of each channel (improves performance).
14
14
  # @option options [Object] :no_unreads
15
15
  # Skip unread counts for each channel (improves performance).
16
+ # @option options [Object] :mpim_aware
17
+ # Returns MPIMs to the client in the API response.
16
18
  # @see https://api.slack.com/methods/rtm.start
17
19
  # @see https://github.com/dblock/slack-api-ref/blob/master/methods/rtm.start.json
18
20
  def rtm_start(options = {})
@@ -22,6 +22,23 @@ module Slack
22
22
  def team_info(options = {})
23
23
  post('team.info', options)
24
24
  end
25
+
26
+ #
27
+ # This method lists the integration activity logs for a team, including when integrations are added, modified and removed. This method can only be called by Admins.
28
+ #
29
+ # @option options [Object] :service_id
30
+ # Filter logs to this service. Defaults to all logs.
31
+ # @option options [Object] :app_id
32
+ # Filter logs to this API application. Defaults to all logs.
33
+ # @option options [user] :user
34
+ # Filter logs generated by this user’s actions. Defaults to all logs.
35
+ # @option options [Object] :change_type
36
+ # Filter logs with this change type. Defaults to all logs.
37
+ # @see https://api.slack.com/methods/team.integrationLogs
38
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.integrationLogs.json
39
+ def team_integrationLogs(options = {})
40
+ post('team.integrationLogs', options)
41
+ end
25
42
  end
26
43
  end
27
44
  end
@@ -0,0 +1,13 @@
1
+ diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
2
+ index 1f7a8d7..2ec4bed 100644
3
+ --- a/lib/slack/web/api/endpoints/chat.rb
4
+ +++ b/lib/slack/web/api/endpoints/chat.rb
5
+ @@ -49,7 +49,7 @@ module Slack
6
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/chat.postMessage.json
7
+ def chat_postMessage(options = {})
8
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
9
+ - throw ArgumentError.new('Required arguments :text missing') if options[:text].nil?
10
+ + throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
11
+ post('chat.postMessage', options)
12
+ end
13
+
@@ -0,0 +1,17 @@
1
+ diff --git a/lib/slack/web/api/endpoints/chat.rb b/lib/slack/web/api/endpoints/chat.rb
2
+ index 1f7a8d7..89b1562 100644
3
+ --- a/lib/slack/web/api/endpoints/chat.rb
4
+ +++ b/lib/slack/web/api/endpoints/chat.rb
5
+ @@ -50,6 +50,12 @@ module Slack
6
+ def chat_postMessage(options = {})
7
+ throw ArgumentError.new('Required arguments :channel missing') if options[:channel].nil?
8
+ throw ArgumentError.new('Required arguments :text or :attachments missing') if options[:text].nil? && options[:attachments].nil?
9
+ + # attachments must be passed as an encoded JSON string
10
+ + if options.key?(:attachments)
11
+ + attachments = options[:attachments]
12
+ + attachments = JSON.dump(attachments) unless attachments.is_a?(String)
13
+ + options = options.merge(attachments: attachments)
14
+ + end
15
+ post('chat.postMessage', options)
16
+ end
17
+
@@ -26,7 +26,12 @@ namespace :slack do
26
26
  method_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/method.erb'))
27
27
  data.each_with_index do |(group, names), index|
28
28
  printf "%2d/%2d %10s %s\n", index, data.size, group, names.keys
29
- File.write "lib/slack/web/api/endpoints/#{group}.rb", method_template.result(group: group, names: names)
29
+ rendered = method_template.result(group: group, names: names)
30
+ File.write "lib/slack/web/api/endpoints/#{group}.rb", rendered
31
+ Dir.glob("lib/slack/web/api/patches/#{group}*.patch").sort.each do |patch|
32
+ puts "- patching #{patch}"
33
+ system("git apply #{patch}") || fail('failed to apply patch')
34
+ end
30
35
  end
31
36
 
32
37
  endpoints_template = Erubis::Eruby.new(File.read('lib/slack/web/api/templates/endpoints.erb'))
@@ -18,11 +18,12 @@ Gem::Specification.new do |s|
18
18
  s.add_dependency 'faraday_middleware'
19
19
  s.add_dependency 'faye-websocket'
20
20
  s.add_dependency 'eventmachine'
21
+ s.add_dependency 'json'
21
22
  s.add_development_dependency 'erubis'
22
23
  s.add_development_dependency 'json-schema'
23
24
  s.add_development_dependency 'rake'
24
25
  s.add_development_dependency 'rspec'
25
26
  s.add_development_dependency 'vcr'
26
27
  s.add_development_dependency 'webmock'
27
- s.add_development_dependency 'rubocop', '0.32.1'
28
+ s.add_development_dependency 'rubocop', '0.35.0'
28
29
  end
data/slack.png ADDED
Binary file
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Slack::Web::Api::Endpoints::Chat do
4
+ let(:client) { Slack::Web::Client.new }
5
+ context 'chat_postMessage' do
6
+ it 'automatically converts attachments into JSON' do
7
+ expect(client).to receive(:post).with(
8
+ 'chat.postMessage',
9
+ channel: 'channel',
10
+ text: 'text',
11
+ attachments: '[]'
12
+ )
13
+ client.chat_postMessage(channel: 'channel', text: 'text', attachments: [])
14
+ end
15
+ context 'text and attachment arguments' do
16
+ it 'requires text or attachments' do
17
+ expect { client.chat_postMessage(channel: 'channel') }.to raise_error ArgumentError, /Required arguments :text or :attachments missing/
18
+ end
19
+ it 'only text' do
20
+ expect(client).to receive(:post).with('chat.postMessage', hash_including(text: 'text'))
21
+ expect { client.chat_postMessage(channel: 'channel', text: 'text') }.to_not raise_error
22
+ end
23
+ it 'only attachments' do
24
+ expect(client).to receive(:post).with('chat.postMessage', hash_including(attachments: '[]'))
25
+ expect { client.chat_postMessage(channel: 'channel', attachments: []) }.to_not raise_error
26
+ end
27
+ it 'both text and attachments' do
28
+ expect(client).to receive(:post).with('chat.postMessage', hash_including(text: 'text', attachments: '[]'))
29
+ expect { client.chat_postMessage(channel: 'channel', text: 'text', attachments: []) }.to_not raise_error
30
+ end
31
+ end
32
+ end
33
+ end
metadata CHANGED
@@ -1,153 +1,167 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Doubrovkine
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faraday_middleware
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faye-websocket
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: eventmachine
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: json
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: erubis
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '>='
87
+ - - ">="
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '>='
94
+ - - ">="
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: json-schema
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - '>='
101
+ - - ">="
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - '>='
108
+ - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - '>='
115
+ - - ">="
102
116
  - !ruby/object:Gem::Version
103
117
  version: '0'
104
118
  type: :development
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - '>='
122
+ - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: rspec
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - '>='
129
+ - - ">="
116
130
  - !ruby/object:Gem::Version
117
131
  version: '0'
118
132
  type: :development
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - '>='
136
+ - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: vcr
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - '>='
143
+ - - ">="
130
144
  - !ruby/object:Gem::Version
131
145
  version: '0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - '>='
150
+ - - ">="
137
151
  - !ruby/object:Gem::Version
138
152
  version: '0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: webmock
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - '>='
157
+ - - ">="
144
158
  - !ruby/object:Gem::Version
145
159
  version: '0'
146
160
  type: :development
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - '>='
164
+ - - ">="
151
165
  - !ruby/object:Gem::Version
152
166
  version: '0'
153
167
  - !ruby/object:Gem::Dependency
@@ -156,26 +170,26 @@ dependencies:
156
170
  requirements:
157
171
  - - '='
158
172
  - !ruby/object:Gem::Version
159
- version: 0.32.1
173
+ version: 0.35.0
160
174
  type: :development
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
178
  - - '='
165
179
  - !ruby/object:Gem::Version
166
- version: 0.32.1
180
+ version: 0.35.0
167
181
  description:
168
182
  email: dblock@dblock.org
169
183
  executables: []
170
184
  extensions: []
171
185
  extra_rdoc_files: []
172
186
  files:
173
- - .gitignore
174
- - .gitmodules
175
- - .rspec
176
- - .rubocop.yml
177
- - .rubocop_todo.yml
178
- - .travis.yml
187
+ - ".gitignore"
188
+ - ".gitmodules"
189
+ - ".rspec"
190
+ - ".rubocop.yml"
191
+ - ".rubocop_todo.yml"
192
+ - ".travis.yml"
179
193
  - CHANGELOG.md
180
194
  - CONTRIBUTING.md
181
195
  - Gemfile
@@ -192,6 +206,8 @@ files:
192
206
  - examples/hi_web/Gemfile
193
207
  - examples/hi_web/hi.gif
194
208
  - examples/hi_web/hi.rb
209
+ - examples/new_ticket/Gemfile
210
+ - examples/new_ticket/new_ticket.rb
195
211
  - lib/slack-ruby-client.rb
196
212
  - lib/slack.rb
197
213
  - lib/slack/config.rb
@@ -212,6 +228,7 @@ files:
212
228
  - lib/slack/web/api/endpoints/files.rb
213
229
  - lib/slack/web/api/endpoints/groups.rb
214
230
  - lib/slack/web/api/endpoints/im.rb
231
+ - lib/slack/web/api/endpoints/mpim.rb
215
232
  - lib/slack/web/api/endpoints/oauth.rb
216
233
  - lib/slack/web/api/endpoints/pins.rb
217
234
  - lib/slack/web/api/endpoints/presence.rb
@@ -222,6 +239,8 @@ files:
222
239
  - lib/slack/web/api/endpoints/team.rb
223
240
  - lib/slack/web/api/endpoints/users.rb
224
241
  - lib/slack/web/api/error.rb
242
+ - lib/slack/web/api/patches/chat.1.text-attachments-required.patch
243
+ - lib/slack/web/api/patches/chat.2.attachments-json.patch
225
244
  - lib/slack/web/api/schema/method.json
226
245
  - lib/slack/web/api/tasks/generate.rake
227
246
  - lib/slack/web/api/templates/endpoints.erb
@@ -234,6 +253,7 @@ files:
234
253
  - lib/slack_ruby_client.rb
235
254
  - screenshots/register-bot.png
236
255
  - slack-ruby-client.gemspec
256
+ - slack.png
237
257
  - spec/fixtures/slack/web/auth_test_error.yml
238
258
  - spec/fixtures/slack/web/auth_test_success.yml
239
259
  - spec/fixtures/slack/web/rtm_start.yml
@@ -245,6 +265,7 @@ files:
245
265
  - spec/slack/real_time/socket_spec.rb
246
266
  - spec/slack/version_spec.rb
247
267
  - spec/slack/web/api/endpoints/auth_spec.rb
268
+ - spec/slack/web/api/endpoints/chat_spec.rb
248
269
  - spec/slack/web/client_spec.rb
249
270
  - spec/spec_helper.rb
250
271
  - spec/support/real_time/connected_client.rb
@@ -260,17 +281,17 @@ require_paths:
260
281
  - lib
261
282
  required_ruby_version: !ruby/object:Gem::Requirement
262
283
  requirements:
263
- - - '>='
284
+ - - ">="
264
285
  - !ruby/object:Gem::Version
265
286
  version: '0'
266
287
  required_rubygems_version: !ruby/object:Gem::Requirement
267
288
  requirements:
268
- - - '>='
289
+ - - ">="
269
290
  - !ruby/object:Gem::Version
270
291
  version: 1.3.6
271
292
  requirements: []
272
293
  rubyforge_project:
273
- rubygems_version: 2.4.5
294
+ rubygems_version: 2.4.8
274
295
  signing_key:
275
296
  specification_version: 4
276
297
  summary: Slack Web and RealTime API client.
@@ -286,6 +307,7 @@ test_files:
286
307
  - spec/slack/real_time/socket_spec.rb
287
308
  - spec/slack/version_spec.rb
288
309
  - spec/slack/web/api/endpoints/auth_spec.rb
310
+ - spec/slack/web/api/endpoints/chat_spec.rb
289
311
  - spec/slack/web/client_spec.rb
290
312
  - spec/spec_helper.rb
291
313
  - spec/support/real_time/connected_client.rb