Class: CPApiRequestPagesCreate
- Inherits:
-
CPApiRequestBase
- Object
- CPApiRequestBase
- CPApiRequestPagesCreate
- Defined in:
- lib/crowi/client/apireq/api_request_pages.rb
Overview
ページ作成リクエスト用クラス
Constant Summary
Constants inherited from CPApiRequestBase
CPApiRequestBase::METHOD_GET, CPApiRequestBase::METHOD_POST
Instance Attribute Summary
Attributes inherited from CPApiRequestBase
Instance Method Summary collapse
-
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する.
-
#initialize(param = {}) ⇒ CPApiRequestPagesCreate
constructor
コンストラクタ.
Methods inherited from CPApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ CPApiRequestPagesCreate
コンストラクタ
108 109 110 111 |
# File 'lib/crowi/client/apireq/api_request_pages.rb', line 108 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
リクエストを実行する
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/crowi/client/apireq/api_request_pages.rb', line 118 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) ret = JSON.parse RestClient::Request.execute params if (ret['ok'] == false) return CPInvalidRequest.new "API return false with msg: #{ret['msg']}" end return CPApiReturn.new(ok: ret['ok'], data: CrowiPage.new(ret['page'])) end |