module UserMappingPrompter 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 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 end