Class: Inttegro::Resources::FileLinks

Inherits:
Object
  • Object
show all
Defined in:
lib/inttegro/resources/file_links.rb

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ FileLinks

Returns a new instance of FileLinks.



7
8
9
# File 'lib/inttegro/resources/file_links.rb', line 7

def initialize(http)
  @http = T.let(http, Inttegro::HTTPClient)
end

Instance Method Details

#create(payload, idempotency_key: nil) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/inttegro/resources/file_links.rb', line 11

def create(payload, idempotency_key: nil)
  @http.post_model(
    "/file_links/create",
    Inttegro::FileLinkCreation,
    payload,
    headers: headers(idempotency_key)
  )
end

#lookup(id:) ⇒ Object



20
21
22
# File 'lib/inttegro/resources/file_links.rb', line 20

def lookup(id:)
  @http.post_resource("/file_links/lookup", Inttegro::FileLink, :file_link, { id: id })
end

#open(url, save_to: nil) ⇒ Object



35
36
37
38
39
# File 'lib/inttegro/resources/file_links.rb', line 35

def open(url, save_to: nil)
  download = @http.get_binary_public(url)
  download.save_to(save_to) if save_to
  download
end

#page(payload = {}) ⇒ Object



24
25
26
# File 'lib/inttegro/resources/file_links.rb', line 24

def page(payload = {})
  @http.post_resource("/file_links/page", Inttegro::FileLinkPage, :page, payload || {})
end

#revoke(payload, idempotency_key: nil) ⇒ Object



28
29
30
31
32
33
# File 'lib/inttegro/resources/file_links.rb', line 28

def revoke(payload, idempotency_key: nil)
  @http.post_resource("/file_links/revoke", Inttegro::FileLink, :file_link,
    payload,
    headers: headers(idempotency_key)
  )
end