Sha256: 525443fdd7671e792fa48e3a6461340a0b78b8a18b969adef9f7368c542803d5

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require "digicert/base"
require "digicert/findable"

module Digicert
  class Domain < Digicert::Base
    extend Digicert::Findable

    include Digicert::Actions::All
    include Digicert::Actions::Fetch
    include Digicert::Actions::Create

    def activate
      request_klass.new(
        :put, [resource_path, resource_id, "activate"].join("/")
      ).parse
    end

    def deactivate
      request_klass.new(
        :put, [resource_path, resource_id, "deactivate"].join("/")
      ).parse
    end

    private

    def resource_path
      "domain"
    end

    def validate_validations(attributes)
      attributes.map do |attribute|
        validate_validation(**attribute)
      end
    end

    # Validate validation
    #
    # We need to provide a valid type of valitations when creating a new domain,
    # but the most important thing about the types are it has to be in lowercase
    # format, otherwise Digicert won't accept it a valid type. So let's ensure
    # we are always providig the type in correct format.
    #
    # Ref: https://www.digicert.com/services/v2/documentation/appendix-validation-types
    #
    def validate_validation(type:, **attributes)
      attributes.merge(type: type.downcase)
    end

    def validate(name:, organization:, validations:, **attributes)
      required_attributes = {
        name: name,
        organization: organization,
        validations: validate_validations(validations),
      }

      required_attributes.merge(attributes)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
digicert-1.0.0 lib/digicert/domain.rb