Class: UnFichierApi::Base
Class Method Summary
collapse
Class Method Details
.call(path:, method: :post, body: {}, headers: {}) ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/un_fichier_api/base.rb', line 16
def call(path:, method: :post, body: {}, headers: {})
connection..merge!
response = connection.send(method, path) do |req|
req.body = body.to_json
end
JSON.parse response.body
end
|
.connection ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/un_fichier_api/base.rb', line 26
def connection
@connection ||= Faraday.new(
url: 'https://api.1fichier.com/v1',
headers: { 'Content-Type' => 'application/json', 'Authorization' => "Bearer #{api_key}" },
request: { timeout: 120 }
)
end
|