Skip to content

Instantly share code, notes, and snippets.

@julianalucena
Forked from nataliaconde/api.rb
Last active Jun 26, 2021
Embed
What would you like to do?
require 'faraday'
require 'json'
module Incognia
class Api
include Singleton
API_HOST = 'https://api.us.incognia.com/api/'.freeze
def register_login(installation_id:, account_id:)
transactions_endpoint = 'v2/authentication/transactions'
params = {
installation_id: installation_id,
account_id: account_id,
type: 'login'
}
response = Faraday.post(
"#{API_HOST}#{transactions_endpoint}",
params.to_json,
headers
)
if response.status == 200
parsed_body = JSON.parse(response.body)
parsed_body['risk_assessment']
else
# Error handling
end
end
private
def headers
{
'Content-Type': 'application/json',
# Read more about how to generate a fresh token at our
# Authenticating in Incognia APIs section.
Authorization: "Bearer #{fresh_token}"
}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment