28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/one_time_secret.rb', line 28
def fetch_secret(secret_key, passphrase: nil)
secret_params = {
passphrase: passphrase
}
conn = Faraday.new(
url: api_url("/secret/#{secret_key}"),
params: secret_params,
headers:
)
resp = conn.post
unless resp.success?
raise "OneTimeSecret fetch_secret request failed with status #{resp.status}#{' (it\'s possible that the secret has already been consumed)' if resp.status == 404}, and body `#{resp.body}`"
end
JSON.parse(resp.body)
end
|