Skip to content

Commit

Permalink
For Uploadcare::ConversionApi added `get_document_conversion_format…
Browse files Browse the repository at this point in the history
…s_info` method to get the possible document conversion formats. (#145)

* For  added  method to get the possible document conversion formats.

* Exclude Metrics/ModuleLength for specs
  • Loading branch information
vipulnsward committed Jun 1, 2024
1 parent 22386b3 commit 964d360
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ Style/OpenStructUse:
- 'spec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rb'
- 'spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb'
- 'spec/uploadcare/rails/objects/file_spec.rb'

Metrics/ModuleLength:
Exclude:
- 'spec/**/*'
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based now on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

* For `Uploadcare::ConversionApi` added `get_document_conversion_formats_info` method to get the possible document conversion formats.

## 3.4.2 — 2024-05-11

### Added
Expand Down
6 changes: 6 additions & 0 deletions lib/uploadcare/rails/api/rest/conversion_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ def get_video_conversion_status(token)
Uploadcare::VideoConverter.status(token)
end

# Conversion formats info
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#tag/Conversion/operation/documentConvertInfo
def get_document_conversion_formats_info(uuid)
Uploadcare::DocumentConverter.info(uuid)
end

# Converts documents
# @see https://uploadcare.com/api-refs/rest-api/v0.7.0/#operation/documentConvert
def convert_document(document_params, options = {})
Expand Down

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

21 changes: 20 additions & 1 deletion spec/uploadcare/rails/api/rest/conversion_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ module Rest

context 'when checking methods' do
it 'responds to expected REST methods' do
%i[convert_video get_video_conversion_status convert_document get_document_conversion_status].each do |m|
%i[
convert_video
get_video_conversion_status
convert_document
get_document_conversion_status
get_document_conversion_formats_info
].each do |m|
expect(subject).to respond_to(m)
end
end
Expand Down Expand Up @@ -88,6 +94,19 @@ module Rest
expect(response.success[:error]).to be_nil
end
end

it 'gets document conversion formats info' do
VCR.use_cassette('conversion_api_get_document_conversion_formats_info') do
uuid = 'b3b32bcb-9bd8-4ee2-a4df-95bcee96b47e'
response = subject.get_document_conversion_formats_info(uuid)
expect(response).to be_success
expect(response.success[:error]).to be_nil
expect(response.success[:format][:name]).to be_a(String)
conversion_formats = response.success[:format][:conversion_formats]
expect(conversion_formats).to be_a(Array)
expect(conversion_formats.first[:name]).to be_a(String)
end
end
end

context 'and when request is failed' do
Expand Down
2 changes: 1 addition & 1 deletion uploadcare-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ Gem::Specification.new do |gem|

gem.version = Uploadcare::Rails::VERSION
gem.add_dependency 'rails', '>= 6'
gem.add_dependency 'uploadcare-ruby', '>= 4.4.1'
gem.add_dependency 'uploadcare-ruby', '>= 4.4.2'
end

0 comments on commit 964d360

Please sign in to comment.