Permalink
Browse files

Added document_name option to set_document_revision

  • Loading branch information...
1 parent 0d9e2f3 commit 9edbca88786091bf454fb4a1567851f67c34a0ba @chicks chicks committed May 4, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/sugarcrm/connection/api/set_document_revision.rb
@@ -3,23 +3,29 @@ module SugarCRM; class Connection
def set_document_revision(document_id, revision_number, opts={})
options = {
:file => '',
- :file_name => ''
+ :file_name => '',
+ :document_name => nil
}.merge! opts
# Raise an exception of we try to pass :file, but not :file_name
if (!options[:file].empty? && options[:file_name].empty?)
raise ArgumentException, ":file_name must be specified if :file is specified"
end
+ # If no document_name is given, use the file_name
+ options[:document_name] ||= options[:file_name]
+
login! unless logged_in?
+
json = <<-EOF
{
"session": "#{@sugar_session_id}",
"document_revision": {
"id": "#{document_id}",
+ "document_name": "#{options[:document_name]}",
+ "revision": "#{revision_number}",
"filename": "#{options[:file_name]}",
- "file": "#{b64_encode(options[:file])}",
- "revision": "#{revision_number}"
+ "file": "#{b64_encode(options[:file])}"
}
}
EOF

0 comments on commit 9edbca8

Please sign in to comment.