Class: CPApiRequestPagesUpdatePost

Inherits:
CPApiRequestBase show all
Defined in:
lib/crowi/client/apireq/api_request_pages.rb

Overview

Note:

notification for 3rd party tool (like Slack)

更新ページ一覧リクエスト用クラス

Constant Summary

Constants inherited from CPApiRequestBase

CPApiRequestBase::METHOD_GET, CPApiRequestBase::METHOD_POST

Instance Attribute Summary

Attributes inherited from CPApiRequestBase

#entry_point, #method, #param

Instance Method Summary collapse

Methods inherited from CPApiRequestBase

#invalid?, #valid?, #validation_msg

Constructor Details

#initialize(param = {}) ⇒ CPApiRequestPagesUpdatePost

コンストラクタ

Parameters:

  • param (Hash) (defaults to: {})

    APIリクエストのパラメータ



311
312
313
# File 'lib/crowi/client/apireq/api_request_pages.rb', line 311

def initialize(param = {})
  super('/_api/pages.updatePost', METHOD_GET, { path: param[:path] })
end

Instance Method Details

#execute(entry_point) ⇒ CrowiPage

リクエストを実行する

Parameters:

Returns:

  • (CrowiPage)

    リクエスト実行結果



319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/crowi/client/apireq/api_request_pages.rb', line 319

def execute(entry_point)

  if invalid?
    return validation_msg
  end
  ret = JSON.parse RestClient.get entry_point, params: @param
  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