Sha256: 6fac236466be6227e0e8432e3350acf5a64e4f5c2769128ecf1b6b074732296e

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

require "digicert/cli/filter_builder"

module Digicert
  module CLI
    class Order < Digicert::CLI::Base
      def list
        display_orders_in_table(orders)
      end

      def find
        apply_ouput_flag(orders.first)
      end

      private

      def orders
        @orders ||= order_api.all(filter_options)
      end

      def order_api
        Digicert::Order
      end

      def filter_options
        if options[:filter]
          { filters: Digicert::CLI::FilterBuilder.build(options[:filter]) }
        end
      end

      def apply_ouput_flag(order)
        options[:quiet] ? order.id : order
      end

      def display_orders_in_table(orders)
        orders_attribtues = orders.map do |order|
          [
            order.id,
            order.product_name_id,
            order.certificate.common_name,
            order.status,
            order.certificate.valid_till,
          ]
        end

        Digicert::CLI::Util.make_it_pretty(
          rows: orders_attribtues,
          headings: ["Id", "Product Type", "Common Name", "Status", "Expiry"],
        )
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
digicert-cli-1.0.0 lib/digicert/cli/order.rb
digicert-cli-0.5.2 lib/digicert/cli/order.rb
digicert-cli-0.5.1 lib/digicert/cli/order.rb
digicert-cli-0.5.0 lib/digicert/cli/order.rb
digicert-cli-0.4.2 lib/digicert/cli/order.rb
digicert-cli-0.4.1 lib/digicert/cli/order.rb
digicert-cli-0.4.0 lib/digicert/cli/order.rb
digicert-cli-0.3.0 lib/digicert/cli/order.rb
digicert-cli-0.2.0 lib/digicert/cli/order.rb