Sha256: abe563edec0b1e935eee545dcdc214c79549574b161514e290133a355bb9bf23

Contents?: true

Size: 616 Bytes

Versions: 2

Compression:

Stored size: 616 Bytes

Contents

# 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
credit_gateway-0.1.1 lib/credit_gateway/behavioral_score.rb
credit_gateway-0.1.0 lib/credit_gateway/behavioral_score.rb