Sha256: e8d239c93b22a1a5b714941eb3cc2bee686ae9945e837ceef4441c903cc1b5ec

Contents?: true

Size: 911 Bytes

Versions: 3

Compression:

Stored size: 911 Bytes

Contents

module MarketplaceKit
  module Commands
    class BaseAuthorizedCommand < BaseCommand
      def initialize(command_args)
        @command_args = command_args
        authenticate
      end

      protected

      def ensure_tmp_folder_exist
        Dir.mkdir('tmp') unless File.exist?('tmp')
      end

      def gateway
        @gateway ||= Services::ApiGateway.new
      end

      def authenticate
        MarketplaceKit.config.load current_env
        user_authentication.authenticate
      end

      def current_env
        endpoint_arg_value
      end

      def endpoint_arg_index
        @endpoint_arg_index ||= @command_args.find_index { |arg| arg == '-e' }
      end

      def endpoint_arg_value
        endpoint_arg_index && @command_args[endpoint_arg_index + 1]
      end

      def user_authentication
        @user_authentication ||= Services::UserAuthentication.new
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marketplace-kit-0.2.4 lib/marketplace_kit/commands/base_authorized_command.rb
marketplace-kit-0.2.3 lib/marketplace_kit/commands/base_authorized_command.rb
marketplace-kit-0.2.2 lib/marketplace_kit/commands/base_authorized_command.rb