module ConfiguredAccountPrompter
Public Instance Methods
configured_account_id(allow_none=false)
click to toggle source
# File lib/pvdgm-svc-client/prompters/configured_account_prompter.rb, line 3 def configured_account_id(allow_none=false) return options[:configured_account_id] if options[:configured_account_id] return options[:configured_account_id] = ENV['CONFIGURED_ACCOUNT_ID'] if ENV['CONFIGURED_ACCOUNT_ID'] return options[:configured_account_id] = prompt_for_configured_account_id(allow_none) end
Private Instance Methods
prompt_for_configured_account_id(allow_none)
click to toggle source
# File lib/pvdgm-svc-client/prompters/configured_account_prompter.rb, line 11 def prompt_for_configured_account_id(allow_none) if respond_to?(:third_party_id) result = get("services/third_parties/#{third_party_id}/service_definitions/#{service_definition_id}/configured_accounts") elsif respond_to?(:service_id) result = get("services/services/#{service_id}/service_definitions/#{service_definition_id}/configured_accounts") end (puts "No accounts have been configured for this service/third party. Cannot continue"; exit 1) if result.empty? # Build a menu of the services puts return prompter.choose do | menu | menu.prompt = "Select the Configured Account: " menu.choice("No Selection") { -1 } if allow_none result.each do | configured_account | menu.choice("#{configured_account['account_name']} (#{configured_account['account_id']}) - #{configured_account['enabled']}") { configured_account['id'] } end end end