# frozen_string_literal: true require 'time' require 'credit_gateway/base_model' require 'credit_gateway/rating' module CreditGateway class BehavioralScore < BaseModel attributes :frequency, :calculated, :main_rating, :component_ratings def self.build(json:) super.tap do |record| record.calculated = Time.parse(record.calculated) if record.calculated record.main_rating = Rating.build(json: (record.main_rating || {})) record.component_ratings = (record.component_ratings || []).map do |rating| Rating.build(json: rating) end end end end end