module ThirdPartyPrompter

Public Instance Methods

third_party_id(allow_none=false) click to toggle source
# File lib/pvdgm-svc-client/prompters/third_party_prompter.rb, line 3
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 Instance Methods

prompt_for_third_party_id(allow_none) click to toggle source
# File lib/pvdgm-svc-client/prompters/third_party_prompter.rb, line 11
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