class Kami::Document

Attributes

created_at[R]
document_identifier[R]
file_error_message[R]
file_status[R]
name[R]
session_view[R]

Public Class Methods

new(client: nil, id: nil, data: nil) click to toggle source
# File lib/kami/document.rb, line 6
def initialize(client: nil, id: nil, data: nil)
  @client = client
  @document_identifier = id
  @raw_data = data

  if data.is_a?(Hash)
    @name = data['name']
    @document_identifier = data['document_identifier']
    @file_status = data['file_status']
    @file_error_message = data['file_error_message']
    @created_at = data['created_at']
  end
end

Public Instance Methods

comments() click to toggle source
# File lib/kami/document.rb, line 48
def comments
  @client.get("documents/#{@document_identifier}/comments")
end
create_export(type: 'annotation') click to toggle source
# File lib/kami/document.rb, line 28
def create_export(type: 'annotation')
  payload = {
    document_identifier: @document_identifier,
    export_type: type
  }
  @export = @client.post('exports', payload)
end
delete() click to toggle source
# File lib/kami/document.rb, line 43
def delete
  @client.delete("documents/#{@document_identifier}")
  true
end
export_file(id = nil) click to toggle source
# File lib/kami/document.rb, line 36
def export_file(id = nil)
  export_id = id
  export_id ||= @export['id'] if @export.is_a?(Hash)

  @client.get("exports/#{export_id}")
end
session_view_url(name: 'Guest', user_id: 0, expires_at: nil, theme: 'light', show_sync: true, show_save: true) click to toggle source
# File lib/kami/document.rb, line 74
def session_view_url(name: 'Guest', user_id: 0, expires_at: nil, theme: 'light', show_sync: true, show_save: true)
  view = session_view(name: name, user_id: user_id, expires_at: expires_at, theme: theme, show_sync: show_sync, show_save: show_save)
  view['viewer_url']
end
status() click to toggle source
# File lib/kami/document.rb, line 24
def status
  @status ||= @client.get("documents/#{@document_identifier}")
end
to_hash() click to toggle source
# File lib/kami/document.rb, line 20
def to_hash
  @raw_data || status
end