Class: GApiRequestLikesAdd
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestLikesAdd
- 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 = {}) ⇒ GApiRequestLikesAdd
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestLikesAdd
コンストラクタ
319 320 321 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 319 def initialize(param = {}) super('/_api/likes.add', METHOD_POST, { page_id: param[:page_id] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 328 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 |