Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby SDK for docspad
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.md
docspad.rb

README.md

Ruby SDK for Docspad

How to use

Load docspad in your project

  • Add the doscpad.rb file to your project.
  • Load the file in your project as
load 'docspad.rb'

Create a DocspadClient object

  • This object is required to upload file(s). Replace YOUR_API_KEY with the API key and PATH_TO_FILE with the path to the file you want to upload.
client = DocspadClient.new(YOUR_API_KEY)

Uploading a document

doc = client.upload(PATH_TO_FILE)
  • To upload a document via a URL :
doc = client.upload(FILE_URL, true)

Operations on document

  • Status
status = doc.getStatus
  • Get a new session to access the document
session = doc.newSession
  • You could also get a URL based on a session
doc.getViewUrl(session)
  • Delete the document
doc.delete
  • Delete only a session
doc.deleteSession(session)

Complete example

  • Here's a simple example of a general workflow. Uploading a document, checking its conversion status, getting a session to view the document and deleting the session.
load 'docspad.rb'

begin
    client = DocspadClient.new(YOUR_API_KEY)
    doc = client.upload(PATH_TO_FILE)
    begin 
        status = doc.getStatus 
        puts status
        sleep (1)
    end until status.conversionStatus == DocspadDocument::ConversionStatus::COMPLETED

    session = doc.newSession
    puts doc.getViewUrl(session)
    doc.deleteSession(session)
    doc.delete
rescue DocspadError => error
    puts error
end
Something went wrong with that request. Please try again.