Sha256: 9ea78ed6821ef047474b380818da32b291a79df9c1b51b044b7ecf7b5ae61dc5

Contents?: true

Size: 1.84 KB

Versions: 7

Compression:

Stored size: 1.84 KB

Contents

# GET request
get '/sample22' do
  haml :sample22
end

# POST request
post '/sample22' do
  # set variables
  set :client_id, params[:client_id]
  set :private_key, params[:private_key]
  set :fileId, params[:fileId]
  set :email, params[:email]
  set :first_name, params[:first_name]
  set :last_name, params[:last_name]

  begin

    # check required variables
    raise 'Please enter all required parameters' if settings.client_id.empty? or settings.private_key.empty? or settings.fileId.empty? or settings.email.empty? or settings.first_name.empty? or settings.last_name.empty?

    # create new user
    user = GroupDocs::User.new
    user.primary_email = settings.email
    user.nickname = settings.first_name
    user.first_name = settings.first_name
    user.last_name = settings.last_name

    # update account
    GroupDocs::User.update_account!(user, {client_id: settings.client_id, private_key: settings.private_key})

    # create file from GUID
    file = GroupDocs::Storage::File.new(guid: settings.fileId)

    # create document from file
    document = GroupDocs::Document.new(file: file)

    # set new collaboration
    document.set_collaborators!([settings.email], 2, {:client_id => settings.client_id, :private_key => settings.private_key})

    # get all collaborations
    collaborations = document.collaborators!({:client_id => settings.client_id, :private_key => settings.private_key})

    # set document reviewers
    document.set_reviewers!(collaborations, {:client_id => settings.client_id, :private_key => settings.private_key})

  rescue Exception => e
    err = e.message
  end

  # set variables for template
  haml :sample22, :locals => {:userId => settings.client_id, :privateKey => settings.private_key, :fileId => settings.fileId, :email => settings.email, :first_name => settings.first_name, :last_name => settings.last_name, :err => err}
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
groupdocs-1.5.7 examples/api-samples/samples/sample22.rb
groupdocs-1.5.6 examples/api-samples/samples/sample22.rb
groupdocs-1.5.5 examples/api-samples/samples/sample22.rb
groupdocs-1.5.4 examples/api-samples/samples/sample22.rb
groupdocs-1.5.3 examples/api-samples/samples/sample22.rb
groupdocs-1.5.2 examples/api-samples/samples/sample22.rb
groupdocs-1.5.1 examples/api-samples/samples/sample22.rb