Class: GApiRequestPagesUpdate
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestPagesUpdate
- 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 = {}) ⇒ GApiRequestPagesUpdate
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestPagesUpdate
コンストラクタ
196 197 198 199 200 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 196 def initialize(param = {}) super('/_api/pages.update', METHOD_POST, { body: param[:body], page_id: param[:page_id], revision_id: param[:revision_id], grant: param[:grant] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 207 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 |