module Crowi::ApiMethods

Public Instance Methods

add_attachment(page_id, filename, content_type) click to toggle source
# File lib/crowi/api_methods.rb, line 32
def add_attachment(page_id, filename, content_type)
  # To use multipart/form-data use faraday directly
  connection = Faraday.new(faraday_options) do |connection|
    connection.request :multipart
    connection.request :url_encoded
    connection.adapter :net_http
  end

  params = { page_id: page_id, file: Faraday::UploadIO.new(filename, content_type), access_token: @access_token }
  Crowi::Response.new(connection.send(:post, '/_api/attachments.add', params))
end
add_comment(page_id, comment, revision_id) click to toggle source
# File lib/crowi/api_methods.rb, line 24
def add_comment(page_id, comment, revision_id)
  post('/_api/comments.add', { commentForm: {  page_id: page_id, comment: comment, revision_id: revision_id } })
end
attachments(page_id) click to toggle source
# File lib/crowi/api_methods.rb, line 28
def attachments(page_id)
  get('/_api/attachments.list', { page_id: page_id })
end
comments(page_id) click to toggle source
# File lib/crowi/api_methods.rb, line 20
def comments(page_id)
  get('/_api/comments.get', { page_id: page_id })
end
create_page(path, body) click to toggle source
# File lib/crowi/api_methods.rb, line 12
def create_page(path, body)
  post('/_api/pages.create', { path: path, body: body })
end
page(path) click to toggle source
# File lib/crowi/api_methods.rb, line 3
def page(path)
  get('/_api/pages.get', { path: path })
end
pages(path = nil, user = nil, offset = 0) click to toggle source
# File lib/crowi/api_methods.rb, line 7
def pages(path = nil, user = nil, offset = 0)
  raise 'path or user is required' unless path || user
  get('/_api/pages.list', { path: path, user: user, offset: offset })
end
update_page(page_id, body) click to toggle source
# File lib/crowi/api_methods.rb, line 16
def update_page(page_id, body)
  post('/_api/pages.update', { page_id: page_id, body: body })
end