Class: ModernTreasury::DocumentController
- Inherits:
-
BaseController
- Object
- BaseController
- ModernTreasury::DocumentController
- Defined in:
- lib/modern_treasury/controllers/document_controller.rb
Overview
DocumentController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#create_document(documentable_id, documentable_type, file, idempotency_key: nil, document_type: nil) ⇒ Document
Create a document.
-
#create_document1(documentable_id, documentable_type, file, idempotency_key: nil, document_type: nil) ⇒ Document
Create a document.
-
#download_document(documentable_id, documentable_type, id) ⇒ void
Download an existing document.
-
#download_document1(id) ⇒ void
Download an existing document.
-
#get_document(documentable_id, documentable_type, id) ⇒ Document
Get an existing document.
-
#get_document1(id) ⇒ Document
Get an existing document.
-
#list_documents(documentable_id: nil, documentable_type: nil, per_page: nil, after_cursor: nil) ⇒ Array[Document]
Get a list of documents.
-
#list_documents1(documentable_id, documentable_type, document_type: nil, after_cursor: nil, per_page: nil) ⇒ Array[Document]
Get a list of documents.
Methods inherited from BaseController
#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent
Constructor Details
This class inherits a constructor from ModernTreasury::BaseController
Instance Method Details
#create_document(documentable_id, documentable_type, file, idempotency_key: nil, document_type: nil) ⇒ Document
Create a document. for the associated object. type description here here something unique, preferably something like an UUID. document, can be ‘null`.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 58 def create_document(documentable_id, documentable_type, file, idempotency_key: nil, document_type: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/documents', Server::DEFAULT) .form_param(new_parameter(documentable_id, key: 'documentable_id')) .form_param(new_parameter(documentable_type, key: 'documentable_type')) .multipart_param(new_parameter(file, key: 'file') .default_content_type('application/octet-stream')) .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key')) .form_param(new_parameter(document_type, key: 'document_type')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic_auth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Document.method(:from_hash)) .local_error('403', 'forbidden', ErrorMessageException) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#create_document1(documentable_id, documentable_type, file, idempotency_key: nil, document_type: nil) ⇒ Document
Create a document. for the associated object. type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`. here something unique, preferably something like an UUID. document, can be `null`.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 142 def create_document1(documentable_id, documentable_type, file, idempotency_key: nil, document_type: nil) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/api/{documentable_type}/{documentable_id}/documents', Server::DEFAULT) .template_param(new_parameter(documentable_id, key: 'documentable_id') .should_encode(true)) .template_param(new_parameter(documentable_type, key: 'documentable_type') .should_encode(true)) .multipart_param(new_parameter(file, key: 'file') .default_content_type('application/octet-stream')) .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key')) .form_param(new_parameter(document_type, key: 'document_type')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic_auth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Document.method(:from_hash)) .local_error('403', 'forbidden', ErrorMessageException) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#download_document(documentable_id, documentable_type, id) ⇒ void
This method returns an undefined value.
Download an existing document. for the associated object. type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`.
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 238 def download_document(documentable_id, documentable_type, id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/{documentable_type}/{documentable_id}/documents/{id}/download', Server::DEFAULT) .template_param(new_parameter(documentable_id, key: 'documentable_id') .should_encode(true)) .template_param(new_parameter(documentable_type, key: 'documentable_type') .should_encode(true)) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .auth(Single.new('basic_auth'))) .response(new_response_handler .is_response_void(true) .local_error('403', 'forbidden', ErrorMessageException) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#download_document1(id) ⇒ void
This method returns an undefined value.
Download an existing document.
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 266 def download_document1(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/documents/{id}/download', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .auth(Single.new('basic_auth'))) .response(new_response_handler .is_response_void(true) .local_error('403', 'forbidden', ErrorMessageException) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#get_document(documentable_id, documentable_type, id) ⇒ Document
Get an existing document. for the associated object. type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 183 def get_document(documentable_id, documentable_type, id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/{documentable_type}/{documentable_id}/documents/{id}', Server::DEFAULT) .template_param(new_parameter(documentable_id, key: 'documentable_id') .should_encode(true)) .template_param(new_parameter(documentable_type, key: 'documentable_type') .should_encode(true)) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic_auth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Document.method(:from_hash)) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#get_document1(id) ⇒ Document
Get an existing document.
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 210 def get_document1(id) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/documents/{id}', Server::DEFAULT) .template_param(new_parameter(id, key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic_auth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Document.method(:from_hash)) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#list_documents(documentable_id: nil, documentable_type: nil, per_page: nil, after_cursor: nil) ⇒ Array[Document]
Get a list of documents. for the associated object. type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`. here here
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 22 def list_documents(documentable_id: nil, documentable_type: nil, per_page: nil, after_cursor: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/documents', Server::DEFAULT) .query_param(new_parameter(documentable_id, key: 'documentable_id')) .query_param(new_parameter(documentable_type, key: 'documentable_type')) .query_param(new_parameter(per_page, key: 'per_page')) .query_param(new_parameter(after_cursor, key: 'after_cursor')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic_auth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Document.method(:from_hash)) .is_response_array(true) .local_error('404', 'not found', ErrorMessageException)) .execute end |
#list_documents1(documentable_id, documentable_type, document_type: nil, after_cursor: nil, per_page: nil) ⇒ Array[Document]
Get a list of documents. for the associated object. type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`. document, can be `null`. here here
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/modern_treasury/controllers/document_controller.rb', line 102 def list_documents1(documentable_id, documentable_type, document_type: nil, after_cursor: nil, per_page: nil) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/api/{documentable_type}/{documentable_id}/documents', Server::DEFAULT) .template_param(new_parameter(documentable_id, key: 'documentable_id') .should_encode(true)) .template_param(new_parameter(documentable_type, key: 'documentable_type') .should_encode(true)) .query_param(new_parameter(document_type, key: 'document_type')) .query_param(new_parameter(after_cursor, key: 'after_cursor')) .query_param(new_parameter(per_page, key: 'per_page')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('basic_auth'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Document.method(:from_hash)) .is_response_array(true)) .execute end |