Class: Minfraud::InsightsClient
- Inherits:
-
Object
- Object
- Minfraud::InsightsClient
- Defined in:
- app/services/minfraud/insights_client.rb
Overview
Direct Faraday client for the MaxMind minFraud Insights endpoint.
Replaces the minfraud gem, which was dropped so the bundle could move off
the gem's connection_pool < 3 and http < 6.0 version ceilings (it
transitively pinned maxmind-geoip2, which is unused elsewhere — geocoder's
:maxmind_geoip2 IP lookup is geocoder-native, not this gem). We only ever
called the Insights endpoint; the request and response shapes here match
exactly what the gem sent and parsed.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- HOST =
'https://minfraud.maxmind.com'- PATH =
'/minfraud/v2.0/insights'- BOOLEAN_KEYS =
Request fields the API expects as JSON booleans. The gem stringified every
other scalar; we mirror that so the wire format is unchanged. %w[was_authorized is_gift has_gift_message].freeze
Instance Method Summary collapse
-
#initialize(account_id:, license_key:) ⇒ InsightsClient
constructor
A new instance of InsightsClient.
-
#insights(request) ⇒ Hash
Perform a minFraud Insights request.
Constructor Details
#initialize(account_id:, license_key:) ⇒ InsightsClient
Returns a new instance of InsightsClient.
29 30 31 32 |
# File 'app/services/minfraud/insights_client.rb', line 29 def initialize(account_id:, license_key:) @account_id = account_id @license_key = license_key end |
Instance Method Details
#insights(request) ⇒ Hash
Perform a minFraud Insights request.
40 41 42 43 44 45 46 47 |
# File 'app/services/minfraud/insights_client.rb', line 40 def insights(request) response = connection.post(PATH, serialize(request)) return response.body if response.success? raise Error, (response) rescue Faraday::Error => e raise Error, e. end |