Class: Inttegro::Resources::Files
- Inherits:
-
Object
- Object
- Inttegro::Resources::Files
- Defined in:
- lib/inttegro/resources/files.rb
Instance Method Summary collapse
- #contents(file_id:, disposition: "attachment") ⇒ Object
- #create(file:, purpose:, title: nil, custom_data: nil, idempotency_key: nil) ⇒ Object
- #delete(file_id:) ⇒ Object
-
#initialize(http) ⇒ Files
constructor
A new instance of Files.
- #lookup(file_id:) ⇒ Object
- #page(payload = {}) ⇒ Object
Constructor Details
#initialize(http) ⇒ Files
Returns a new instance of Files.
7 8 9 |
# File 'lib/inttegro/resources/files.rb', line 7 def initialize(http) @http = T.let(http, Inttegro::HTTPClient) end |
Instance Method Details
#contents(file_id:, disposition: "attachment") ⇒ Object
28 29 30 |
# File 'lib/inttegro/resources/files.rb', line 28 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) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/inttegro/resources/files.rb', line 11 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:) ⇒ Object
32 33 34 |
# File 'lib/inttegro/resources/files.rb', line 32 def delete(file_id:) @http.post_resource("/files/delete", Inttegro::File, :file, { file_id: file_id }) end |