Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Return the full API response if the destination param is not passed #69

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/crowdin-api/core/send_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def parse_response(response)
end

def fetch_response_data(doc)
if doc['data'].is_a?(Hash) && doc['data']['url'] && doc['data']['url'].include?('response-content-disposition')
if @file_destination && doc['data'].is_a?(Hash) && doc['data']['url']
download_file(doc['data']['url'])
else
doc
Expand All @@ -53,8 +53,7 @@ def fetch_response_data(doc)

def download_file(url)
download = URI.parse(url).open
destination = @file_destination || download.meta['content-disposition']
.match(/filename=("?)(.+)\1/)[2]
destination = @file_destination

IO.copy_stream(download, destination)

Expand Down
Loading