Class: GApiRequestPagesList
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestPagesList
- 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
リクエストを実行する [TODO] pagination に対応する.
-
#initialize(param = {}) ⇒ GApiRequestPagesList
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestPagesList
コンストラクタ
12 13 14 15 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 12 def initialize(param = {}) super('/_api/pages.list', METHOD_GET, { path: param[:path_exp], user: param[:user] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
- TODO
-
pagination に対応する
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 23 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 pages = [] ret['pages'].each do |page| pages.push(GrowiPage.new(page)) end return GApiReturn.new(ok: ret['ok'], data: pages) rescue Exception => e GCLogger.logger.error(e) return GCInvalidRequest.new "Fail to parse: #{e}" end end |