class Fastlane::Firebase::Manager

Public Instance Methods

login(username) click to toggle source
# File lib/fastlane/plugin/firebase/lib/manager.rb, line 10
                def login(username)
                        item = Security::InternetPassword.find(server: server_name(), account: username)
keychain_password = item.password if item

password = keychain_password
begin 
  password = UI.password("Password for #{username}") unless password
  
  #Api instance
  @api = Firebase::Api.new(username, password)
  
  #Store password
  Security::InternetPassword.add(server_name(), username, password) unless keychain_password == password

  @api
rescue Firebase::Api::LoginError => e
  UI.error e.message

  if UI.confirm "Do you want to re-enter your password?" then
          password = nil
    if keychain_password then
      puts "Removing Keychain entry for user '#{username}'...".yellow
      Security::InternetPassword.delete(server: server_name(), account: username)
    end
    keychain_password = nil
    retry
  end
end
                end
select_client(project, client_id) click to toggle source
# File lib/fastlane/plugin/firebase/lib/manager.rb, line 56
def select_client(project, client_id)
  if project["clientSummary"] == nil then
    UI.user_error! "Project has no clients"
    return
  end

  clients = (project["clientSummary"] || []).sort {|left, right| left["clientId"] <=> right["clientId"] }

  if client = clients.select {|c| c["clientId"] == client_id }.first then
          client
  else
          options = clients.map { |p| "#{p["clientId"]} (#{p["displayName"]})" }
          index = select_index("Select client:", options)
          clients[index]
        end
end
select_index(text, options) click to toggle source
# File lib/fastlane/plugin/firebase/lib/manager.rb, line 73
def select_index(text, options)
                          selected = UI.select(text, options)
                          return options.index(selected)
                  end
select_project(project_number) click to toggle source
# File lib/fastlane/plugin/firebase/lib/manager.rb, line 40
                  def select_project(project_number)
                          projects = @api.project_list()
  if projects.count == 0 then
    UI.user_error! "No projects exist under the account"
    return
  end

                          if project = projects.select {|p| p["projectNumber"] == project_number }.first then
                                  project
                          else 
          options = projects.map { |p| p["displayName"] }
          index = select_index("Select project:", options)
          projects[index]
  end
end
server_name() click to toggle source
# File lib/fastlane/plugin/firebase/lib/manager.rb, line 6
                  def server_name
  "firebase.google.com"
end