Skip to content

Commit

Permalink
Require content parameter in update action
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
tagliala committed Jan 20, 2025
1 parent be8e2f9 commit 41efdf7
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/colore/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 41efdf7

Please sign in to comment.