Skip to content

Commit 8a486ad

Browse files
committed
add options to request methods to allow for no response processing
1 parent dbff98d commit 8a486ad

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/slack/web/faraday/request.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@ module Slack
33
module Web
44
module Faraday
55
module Request
6-
def get(path, options = {})
7-
request(:get, path, options)
6+
def get(path, options = {}, expect_json_response: true)
7+
request(:get, path, options, expect_json_response)
88
end
99

10-
def post(path, options = {})
11-
request(:post, path, options)
10+
def post(path, options = {}, expect_json_response: true)
11+
request(:post, path, options, expect_json_response)
1212
end
1313

14-
def put(path, options = {})
15-
request(:put, path, options)
14+
def put(path, options = {}, expect_json_response: true)
15+
request(:put, path, options, expect_json_response)
1616
end
1717

18-
def delete(path, options = {})
19-
request(:delete, path, options)
18+
def delete(path, options = {}, expect_json_response: true)
19+
request(:delete, path, options, expect_json_response)
2020
end
2121

2222
private
2323

24-
def request(method, path, options)
25-
response = connection.send(method) do |request|
24+
def request(method, path, options, expect_json_response)
25+
connection_to_use = expect_json_response ? connection : connection_without_response_parsing
26+
response = connection_to_use.send(method) do |request|
2627
case method
2728
when :get, :delete
2829
request.url(path, options)

0 commit comments

Comments
 (0)