module ThirdPartyPrompter def third_party_id(allow_none=false) return options[:third_party_id] if options[:third_party_id] return options[:third_party_id] = ENV['THIRD_PARTY_ID'] if ENV['THIRD_PARTY_ID'] return options[:third_party_id] = prompt_for_third_party_id(allow_none) end private def prompt_for_third_party_id(allow_none) result = get("services/third_parties") (puts "No third parties are defined. Cannot continue"; exit 1) if result.empty? # Build a menu of the third parties puts return prompter.choose do | menu | menu.prompt = "Select the Third Party: " menu.choice("No Selection") { -1 } if allow_none result.each do | third_party | menu.choice(third_party['name']) { third_party['id'] } end end end end