Sha256: e088d47fe808f07efa8bbdfc24fb38ed31175d08692093bb467622df36604345

Contents?: true

Size: 962 Bytes

Versions: 6

Compression:

Stored size: 962 Bytes

Contents

module SltcRegistrationPrompter

  def sltc_registration_id(allow_none=false)
    return options[:sltc_registration_id] if options[:sltc_registration_id]
    return options[:sltc_registration_id] = ENV['SLTC_REGISTRATION_ID'] if ENV['SLTC_REGISTRATION_ID']
    return options[:sltc_registration_id] = prompt_for_sltc_registration_id(allow_none)
  end

  private

  def prompt_for_sltc_registration_id(allow_none)
    result = get("services/sltc_registrations?status=0")

    (puts "No uncompleted SLTC Registrations are available. Cannot continue"; exit 1) if result.empty?

    # Build a menu of the account mappings
    puts
    return prompter.choose do | menu |
      menu.prompt = "Select the SLTC Registration: "
      menu.choice("No Selection") { -1 } if allow_none
      result.each do | sltc_registration |
        menu.choice("#{sltc_registration['company_name']} (#{sltc_registration['id']})") { sltc_registration['id'] }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pvdgm-svc-client-0.3.4 lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb
pvdgm-svc-client-0.3.3 lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb
pvdgm-svc-client-0.3.2 lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb
pvdgm-svc-client-0.2.2 lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb
pvdgm-svc-client-0.2.1 lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb
pvdgm-svc-client-0.1.6 lib/pvdgm-svc-client/prompters/sltc_registration_prompter.rb