Class: Crocodoc::Session
- Inherits:
-
Object
- Object
- Crocodoc::Session
- Defined in:
- lib/crocodoc/session.rb
Overview
Provides access to the Crocodoc Session API. The Session API is used to to create sessions for specific documents that can be used to view a document using a specific session-based URL.
Constant Summary collapse
- @@path =
The Session API path relative to the base API path
'/session/'
Class Method Summary collapse
-
.create(uuid, params = {}) ⇒ String
Create a session for a specific document by UUID that is optionally editable and can use user ID and name info from your application, can filter annotations, can grant admin permissions, can be downloadable, can be copy-protected, and can prevent changes from being persisted.
-
.path ⇒ Object
Get the path.
-
.path=(path) ⇒ Object
Set the path.
Class Method Details
.create(uuid, params = {}) ⇒ String
Create a session for a specific document by UUID that is optionally editable and can use user ID and name info from your application, can filter annotations, can grant admin permissions, can be downloadable, can be copy-protected, and can prevent changes from being persisted.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/crocodoc/session.rb', line 45 def self.create(uuid, params = {}) post_params = {uuid: uuid} if params.has_key? 'is_editable' post_params['editable'] = params['is_editable'] ? 'true' : 'false' end if ( params.has_key? 'user' \ and params['user'] \ and params['user'].is_a? Hash \ and params['user'].has_key? 'id' \ and params['user'].has_key? 'name' \ ) post_params['user'] = String(params['user']['id']) + ',' + params['user']['name'] end if params.has_key? 'filter' if params['filter'].is_a? Array params['filter'] = params['filter'].join(',') end post_params['filter'] = params['filter'] end if params.has_key? 'is_admin' post_params['admin'] = params['is_admin'] ? 'true' : 'false' end if params.has_key? 'is_downloadable' post_params['downloadable'] = params['is_downloadable'] ? 'true' : 'false' end if params.has_key? 'is_copyprotected' post_params['copyprotected'] = params['is_copyprotected'] ? 'true' : 'false' end if params.has_key? 'is_demo' post_params['demo'] = params['is_demo'] ? 'true' : 'false' end post_params['sidebar'] = params['sidebar'] if params.has_key? 'sidebar' session = Crocodoc._request(self.path, 'create', nil, post_params) unless session.is_a? Hash and session.has_key? 'session' return Crocodoc._error('missing_session_key', self.name, __method__, session) end session['session'] end |
.path ⇒ Object
Get the path
15 16 17 |
# File 'lib/crocodoc/session.rb', line 15 def self.path @@path end |
.path=(path) ⇒ Object
Set the path
10 11 12 |
# File 'lib/crocodoc/session.rb', line 10 def self.path=(path) @@path = path end |