Class: GApiRequestLikesRemove
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestLikesRemove
- 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 = {}) ⇒ GApiRequestLikesRemove
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestLikesRemove
コンストラクタ
376 377 378 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 376 def initialize(param = {}) super('/_api/likes.remove', METHOD_POST, { page_id: param[:page_id] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/growi/client/apireq/api_request_pages.rb', line 385 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 |