Class: GApiRequestPagesRemove

Inherits:
GApiRequestBase show all
Defined in:
lib/growi/client/apireq/api_request_pages.rb

Overview

ページ削除リクエスト用クラス(API利用不可)

Constant Summary

Constants inherited from GApiRequestBase

GApiRequestBase::METHOD_GET, GApiRequestBase::METHOD_POST

Instance Attribute Summary

Attributes inherited from GApiRequestBase

#entry_point, #method, #param

Instance Method Summary collapse

Methods inherited from GApiRequestBase

#invalid?, #valid?, #validation_msg

Constructor Details

#initialize(param = {}) ⇒ GApiRequestPagesRemove

コンストラクタ

Parameters:

  • param (Hash) (defaults to: {})

    APIリクエストのパラメータ

Raises:

  • (Exception)


495
496
497
498
499
# File 'lib/growi/client/apireq/api_request_pages.rb', line 495

def initialize(param = {})
  raise Exception, 'API of pages.remove is forbidden'
  super('/_api/pages.remove', METHOD_GET,
        { page_id: param[:page_id], revision_id: param[:revision_id] })
end

Instance Method Details

#execute(entry_point, rest_client_param: {}) ⇒ Array

リクエストを実行する

Parameters:

  • entry_point (String)

    APIのエントリーポイントとなるURL(ex. localhost:3000/_api/pages.list

  • rest_client_param (Hash) (defaults to: {})

    RestClientのパラメータ

Returns:

  • (Array)

    リクエスト実行結果



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/growi/client/apireq/api_request_pages.rb', line 506

def execute(entry_point, rest_client_param: {})

  if invalid?
    return validation_msg
  end

  param = { 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

  return GApiReturn.new(ok: ret['ok'], data: GrowiPage.new(ret['page']))
end