class CPApiRequestPagesRemove

ページ削除リクエスト用クラス(API利用不可) @ref github.com/crowi/crowi/blob/master/lib/routes/page.js

Public Class Methods

new(param = {}) click to toggle source

コンストラクタ @override @param [Hash] param APIリクエストのパラメータ

Calls superclass method CPApiRequestBase::new
# File lib/crowi/client/apireq/api_request_pages.rb, line 385
def initialize(param = {})
  raise Exception, 'API of pages.remove is forbidden'
  super('/_api/pages.remove', METHOD_GET,
        { page_id: param[:page_id], revision_id: param[:revision_id] })
end

Public Instance Methods

execute(entry_point, rest_client_param: {}) click to toggle source

リクエストを実行する @override @param [String] entry_point APIのエントリーポイントとなるURL(ex. localhost:3000/_api/pages.list) @param [Hash] rest_client_param RestClientのパラメータ @return [Array] リクエスト実行結果

# File lib/crowi/client/apireq/api_request_pages.rb, line 396
def execute(entry_point, rest_client_param: {})

  if invalid?
    return validation_msg
  end
  param = { method: :get, url: entry_point, headers: { params: @param } }.merge(rest_client_param)
  ret = JSON.parse RestClient::Request.execute param
  if (ret['ok'] == false)
    return CPInvalidRequest.new "API return false with msg: #{ret['msg']}"
  end
  return CPApiReturn.new(ok: ret['ok'], data: CrowiPage.new(ret['page']))
end

Protected Instance Methods

_invalid() click to toggle source

バリデーションエラーを取得する @override @return [nil/CPInvalidRequest] バリデーションエラー結果

# File lib/crowi/client/apireq/api_request_pages.rb, line 414
def _invalid
  if ! (@param[:page_id] || @param[:revision_id]) 
    return CPInvalidRequest.new 'Parameter page_id or revision_id is required.'
  end
end