class Hibp::Parsers::Breach
Used to convert raw API response data to the breach entity or array of the entities in case if response data contains multiple breaches
Public Instance Methods
parse_response(response)
click to toggle source
Convert raw data to the breach entity
@param response [Faraday::Response] -
Response that contains raw data for conversion
@see haveibeenpwned.com/API/v3 (The breach model, Sample breach response)
@return [Array<Hibp::Breach>, Hibp::Breach]
Calls superclass method
# File lib/hibp/parsers/breach.rb, line 21 def parse_response(response) super(response) do |attributes| Models::Breach.new(convert_dates!(attributes)) end end
Private Instance Methods
convert_dates!(attributes)
click to toggle source
# File lib/hibp/parsers/breach.rb, line 29 def convert_dates!(attributes) %i[modified_date breach_date added_date].each do |attr_key| next if attributes[attr_key].nil? type = attr_key == :breach_date ? Date : Time attributes[attr_key] = type.parse(attributes[attr_key]) end attributes end