module UserMappingPrompter

Public Instance Methods

user_mapping_id(allow_none=false) click to toggle source
# File lib/pvdgm-svc-client/prompters/user_mapping_prompter.rb, line 3
def user_mapping_id(allow_none=false)
  return options[:user_mapping_id] if options[:user_mapping_id]
  return options[:user_mapping_id] = ENV['USER_MAPPING_ID'] if ENV['USER_MAPPING_ID']
  return options[:user_mapping_id] = prompt_for_user_mapping_id(allow_none)
end

Private Instance Methods

prompt_for_user_mapping_id(allow_none) click to toggle source
# File lib/pvdgm-svc-client/prompters/user_mapping_prompter.rb, line 11
def prompt_for_user_mapping_id(allow_none)
  result = get("services/third_parties/#{third_party_id}/user_mappings")

  (puts "No third-parties are defined. Cannot continue"; exit 1) if result.empty?

  # Build a menu of the user mappings
  puts
  return prompter.choose do | menu |
    menu.prompt = "Select the User Mapping: "
    menu.choice("No Selection") { -1 } if allow_none
    result.each do | user_mapping |
      menu.choice("#{user_mapping['user_name']} (#{user_mapping['user_id']}) - #{user_mapping['user_code']}") { user_mapping['id'] }
    end
  end
end