Skip to content

Commit ed6ad46

Browse files
committed
remove extra parameter, determine if response should be parsed into json based on the request type
1 parent 87885d8 commit ed6ad46

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

lib/slack/web/api/helpers/files.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def files_upload_v2(options = {})
4444
file_id = get_upload_url_response[:file_id]
4545

4646
# 2. upload the file and do not process the return body
47-
post(upload_url, content, false)
47+
post(upload_url, content)
4848

4949
# 3. complete the upload
5050
complete_upload_request_params = options.slice(:channels, :initial_comment, :thread_ts)

lib/slack/web/faraday/connection.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def connection
3737
end
3838

3939
def connection_without_response_parsing
40-
@connection_without_response_parsing ||= create_connection(false)
40+
@connection_without_response_parsing ||= create_connection(expect_json_response: false)
4141
end
4242

4343
private :create_connection

lib/slack/web/faraday/request.rb

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

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

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

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

2222
private
2323

24-
def request(method, path, options, expect_json_response)
24+
def request(method, path, options)
25+
expect_json_response = options.is_a? Hash
2526
connection_to_use = expect_json_response ? connection : connection_without_response_parsing
2627
response = connection_to_use.send(method) do |request|
2728
case method

0 commit comments

Comments
 (0)