Sha256: 226075e1d214bc2c7c33ad106673fd2e2bb57394605795f8f4c119783d3fc4be

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module Commands::Core::Domain
  class ByIdentifier < RestPack::Service::Command
    required do
      string :identifier
    end

    optional do
      string :include
    end

    def execute
      identifiers = [
        inputs[:identifier],
        without_subdomain(identifier)
      ]

      identifiers.reject(&:nil?).each do |identifier|
        result = Serializers::Core::Domain.resource(
          inputs,
          Models::Core::Domain.where(identifier: identifier)
        )

        if result[:domains].any?
          return result
        end
      end

      status :not_found
    end

    private

    def without_subdomain(identifier)
      identifier.split('.')[1..-1].join('.')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_core_service-0.0.14 lib/restpack_core_service/commands/domain/by_identifier.rb