Class: Inttegro::Resources::Files
- Inherits:
-
Object
- Object
- Inttegro::Resources::Files
- Defined in:
- lib/inttegro/resources/files.rb
Overview
Client for uploading, listing, downloading, and deleting application-owned files.
Access this resource through Client#files.
Instance Method Summary collapse
-
#contents(file_id:, disposition: "attachment") ⇒ Inttegro::FileDownload
Retrieve the original bytes for a file.
-
#create(file:, purpose:, title: nil, custom_data: nil, idempotency_key: nil) ⇒ Inttegro::File
Upload a file using multipart form data.
-
#delete(file_id:) ⇒ Inttegro::File
Tombstone a file and request backing-object cleanup under the API's reference policy.
-
#initialize(http) ⇒ Files
constructor
A new instance of Files.
-
#lookup(file_id:) ⇒ Inttegro::File
Retrieve metadata for one file.
-
#page(payload = {}) ⇒ Inttegro::File::Page
Retrieve a filtered page of files.
Constructor Details
#initialize(http) ⇒ Files
Returns a new instance of Files.
11 12 13 |
# File 'lib/inttegro/resources/files.rb', line 11 def initialize(http) @http = T.let(http, Inttegro::HTTPClient) end |
Instance Method Details
#contents(file_id:, disposition: "attachment") ⇒ Inttegro::FileDownload
Retrieve the original bytes for a file.
53 54 55 |
# File 'lib/inttegro/resources/files.rb', line 53 def contents(file_id:, disposition: "attachment") @http.post_binary_json("/files/contents", { file_id: file_id, disposition: disposition }) end |
#create(file:, purpose:, title: nil, custom_data: nil, idempotency_key: nil) ⇒ Inttegro::File
Upload a file using multipart form data.
23 24 25 26 27 28 29 30 |
# File 'lib/inttegro/resources/files.rb', line 23 def create(file:, purpose:, title: nil, custom_data: nil, idempotency_key: nil) headers = idempotency_key ? { "Idempotency-Key" => idempotency_key } : {} @http.post_multipart_resource("/files/create", Inttegro::File, :file, fields: { purpose: purpose, title: title, custom_data: custom_data }, files: { file: file }, headers: headers ) end |
#delete(file_id:) ⇒ Inttegro::File
Tombstone a file and request backing-object cleanup under the API's reference policy.
61 62 63 |
# File 'lib/inttegro/resources/files.rb', line 61 def delete(file_id:) @http.post_resource("/files/delete", Inttegro::File, :file, { file_id: file_id }) end |
#lookup(file_id:) ⇒ Inttegro::File
Retrieve metadata for one file.
36 37 38 |
# File 'lib/inttegro/resources/files.rb', line 36 def lookup(file_id:) @http.post_resource("/files/lookup", Inttegro::File, :file, { file_id: file_id }) end |
#page(payload = {}) ⇒ Inttegro::File::Page
Retrieve a filtered page of files.
44 45 46 |
# File 'lib/inttegro/resources/files.rb', line 44 def page(payload = {}) @http.post_resource("/files/page", Inttegro::File::Page, :page, payload || {}) end |