Class: Emasser::Register

Inherits:
SubCommandBase show all
Defined in:
lib/emasser/post.rb

Overview

The Registration endpoint provides the ability to register a certificate & obtain an API-key.

Endpoint:

/api/api-key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SubCommandBase

banner

Methods included from OutputConverters

#change_to_datetime, #to_output_hash

Methods included from InputConverters

#to_input_hash

Methods included from OptionsParser

#optional_options, #required_options

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/emasser/post.rb', line 49

def self.exit_on_failure?
  true
end

Instance Method Details

#certObject

rubocop:disable Style/RedundantBegin



55
56
57
58
59
60
61
62
63
# File 'lib/emasser/post.rb', line 55

def cert
  begin
    result = EmassClient::RegistrationApi.new.register_user(Emasser::GET_REGISTER_RETURN_TYPE)
    puts to_output_hash(result).green
  rescue EmassClient::ApiError => e
    puts 'Exception when calling RegistrationApi->register_user'.red
    puts to_output_hash(e).split('\n').join('. ')
  end
end