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

Add multipage conversion (save_in_group) parameter to document conversion #173

Merged
merged 1 commit into from
Jun 22, 2024
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: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

### Added
* Multi page conversion parameter (`save_in_group`) added to `DocumentConverter#convert` options.

## 4.4.2 — 2024-05-29

### Fixed
Expand Down
4 changes: 3 additions & 1 deletion api_examples/rest_api/post_convert_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
Uploadcare.config.secret_key = 'YOUR_SECRET_KEY'

document_params = { uuid: '1bac376c-aa7e-4356-861b-dd2657b5bfd2', format: :pdf }
options = { store: true }
options = { store: '1' }
# for multipage conversion
# options = { store: '1', save_in_group: '1' }
vipulnsward marked this conversation as resolved.
Show resolved Hide resolved
Uploadcare::DocumentConverter.convert(document_params, options)
3 changes: 2 additions & 1 deletion lib/uploadcare/client/conversion/base_conversion_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def build_body_for_many(arr, options, url_builder_class)
**build_paths_body(params)
)
end,
store: options[:store]
store: options[:store],
save_in_group: options[:save_in_group]
}.compact.to_json
end
end
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

118 changes: 118 additions & 0 deletions spec/fixtures/vcr_cassettes/document_convert_convert_multipage_zip.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 62 additions & 0 deletions spec/fixtures/vcr_cassettes/document_convert_to_multipage.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions spec/support/vcr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
i.request.body = "Big string (#{i.request.body.size / (1024 * 1024)}) MB"
end
end
config.configure_rspec_metadata!
end
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ module Conversion

shared_examples 'succeeds documents conversion' do
it 'returns a convert documents response' do
VCR.use_cassette('document_convert_convert_many') do
expect(subject).to be_success
end
expect(subject).to be_success
end
end

Expand All @@ -29,7 +27,21 @@ module Conversion
end
let(:options) { { store: false } }

context 'when all params are present' do
context 'when all params are present', vcr: 'document_convert_convert_many' do
it_behaves_like 'succeeds documents conversion'
end

context 'multipage conversion', vcr: 'document_convert_to_multipage' do
let(:array_of_params) do
[
{
uuid: '23d29586-713e-4152-b400-05fb54730453',
format: 'png'
}
]
end
let(:options) { { store: '0', save_in_group: '1' } }

it_behaves_like 'succeeds documents conversion'
end
end
Expand Down
Loading
Loading