Skip to content

Commit

Permalink
Add multipage conversion (save_in_group) parameter to document conver…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
vipulnsward committed Jun 22, 2024
1 parent df19608 commit bda80cb
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 19 deletions.
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' }
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

0 comments on commit bda80cb

Please sign in to comment.