Class: GApiRequestPagesGet
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestPagesGet
- Defined in:
- lib/growi/client/apireq/api_request_pages.rb
Overview
ページ取得リクエスト用クラス
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 = {}) ⇒ GApiRequestPagesGet
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestPagesGet
コンストラクタ
81 82 83 84 85 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 81 def initialize(param = {}) super('/_api/pages.get', METHOD_GET, { page_id: param[:page_id], path: param[:path], revision_id: param[:revision_id] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 92 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 return GApiReturn.new(ok: ret['ok'], data: GrowiPage.new(ret['page'])) end |