Class: GApiRequestPagesCreate
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestPagesCreate
- 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 = {}) ⇒ GApiRequestPagesCreate
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestPagesCreate
コンストラクタ
138 139 140 141 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 138 def initialize(param = {}) super('/_api/pages.create', METHOD_POST, { body: param[:body], path: param[:path], grant: param[:grant] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 148 def execute(entry_point, rest_client_param: {}) if invalid? return validation_msg end params = { method: :post, url: entry_point, payload: @param.to_json, headers: { content_type: :json, accept: :json } }.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 |