Sha256: d2792e3d89a6a3b16d29736d9246a2ed0d573ad288bcf3dbaaf976eb92131b35

Contents?: true

Size: 987 Bytes

Versions: 4

Compression:

Stored size: 987 Bytes

Contents

# frozen_string_literal: true

require 'creditsafe/namespace'

module Creditsafe
  module Request
    class CompanyReport
      def initialize(company_id, custom_data)
        @company_id = company_id
        @custom_data = custom_data
      end

      def message
        message = {
          "#{Creditsafe::Namespace::OPER}:companyId" => company_id.to_s,
          "#{Creditsafe::Namespace::OPER}:reportType" => 'Full',
          "#{Creditsafe::Namespace::OPER}:language" => "EN"
        }

        unless custom_data.nil?
          message["#{Creditsafe::Namespace::OPER}:customData"] = {
            "#{Creditsafe::Namespace::DAT}:Entries" => {
              "#{Creditsafe::Namespace::DAT}:Entry" => custom_data_entries
            }
          }
        end

        message
      end

      private

      def custom_data_entries
        custom_data.map { |key, value| { :@key => key, :content! => value } }
      end

      attr_reader :company_id, :custom_data
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
creditsafe-0.5.0 lib/creditsafe/request/company_report.rb
creditsafe-0.4.0 lib/creditsafe/request/company_report.rb
creditsafe-0.3.2 lib/creditsafe/request/company_report.rb
creditsafe-0.3.1 lib/creditsafe/request/company_report.rb