Sha256: 5d88300accc4275efc4c79fb002164975def130596aceb51a63a49162e61e351

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'creditsafe/base_model'
require 'creditsafe/models/main_activity'
require 'creditsafe/models/company_status'
require 'creditsafe/models/currency_value'
require 'creditsafe/models/credit_rating'

module Creditsafe
  module Models
    class CompanySummary < BaseModel
      attributes :business_name, :country, :company_number, :company_registration_number,
                 :main_activity, :company_status, :lei_number,
                 :latest_shareholders_equity_figure, :latest_turnover_figure, :credit_rating

      def self.build(json:)
        super.tap do |record|
          record.main_activity = MainActivity.build(json: json.fetch(:mainActivity, {}))
          record.company_status = CompanyStatus.build(json: json.fetch(:companyStatus, {}))
          record.latest_shareholders_equity_figure = CurrencyValue.build(
            json: json.fetch(:latestShareholdersEquityFigure, {})
          )
          record.latest_turnover_figure = CurrencyValue.build(
            json: json.fetch(:latestTurnoverFigure, {})
          )
          record.credit_rating = CreditRating.build(json: json.fetch(:creditRating, {}))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
creditsafe_connect-0.1.7 lib/creditsafe/models/company_summary.rb