From d6766c55b278d61010a1b1b6141d3adb58ca06f7 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Mon, 20 Jan 2025 19:57:20 +0100 Subject: [PATCH] Require `content` parameter in update action (#34) The `content` check has always been present, but the `file` parameter is now mandatory. In the past, updating the title with `update_document` was possible, but now a dedicated action exists. Attempting to update a file without `content` raises: ``` Colore::Errors::ClientError: Invalid parameter file ``` --- lib/colore/client.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/colore/client.rb b/lib/colore/client.rb index adff9d8..292a1cc 100644 --- a/lib/colore/client.rb +++ b/lib/colore/client.rb @@ -104,7 +104,7 @@ def create_document(doc_id:, filename:, content:, title: nil, author: nil, actio # results of the conversion in it # # @return [Hash] a standard response - def update_document(doc_id:, filename:, content: nil, author: nil, actions: nil, callback_url: nil) + def update_document(doc_id:, filename:, content:, author: nil, actions: nil, callback_url: nil) params = {} params[:actions] = actions if actions params[:author] = author if author @@ -114,12 +114,8 @@ def update_document(doc_id:, filename:, content: nil, author: nil, actions: nil, base_filename = File.basename(filename) response = nil - if content - with_tempfile(content) do |io| - params[:file] = file_param(io) - response = send_request :post, "#{url_for_base(doc_id)}/#{encode_param(base_filename)}", params, :json - end - else + with_tempfile(content) do |io| + params[:file] = file_param(io) response = send_request :post, "#{url_for_base(doc_id)}/#{encode_param(base_filename)}", params, :json end response