class CreditReport::ExperianService < CreditReport::ApplicationService
  def call
    resp = rest_client_request(:post, url, @model, :contact, body: body)
    @model.update(credit_report_key: resp.headers[:requestid])
  end

  private
    def endpoint
      'experian/credit-profile/credit-report/basic/exp-prequal-vantage4'
    end

    def body
      if Rails.env.development? || ENV['STAGING']&.to_bool
        {
          firstName: "Anderson",
          lastName: "Laurie",
          street1: "9817 LOOP BLVD",
          street2: "APT G",
          city: "CALIFORNIA CITY",
          state: "CA",
          zip: "935051352",
          ssn: "666455730"
        }
      else
        {
          firstName: @options[:first_name],
          lastName: @options[:last_name],
          street1: @options[:address],
          street2: @options[:address_ext],
          city: @options[:city],
          state: @options[:state],
          zip: @options[:zip],
          ssn: @options[:ssn],
        }
      end
    end
end
