slack-ruby-client-bhe 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +17 -0
  2. data/.gitignore +4 -0
  3. data/.gitmodules +3 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +6 -0
  6. data/.rubocop_todo.yml +78 -0
  7. data/.travis.yml +26 -0
  8. data/CHANGELOG.md +79 -0
  9. data/CONTRIBUTING.md +157 -0
  10. data/Gemfile +5 -0
  11. data/LICENSE.md +22 -0
  12. data/README.md +385 -0
  13. data/RELEASING.md +69 -0
  14. data/Rakefile +19 -0
  15. data/UPGRADING.md +26 -0
  16. data/bin/commands.rb +21 -0
  17. data/bin/commands/api.rb +14 -0
  18. data/bin/commands/auth.rb +12 -0
  19. data/bin/commands/channels.rb +149 -0
  20. data/bin/commands/chat.rb +47 -0
  21. data/bin/commands/dnd.rb +47 -0
  22. data/bin/commands/emoji.rb +12 -0
  23. data/bin/commands/files.rb +72 -0
  24. data/bin/commands/groups.rb +167 -0
  25. data/bin/commands/im.rb +53 -0
  26. data/bin/commands/mpim.rb +53 -0
  27. data/bin/commands/oauth.rb +16 -0
  28. data/bin/commands/pins.rb +37 -0
  29. data/bin/commands/reactions.rb +53 -0
  30. data/bin/commands/rtm.rb +15 -0
  31. data/bin/commands/search.rb +40 -0
  32. data/bin/commands/stars.rb +37 -0
  33. data/bin/commands/team.rb +32 -0
  34. data/bin/commands/usergroups.rb +73 -0
  35. data/bin/commands/users.rb +57 -0
  36. data/bin/slack +50 -0
  37. data/examples/hi_real_time/Gemfile +5 -0
  38. data/examples/hi_real_time/hi.gif +0 -0
  39. data/examples/hi_real_time/hi.rb +32 -0
  40. data/examples/hi_real_time_and_web/Gemfile +5 -0
  41. data/examples/hi_real_time_and_web/hi.gif +0 -0
  42. data/examples/hi_real_time_and_web/hi.rb +24 -0
  43. data/examples/hi_real_time_async/Gemfile +5 -0
  44. data/examples/hi_real_time_async/hi.rb +29 -0
  45. data/examples/hi_web/Gemfile +3 -0
  46. data/examples/hi_web/hi.gif +0 -0
  47. data/examples/hi_web/hi.rb +12 -0
  48. data/examples/new_ticket/Gemfile +3 -0
  49. data/examples/new_ticket/new_ticket.rb +25 -0
  50. data/lib/slack-ruby-client.rb +29 -0
  51. data/lib/slack.rb +1 -0
  52. data/lib/slack/config.rb +21 -0
  53. data/lib/slack/messages/formatting.rb +30 -0
  54. data/lib/slack/real_time/api/message.rb +20 -0
  55. data/lib/slack/real_time/api/message_id.rb +14 -0
  56. data/lib/slack/real_time/api/ping.rb +16 -0
  57. data/lib/slack/real_time/api/typing.rb +17 -0
  58. data/lib/slack/real_time/client.rb +152 -0
  59. data/lib/slack/real_time/concurrency.rb +8 -0
  60. data/lib/slack/real_time/concurrency/celluloid.rb +93 -0
  61. data/lib/slack/real_time/concurrency/eventmachine.rb +39 -0
  62. data/lib/slack/real_time/config.rb +55 -0
  63. data/lib/slack/real_time/socket.rb +81 -0
  64. data/lib/slack/version.rb +3 -0
  65. data/lib/slack/web/api/endpoints.rb +53 -0
  66. data/lib/slack/web/api/endpoints/api.rb +24 -0
  67. data/lib/slack/web/api/endpoints/auth.rb +20 -0
  68. data/lib/slack/web/api/endpoints/channels.rb +220 -0
  69. data/lib/slack/web/api/endpoints/chat.rb +91 -0
  70. data/lib/slack/web/api/endpoints/dnd.rb +64 -0
  71. data/lib/slack/web/api/endpoints/emoji.rb +20 -0
  72. data/lib/slack/web/api/endpoints/files.rb +108 -0
  73. data/lib/slack/web/api/endpoints/groups.rb +247 -0
  74. data/lib/slack/web/api/endpoints/im.rb +85 -0
  75. data/lib/slack/web/api/endpoints/mpim.rb +84 -0
  76. data/lib/slack/web/api/endpoints/oauth.rb +32 -0
  77. data/lib/slack/web/api/endpoints/pins.rb +64 -0
  78. data/lib/slack/web/api/endpoints/presence.rb +23 -0
  79. data/lib/slack/web/api/endpoints/reactions.rb +89 -0
  80. data/lib/slack/web/api/endpoints/rtm.rb +27 -0
  81. data/lib/slack/web/api/endpoints/search.rb +65 -0
  82. data/lib/slack/web/api/endpoints/stars.rb +61 -0
  83. data/lib/slack/web/api/endpoints/team.rb +47 -0
  84. data/lib/slack/web/api/endpoints/usergroups.rb +113 -0
  85. data/lib/slack/web/api/endpoints/users.rb +73 -0
  86. data/lib/slack/web/api/error.rb +14 -0
  87. data/lib/slack/web/api/mixins.rb +3 -0
  88. data/lib/slack/web/api/mixins/channels.id.json +20 -0
  89. data/lib/slack/web/api/mixins/channels.id.rb +26 -0
  90. data/lib/slack/web/api/mixins/groups.id.json +20 -0
  91. data/lib/slack/web/api/mixins/groups.id.rb +26 -0
  92. data/lib/slack/web/api/mixins/users.id.json +20 -0
  93. data/lib/slack/web/api/mixins/users.id.rb +26 -0
  94. data/lib/slack/web/api/patches/chat.1.text-attachments-required.patch +13 -0
  95. data/lib/slack/web/api/patches/chat.2.attachments-json.patch +17 -0
  96. data/lib/slack/web/api/schema/group.json +14 -0
  97. data/lib/slack/web/api/schema/method.json +45 -0
  98. data/lib/slack/web/api/tasks/generate.rake +61 -0
  99. data/lib/slack/web/api/templates/command.erb +34 -0
  100. data/lib/slack/web/api/templates/commands.erb +5 -0
  101. data/lib/slack/web/api/templates/endpoints.erb +21 -0
  102. data/lib/slack/web/api/templates/method.erb +49 -0
  103. data/lib/slack/web/client.rb +28 -0
  104. data/lib/slack/web/config.rb +41 -0
  105. data/lib/slack/web/faraday/connection.rb +29 -0
  106. data/lib/slack/web/faraday/request.rb +39 -0
  107. data/lib/slack/web/faraday/response/raise_error.rb +15 -0
  108. data/lib/slack_ruby_client.rb +1 -0
  109. data/screenshots/register-bot.png +0 -0
  110. data/slack-ruby-client.gemspec +31 -0
  111. data/slack.png +0 -0
  112. data/spec/fixtures/slack/web/429_error.yml +83 -0
  113. data/spec/fixtures/slack/web/auth_test_error.yml +48 -0
  114. data/spec/fixtures/slack/web/auth_test_success.yml +57 -0
  115. data/spec/fixtures/slack/web/channels_info.yml +46 -0
  116. data/spec/fixtures/slack/web/groups_info.yml +43 -0
  117. data/spec/fixtures/slack/web/rtm_start.yml +73 -0
  118. data/spec/fixtures/slack/web/users_info.yml +130 -0
  119. data/spec/fixtures/slack/web/users_list.yml +72 -0
  120. data/spec/integration/integration_spec.rb +107 -0
  121. data/spec/slack/config_spec.rb +14 -0
  122. data/spec/slack/messages/formatting_spec.rb +43 -0
  123. data/spec/slack/real_time/api/message_spec.rb +15 -0
  124. data/spec/slack/real_time/api/ping_spec.rb +15 -0
  125. data/spec/slack/real_time/api/typing_spec.rb +15 -0
  126. data/spec/slack/real_time/client_spec.rb +198 -0
  127. data/spec/slack/real_time/concurrency/celluloid_spec.rb +58 -0
  128. data/spec/slack/real_time/concurrency/eventmachine_spec.rb +49 -0
  129. data/spec/slack/slack_spec.rb +58 -0
  130. data/spec/slack/version_spec.rb +7 -0
  131. data/spec/slack/web/api/endpoints/auth_spec.rb +20 -0
  132. data/spec/slack/web/api/endpoints/channels_spec.rb +11 -0
  133. data/spec/slack/web/api/endpoints/chat_spec.rb +33 -0
  134. data/spec/slack/web/api/endpoints/groups_spec.rb +11 -0
  135. data/spec/slack/web/api/endpoints/users_spec.rb +17 -0
  136. data/spec/slack/web/api/error_spec.rb +14 -0
  137. data/spec/slack/web/api/mixins/channels_spec.rb +31 -0
  138. data/spec/slack/web/api/mixins/groups_spec.rb +31 -0
  139. data/spec/slack/web/api/mixins/users_spec.rb +31 -0
  140. data/spec/slack/web/client_spec.rb +134 -0
  141. data/spec/spec_helper.rb +14 -0
  142. data/spec/support/queue_with_timeout.rb +34 -0
  143. data/spec/support/real_time/concurrency/mock.rb +31 -0
  144. data/spec/support/real_time/connected_client.rb +16 -0
  145. data/spec/support/token.rb +10 -0
  146. data/spec/support/vcr.rb +8 -0
  147. metadata +392 -0
@@ -0,0 +1,47 @@
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 Team
8
+ #
9
+ # This method is used to get the access logs for users on a team.
10
+ #
11
+ # @see https://api.slack.com/methods/team.accessLogs
12
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.accessLogs.json
13
+ def team_accessLogs(options = {})
14
+ post('team.accessLogs', options)
15
+ end
16
+
17
+ #
18
+ # This method provides information about your team.
19
+ #
20
+ # @see https://api.slack.com/methods/team.info
21
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/team.info.json
22
+ def team_info(options = {})
23
+ post('team.info', options)
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 Slack app. 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
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
41
+ post('team.integrationLogs', options)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,113 @@
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 Usergroups
8
+ #
9
+ # This method is used to create a user group.
10
+ #
11
+ # @option options [Object] :name
12
+ # A name for the user group. Must be unique among user groups.
13
+ # @option options [Object] :handle
14
+ # A mention handle. Must be unique among channels, users and user groups.
15
+ # @option options [Object] :description
16
+ # A short description of the user group.
17
+ # @option options [Object] :channels
18
+ # A comma separated string of encoded channel IDs for which the user group uses as a default.
19
+ # @option options [Object] :include_count
20
+ # Include the number of users in each user group.
21
+ # @see https://api.slack.com/methods/usergroups.create
22
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.create.json
23
+ def usergroups_create(options = {})
24
+ throw ArgumentError.new('Required arguments :name missing') if options[:name].nil?
25
+ post('usergroups.create', options)
26
+ end
27
+
28
+ #
29
+ # This method disables an existing user group.
30
+ #
31
+ # @option options [Object] :usergroup
32
+ # The encoded ID of the user group to disable.
33
+ # @option options [Object] :include_count
34
+ # Include the number of users in the user group.
35
+ # @see https://api.slack.com/methods/usergroups.disable
36
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.disable.json
37
+ def usergroups_disable(options = {})
38
+ throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
39
+ post('usergroups.disable', options)
40
+ end
41
+
42
+ #
43
+ # This method enables a user group which was previously disabled.
44
+ #
45
+ # @option options [Object] :usergroup
46
+ # The encoded ID of the user group to enable.
47
+ # @option options [Object] :include_count
48
+ # Include the number of users in the user group.
49
+ # @see https://api.slack.com/methods/usergroups.enable
50
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.enable.json
51
+ def usergroups_enable(options = {})
52
+ throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
53
+ post('usergroups.enable', options)
54
+ end
55
+
56
+ #
57
+ # This method returns a list of all user groups in the team. This can optionally include disabled user groups.
58
+ #
59
+ # @option options [Object] :include_disabled
60
+ # Include disabled user groups.
61
+ # @option options [Object] :include_count
62
+ # Include the number of users in each user group.
63
+ # @option options [Object] :include_users
64
+ # Include the list of users for each user group.
65
+ # @see https://api.slack.com/methods/usergroups.list
66
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.list.json
67
+ def usergroups_list(options = {})
68
+ post('usergroups.list', options)
69
+ end
70
+
71
+ #
72
+ # This method updates the properties of an existing user group.
73
+ #
74
+ # @option options [Object] :usergroup
75
+ # The encoded ID of the user group to update.
76
+ # @option options [Object] :name
77
+ # A name for the user group. Must be unique among user groups.
78
+ # @option options [Object] :handle
79
+ # A mention handle. Must be unique among channels, users and user groups.
80
+ # @option options [Object] :description
81
+ # A short description of the user group.
82
+ # @option options [Object] :channels
83
+ # A comma separated string of encoded channel IDs for which the user group uses as a default.
84
+ # @option options [Object] :include_count
85
+ # Include the number of users in the user group.
86
+ # @see https://api.slack.com/methods/usergroups.update
87
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.update.json
88
+ def usergroups_update(options = {})
89
+ throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
90
+ post('usergroups.update', options)
91
+ end
92
+
93
+ #
94
+ # This method updates the list of users that belong to a user group. This method replaces all users in a user group with the list of users provided in the users parameter.
95
+ #
96
+ # @option options [Object] :usergroup
97
+ # The encoded ID of the user group to update.
98
+ # @option options [Object] :users
99
+ # A comma separated string of encoded user IDs that represent the entire list of users for the user group.
100
+ # @option options [Object] :include_count
101
+ # Include the number of users in the user group.
102
+ # @see https://api.slack.com/methods/usergroups.users
103
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/usergroups.users.json
104
+ def usergroups_users(options = {})
105
+ throw ArgumentError.new('Required arguments :usergroup missing') if options[:usergroup].nil?
106
+ throw ArgumentError.new('Required arguments :users missing') if options[:users].nil?
107
+ post('usergroups.users', options)
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,73 @@
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 Users
8
+ #
9
+ # This method lets you find out information about a user's presence.
10
+ # Consult the presence documentation for more details.
11
+ #
12
+ # @option options [user] :user
13
+ # User to get presence info on. Defaults to the authed user.
14
+ # @see https://api.slack.com/methods/users.getPresence
15
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.getPresence.json
16
+ def users_getPresence(options = {})
17
+ throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
18
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
19
+ post('users.getPresence', options)
20
+ end
21
+
22
+ #
23
+ # This method returns information about a team member.
24
+ #
25
+ # @option options [user] :user
26
+ # User to get info on.
27
+ # @see https://api.slack.com/methods/users.info
28
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.info.json
29
+ def users_info(options = {})
30
+ throw ArgumentError.new('Required arguments :user missing') if options[:user].nil?
31
+ options = options.merge(user: users_id(options)['user']['id']) if options[:user]
32
+ post('users.info', options)
33
+ end
34
+
35
+ #
36
+ # This method returns a list of all users in the team. This includes deleted/deactivated users.
37
+ #
38
+ # @option options [Object] :presence
39
+ # Whether to include presence data in the output.
40
+ # @see https://api.slack.com/methods/users.list
41
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.list.json
42
+ def users_list(options = {})
43
+ post('users.list', options)
44
+ end
45
+
46
+ #
47
+ # This method lets the slack messaging server know that the authenticated user
48
+ # is currently active. Consult the presence documentation for
49
+ # more details.
50
+ #
51
+ # @see https://api.slack.com/methods/users.setActive
52
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.setActive.json
53
+ def users_setActive(options = {})
54
+ post('users.setActive', options)
55
+ end
56
+
57
+ #
58
+ # This method lets you set the calling user's manual presence.
59
+ # Consult the presence documentation for more details.
60
+ #
61
+ # @option options [Object] :presence
62
+ # Either auto or away.
63
+ # @see https://api.slack.com/methods/users.setPresence
64
+ # @see https://github.com/dblock/slack-api-ref/blob/master/methods/users.setPresence.json
65
+ def users_setPresence(options = {})
66
+ throw ArgumentError.new('Required arguments :presence missing') if options[:presence].nil?
67
+ post('users.setPresence', options)
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,14 @@
1
+ module Slack
2
+ module Web
3
+ module Api
4
+ class Error < ::Faraday::Error
5
+ attr_reader :response
6
+
7
+ def initialize(message, response = nil)
8
+ @response = response
9
+ super message
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ require 'slack/web/api/mixins/channels.id'
2
+ require 'slack/web/api/mixins/users.id'
3
+ require 'slack/web/api/mixins/groups.id'
@@ -0,0 +1,20 @@
1
+ {
2
+ "mixin": true,
3
+ "group": "channels",
4
+ "name": "channels.id",
5
+ "desc": "This method returns the ID of a team channel.",
6
+ "args": {
7
+ "channel": {
8
+ "required": true,
9
+ "example": "#general",
10
+ "desc": "Channel to get ID for, prefixed with #.",
11
+ "type": "channel"
12
+ }
13
+ },
14
+ "errors": {
15
+ "channel_not_found": "Value passed for channel was invalid.",
16
+ "not_authed": "No authentication token provided.",
17
+ "invalid_auth": "Invalid authentication token.",
18
+ "account_inactive": "Authentication token is for a deleted user or team."
19
+ }
20
+ }
@@ -0,0 +1,26 @@
1
+ module Slack
2
+ module Web
3
+ module Api
4
+ module Mixins
5
+ module Channels
6
+ #
7
+ # This method returns a channel ID given a channel name.
8
+ #
9
+ # @option options [channel] :channel
10
+ # Channel to get ID for, prefixed with #.
11
+ def channels_id(options = {})
12
+ name = options[:channel]
13
+ throw ArgumentError.new('Required arguments :channel missing') if name.nil?
14
+ return { 'ok' => true, 'channel' => { 'id' => name } } unless name[0] == '#'
15
+ channels_list.tap do |list|
16
+ list['channels'].each do |channel|
17
+ return { 'ok' => true, 'channel' => { 'id' => channel['id'] } } if channel['name'] == name[1..-1]
18
+ end
19
+ end
20
+ fail Slack::Web::Api::Error, 'channel_not_found'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ {
2
+ "mixin": true,
3
+ "group": "groups",
4
+ "name": "groups.id",
5
+ "desc": "This method returns the ID of a group.",
6
+ "args": {
7
+ "channel": {
8
+ "required": true,
9
+ "example": "#general",
10
+ "desc": "Group channel to get ID for, prefixed with #.",
11
+ "type": "group"
12
+ }
13
+ },
14
+ "errors": {
15
+ "channel_not_found": "Value passed for group was invalid.",
16
+ "not_authed": "No authentication token provided.",
17
+ "invalid_auth": "Invalid authentication token.",
18
+ "account_inactive": "Authentication token is for a deleted user or team."
19
+ }
20
+ }
@@ -0,0 +1,26 @@
1
+ module Slack
2
+ module Web
3
+ module Api
4
+ module Mixins
5
+ module Groups
6
+ #
7
+ # This method returns a group ID given a group name.
8
+ #
9
+ # @option options [channel] :channel
10
+ # Group channel to get ID for, prefixed with #.
11
+ def groups_id(options = {})
12
+ name = options[:channel]
13
+ throw ArgumentError.new('Required arguments :channel missing') if name.nil?
14
+ return { 'ok' => true, 'group' => { 'id' => name } } unless name[0] == '#'
15
+ groups_list.tap do |list|
16
+ list['groups'].each do |group|
17
+ return { 'ok' => true, 'group' => { 'id' => group['id'] } } if group['name'] == name[1..-1]
18
+ end
19
+ end
20
+ fail Slack::Web::Api::Error, 'channel_not_found'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ {
2
+ "mixin": true,
3
+ "group": "users",
4
+ "name": "users.id",
5
+ "desc": "This method returns the ID of a team user.",
6
+ "args": {
7
+ "user": {
8
+ "required": true,
9
+ "example": "#general",
10
+ "desc": "User to get ID for, prefixed with @.",
11
+ "type": "user"
12
+ }
13
+ },
14
+ "errors": {
15
+ "user_not_found": "Value passed for user was invalid.",
16
+ "not_authed": "No authentication token provided.",
17
+ "invalid_auth": "Invalid authentication token.",
18
+ "account_inactive": "Authentication token is for a deleted user or team."
19
+ }
20
+ }
@@ -0,0 +1,26 @@
1
+ module Slack
2
+ module Web
3
+ module Api
4
+ module Mixins
5
+ module Users
6
+ #
7
+ # This method returns a user ID given a user name.
8
+ #
9
+ # @option options [user] :user
10
+ # User to get ID for, prefixed with '@'.
11
+ def users_id(options = {})
12
+ name = options[:user]
13
+ throw ArgumentError.new('Required arguments :user missing') if name.nil?
14
+ return { 'ok' => true, 'user' => { 'id' => name } } unless name[0] == '@'
15
+ users_list.tap do |list|
16
+ list['members'].each do |user|
17
+ return { 'ok' => true, 'user' => { 'id' => user['id'] } } if user['name'] == name[1..-1]
18
+ end
19
+ end
20
+ fail Slack::Web::Api::Error, 'user_not_found'
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ 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
+
@@ -0,0 +1,14 @@
1
+ {
2
+ "type": "object",
3
+ "required": [
4
+ "name"
5
+ ],
6
+ "properties": {
7
+ "name": {
8
+ "type": "string"
9
+ },
10
+ "desc": {
11
+ "type": "string"
12
+ }
13
+ }
14
+ }