Sha256: c08f60df49553d4900a94aa0b8b32cb0a0afd18f98d4b5076746a501657ec1e2

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

module SugarCRM; class Connection
  # Sets a new revision for a document.
  def set_document_revision(document_id, revision_number, opts={})
    options = { 
      :file => '', 
      :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])}"
        }
      }
    EOF
    json.gsub!(/^\s{6}/,'')
    send!(:set_document_revision, json)
  end
end; end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
sugarcrm_emp-0.10.5 lib/sugarcrm/connection/api/set_document_revision.rb
sugarcrm_emp-0.10.1 lib/sugarcrm/connection/api/set_document_revision.rb
sugarcrm_emp-0.10.0 lib/sugarcrm/connection/api/set_document_revision.rb
sugarcrm-0.9.18 lib/sugarcrm/connection/api/set_document_revision.rb
sugarcrm-0.9.17 ./lib/sugarcrm/connection/api/set_document_revision.rb
sugarcrm-0.9.16 ./lib/sugarcrm/connection/api/set_document_revision.rb
sugarcrm-0.9.15 ./lib/sugarcrm/connection/api/set_document_revision.rb
sugarcrm-0.9.14 ./lib/sugarcrm/connection/api/set_document_revision.rb