Class: Inttegro::Resources::FileLinks
- Inherits:
-
Object
- Object
- Inttegro::Resources::FileLinks
- Defined in:
- lib/inttegro/resources/file_links.rb
Overview
Client for revocable public capability URLs that deliver Inttegro files.
Access this resource through Client#file_links.
Instance Method Summary collapse
-
#create(payload, idempotency_key: nil) ⇒ Inttegro::FileLink::Creation
Create a public file link.
-
#initialize(http) ⇒ FileLinks
constructor
A new instance of FileLinks.
-
#lookup(id:) ⇒ Inttegro::FileLink
Retrieve a file link without exposing its token material.
-
#open(url, save_to: nil) ⇒ Inttegro::FileDownload
Download the bytes exposed by a public file-link URL.
-
#page(payload = {}) ⇒ Inttegro::FileLink::Page
Retrieve a filtered page of file links.
-
#revoke(payload, idempotency_key: nil) ⇒ Inttegro::FileLink
Revoke a file link so its capability URL can no longer serve the file.
Constructor Details
#initialize(http) ⇒ FileLinks
Returns a new instance of FileLinks.
11 12 13 |
# File 'lib/inttegro/resources/file_links.rb', line 11 def initialize(http) @http = T.let(http, Inttegro::HTTPClient) end |
Instance Method Details
#create(payload, idempotency_key: nil) ⇒ Inttegro::FileLink::Creation
Create a public file link.
20 21 22 23 24 25 26 27 |
# File 'lib/inttegro/resources/file_links.rb', line 20 def create(payload, idempotency_key: nil) @http.post_model( "/file_links/create", Inttegro::FileLink::Creation, payload, headers: headers(idempotency_key) ) end |
#lookup(id:) ⇒ Inttegro::FileLink
Retrieve a file link without exposing its token material.
33 34 35 |
# File 'lib/inttegro/resources/file_links.rb', line 33 def lookup(id:) @http.post_resource("/file_links/lookup", Inttegro::FileLink, :file_link, { id: id }) end |
#open(url, save_to: nil) ⇒ Inttegro::FileDownload
Download the bytes exposed by a public file-link URL.
This public capability request does not use the client's API key. When save_to is
supplied, the response is also written to that path before being returned.
65 66 67 68 69 |
# File 'lib/inttegro/resources/file_links.rb', line 65 def open(url, save_to: nil) download = @http.get_binary_public(url) download.save_to(save_to) if save_to download end |
#page(payload = {}) ⇒ Inttegro::FileLink::Page
Retrieve a filtered page of file links.
41 42 43 |
# File 'lib/inttegro/resources/file_links.rb', line 41 def page(payload = {}) @http.post_resource("/file_links/page", Inttegro::FileLink::Page, :page, payload || {}) end |
#revoke(payload, idempotency_key: nil) ⇒ Inttegro::FileLink
Revoke a file link so its capability URL can no longer serve the file.
50 51 52 53 54 55 |
# File 'lib/inttegro/resources/file_links.rb', line 50 def revoke(payload, idempotency_key: nil) @http.post_resource("/file_links/revoke", Inttegro::FileLink, :file_link, payload, headers: headers(idempotency_key) ) end |