Class: Mihari::Services::GeolocationBuilder

Inherits:
Mihari::Service show all
Defined in:
lib/mihari/services/builders.rb

Overview

Geolocation builder

Instance Method Summary collapse

Methods inherited from Mihari::Service

call, #result, result

Instance Method Details

#call(ip, enricher: Enrichers::MMDB.new) ⇒ Mihari::Models::Geolocation?

Build Geolocation

Parameters:

Returns:



91
92
93
94
95
96
97
98
99
100
# File 'lib/mihari/services/builders.rb', line 91

def call(ip, enricher: Enrichers::MMDB.new)
  enricher.result(ip).fmap do |res|
    if res.country_code
      Models::Geolocation.new(
        country: NormalizeCountry(res.country_code, to: :short),
        country_code: res.country_code
      )
    end
  end.value_or nil
end