class CPApiRequestPagesUpdatePost

更新ページ一覧リクエスト用クラス @ref github.com/crowi/crowi/blob/master/lib/routes/page.js @note notification for 3rd party tool (like Slack)

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 339
def initialize(param = {})
  super('/_api/pages.updatePost', METHOD_GET, { path: param[:path] })
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 348
def execute(entry_point, rest_client_param: {})

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

Protected Instance Methods

_invalid() click to toggle source

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

# File lib/crowi/client/apireq/api_request_pages.rb, line 370
def _invalid
  if ! (@param[:path]) 
    return CPInvalidRequest.new 'Parameter path required.'
  end
end