Class: GApiRequestPagesUpdatePost
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestPagesUpdatePost
- Defined in:
- lib/growi/client/apireq/api_request_pages.rb
Overview
Note:
notification for 3rd party tool (like Slack)
更新ページ一覧リクエスト用クラス
Constant Summary
Constants inherited from GApiRequestBase
GApiRequestBase::METHOD_GET, GApiRequestBase::METHOD_POST
Instance Attribute Summary
Attributes inherited from GApiRequestBase
Instance Method Summary collapse
-
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する.
-
#initialize(param = {}) ⇒ GApiRequestPagesUpdatePost
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestPagesUpdatePost
コンストラクタ
433 434 435 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 433 def initialize(param = {}) super('/_api/pages.updatePost', METHOD_GET, { path: param[:path] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 442 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) GCLogger.logger.debug('Request: ' + params.to_s) begin raw_ret = RestClient::Request.execute params GCLogger.logger.debug('Return: ' + raw_ret.to_s) ret = JSON.parse raw_ret rescue Exception => e GCLogger.logger.error(e) return GCInvalidRequest.new "Unknown error occured: #{e}" end if (!ret['ok'].nil? && ret['ok'] == false) return GCInvalidRequest.new "API return false with msg: #{ret['msg']}" end begin posts = [] ret['updatePost'].each do |post| pages.push(GrowiPage.new(post)) end return GApiReturn.new(ok: ret['ok'], data: posts) rescue Exception => e GCLogger.logger.error(e) return GCInvalidRequest.new "Fail to parse: #{e}" end end |