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

fix(bundles): add destination parameter #85

Merged
Merged
Show file tree
Hide file tree
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: 3 additions & 2 deletions lib/crowdin-api/api_resources/bundles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ def check_bundle_export_status(bundle_id, export_id, project_id = config.project

# @param bundle_id [Integer] Bundle ID
# @param export_id [String] Export ID
# @param destination [String] Destination of File
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.download.get API Documentation}
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.exports.download.get Enterprise API Documentation}
def download_bundle(bundle_id, export_id, project_id = config.project_id)
def download_bundle(bundle_id, export_id, destination = nil, project_id = config.project_id)
bundle_id || raise_parameter_is_required_error(:bundle_id)
export_id || raise_parameter_is_required_error(:export_id)
project_id || raise_project_id_is_required_error
Expand All @@ -82,7 +83,7 @@ def download_bundle(bundle_id, export_id, project_id = config.project_id)
:get,
"#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}/download"
)
Web::SendRequest.new(request).perform
Web::SendRequest.new(request, destination).perform
end

# @param bundle_id [Integer] Bundle ID
Expand Down
2 changes: 1 addition & 1 deletion spec/api_resources/bundles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

it 'when request are valid', :default do
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}/download")
download_bundle = @crowdin.download_bundle(bundle_id, export_id, project_id)
download_bundle = @crowdin.download_bundle(bundle_id, export_id, nil, project_id)
expect(download_bundle).to eq(200)
end
end
Expand Down