diff --git a/examples/alternative_converter.rb b/examples/alternative_converter.rb deleted file mode 100644 index 34e441b..0000000 --- a/examples/alternative_converter.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'convert_api' -require 'tmpdir' - -ConvertApi.configure do |config| - config.api_secret = ENV['CONVERT_API_SECRET'] # your api secret - # or - config.token = ENV['CONVERT_API_TOKEN'] # your token -end - -# Example of saving Word docx to PDF using OpenOffice converter -# https://www.convertapi.com/doc-to-pdf/openoffice - -# Use upload IO wrapper to upload file only once to the API -upload_io = ConvertApi::UploadIO.new(File.open('files/test.docx')) - -saved_files = ConvertApi - .convert('pdf', {File: upload_io, converter: 'openofficetopdf'}) - .save_files(Dir.tmpdir) - -puts "The PDF saved to: #{saved_files}" diff --git a/lib/convert_api/task.rb b/lib/convert_api/task.rb index 39194d4..85fcc1f 100644 --- a/lib/convert_api/task.rb +++ b/lib/convert_api/task.rb @@ -15,11 +15,9 @@ def run from_format = @from_format || detect_format(params) read_timeout = @conversion_timeout + config.conversion_timeout_delta if @conversion_timeout - converter = detect_converter(params) - converter_path = converter ? "/converter/#{converter}" : '' response = ConvertApi.client.post( - "convert/#{from_format}/to/#{@to_format}#{converter_path}", + "convert/#{from_format}/to/#{@to_format}", params, read_timeout: read_timeout, ) @@ -70,14 +68,6 @@ def detect_format(params) FormatDetector.new(resource, @to_format).run end - def detect_converter(params) - params.each do |key, value| - return value if key.to_s.downcase == 'converter' - end - - nil - end - def config ConvertApi.config end diff --git a/spec/convert_api/task_spec.rb b/spec/convert_api/task_spec.rb index 8af9197..d8b87c8 100644 --- a/spec/convert_api/task_spec.rb +++ b/spec/convert_api/task_spec.rb @@ -16,18 +16,6 @@ expect(subject).to be_instance_of(ConvertApi::Result) end - context 'with converter' do - let(:params) { { File: file, Converter: 'openoffice' } } - - it 'adds converter to the path' do - expect(ConvertApi.client).to( - receive(:post).with('convert/txt/to/pdf/converter/openoffice', instance_of(Hash), instance_of(Hash)).and_return(result) - ) - - expect(subject).to be_instance_of(ConvertApi::Result) - end - end - context 'when file is instance of ResultFile' do let(:file) { ConvertApi::ResultFile.new('Url' => 'testurl') } let(:expected_params) { hash_including(File: 'testurl') }