# frozen_string_literal: true require 'creditsafe/base_model' require 'creditsafe/models/company_summary' require 'creditsafe/models/company_identification' require 'creditsafe/models/credit_score' require 'creditsafe/models/contact_information' module Creditsafe module Models class Report < BaseModel attributes :company_id, :language, :company_summary, :company_identification, :credit_score, :contact_information, :share_capital_structure, :directors, :directorships, :financial_statements, :local_financial_statements, :payment_data, :payment_data_extra, :negative_information, :additional_information, :other_information def self.build(json:) super.tap do |record| record.company_summary = CompanySummary.build(json: json.fetch(:companySummary, {})) record.company_identification = CompanyIdentification.build( json: json.fetch(:companyIdentification, {}) ) record.credit_score = CreditScore.build(json: json.fetch(:creditScore, {})) record.contact_information = ContactInformation.build(json: json.fetch(:contactInformation, {})) end end end end end