Class: UnimatrixCLI::Keymaker::ResourceOwner::InviteCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/unimatrix_cli/keymaker/resource_owner/invite_command.rb

Instance Method Summary collapse

Methods inherited from Command

available_commands, descendants, #initialize, #read_file, #validate, #validate_collection, #write

Methods included from UnimatrixParser

included

Constructor Details

This class inherits a constructor from UnimatrixCLI::Command

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/unimatrix_cli/keymaker/resource_owner/invite_command.rb', line 18

def execute
  endpoint = "#{ Configuration.default_config[ 'keymaker_url' ] }/invite?#{ encoded_query }"
  
  resource_owner_response = make_request( endpoint, 'Post', { resource_owner: resource_owner } )
  
  if !resource_owner_response[ 'error' ]
    write(
      message: "Invite successfully created for resource owner. \n" +
      "Email Address: #{ resource_owner_response[ 'email_address' ] } \n" +
      "UUID: #{ resource_owner_response[ 'uuid' ] } \n" +
      "First Name: #{ resource_owner_response[ 'name_first' ] || '<none>' } \n" +
      "Last Name: #{ resource_owner_response[ 'name_last' ] || '<none>' }"
    )
  else
    write( 
      message: "Error inviting resource owner: " +
      "#{ resource_owner_response.inspect }", error: true 
    )
  end
end