Class: GApiRequestAttachmentsAdd
- Inherits:
-
GApiRequestBase
- Object
- GApiRequestBase
- GApiRequestAttachmentsAdd
- Defined in:
- lib/growi/client/apireq/api_request_attachments.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 = {}) ⇒ GApiRequestAttachmentsAdd
constructor
コンストラクタ.
Methods inherited from GApiRequestBase
#invalid?, #valid?, #validation_msg
Constructor Details
#initialize(param = {}) ⇒ GApiRequestAttachmentsAdd
コンストラクタ
54 55 56 57 |
# File 'lib/growi/client/apireq/api_request_attachments.rb', line 54 def initialize(param = {}) super('/_api/attachments.add', METHOD_POST, { page_id: param[:page_id], file: param[:file] }) end |
Instance Method Details
#execute(entry_point, rest_client_param: {}) ⇒ Array
リクエストを実行する
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/growi/client/apireq/api_request_attachments.rb', line 64 def execute(entry_point, rest_client_param: {}) if invalid? return validation_msg end params = { method: :post, url: entry_point, payload: { access_token: @param[:access_token], page_id: @param[:page_id], file: @param[:file] } }.merge(rest_client_param) ret = JSON.parse RestClient::Request.execute params if (ret['ok'] == false) return GCInvalidRequest.new "API return false with msg: #{ret['msg']}" end data = { page: GrowiPage.new(ret['page']), attachment: GrowiAttachment.new(ret['attachment']) } return GApiReturn.new(ok: ret['ok'], data: data) end |