Sha256: a76f7d7254001835d97e80ff551a68b8dacf4823c4ebaafc0be403c16ccbf260

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

module Digicert
  module CLI
    module Command
      class Order
        attr_reader :order_id, :options

        def initialize(attributes = {})
          @options = attributes
          @order_id = options[:order_id]
        end

        def list
          find_order || order_api.all
        end

        def find
          find_order || filter_order
        end

        private

        def find_order
          if order_id
            order_api.fetch(order_id)
          end
        end

        def filter_order
          list.select do |order|
            filter_by_common_name(order) && filter_by_product_type(order)
          end
        end

        def filter_by_common_name(order)
          !options[:common_name] ||
            options[:common_name] == order.certificate.common_name
        end

        def filter_by_product_type(order)
          !options[:product_type] ||
            options[:product_type] == order.product_name_id
        end

        def order_api
          Digicert::Order
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
digicert-cli-0.1.0 lib/digicert/cli/command/order.rb