Sha256: 913906adfaf42b0d4d265304517d67762199ffdbe43377cdafd3a57996ef16e6

Contents?: true

Size: 879 Bytes

Versions: 4

Compression:

Stored size: 879 Bytes

Contents

module Digicert
  class DuplicateCertificateFinder
    def initialize(request_id:)
      @request_id = request_id
    end

    def find
      certificate_by_date_created
    end

    def self.find_by(request_id:)
      new(request_id: request_id).find
    end

    private

    attr_reader :request_id

    def certificate_by_date_created
      certificates_by_date_created.first
    end

    def certificates_by_date_created
      duplicate_certificates.select do |certificate|
        certificate.date_created == request_created_at
      end
    end

    def duplicate_certificates
      @duplicate_certificates ||=
        Digicert::DuplicateCertificate.all(order_id: request.order.id)
    end

    def request_created_at
      request.order.certificate.date_created
    end

    def request
      @request ||= Digicert::CertificateRequest.fetch(request_id)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
digicert-0.3.0 lib/digicert/duplicate_certificate_finder.rb
digicert-0.2.0 lib/digicert/duplicate_certificate_finder.rb
digicert-0.1.2 lib/digicert/duplicate_certificate_finder.rb
digicert-0.1.1 lib/digicert/duplicate_certificate_finder.rb