# frozen_string_literal: true require 'creditsafe/base_model' require 'creditsafe/models/credit_rating' require 'creditsafe/models/currency_value' module Creditsafe module Models class CreditScore < BaseModel attributes :current_credit_rating, :current_contract_limit, :previous_credit_rating, :latest_rating_change_date def self.build(json:) super.tap do |record| record.current_credit_rating = CreditRating.build(json: json.fetch(:currentCreditRating, {})) record.current_contract_limit = CurrencyValue.build(json: json.fetch(:currentContractLimit, {})) record.previous_credit_rating = CreditRating.build(json: json.fetch(:previousCreditRating, {})) end end end end end