Class: EY::CLI::API
Constant Summary
Constants inherited from API
Instance Attribute Summary
Attributes inherited from API
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(token = nil) ⇒ API
constructor
A new instance of API.
- #refresh ⇒ Object
- #request ⇒ Object
Methods inherited from API
#==, #apps, #apps_for_repo, #environments, request, #resolver, #user
Constructor Details
#initialize(token = nil) ⇒ API
Returns a new instance of API.
8 9 10 11 12 13 14 15 16 |
# File 'lib/engineyard/cli/api.rb', line 8 def initialize(token = nil) @token = token if ENV['ENGINEYARD_API_TOKEN'] @token = ENV['ENGINEYARD_API_TOKEN'] end @token ||= EY::EYRC.load.api_token @token ||= self.class.fetch_token raise EY::Error, "Sorry, we couldn't get your API token." unless @token end |
Class Method Details
.fetch_token ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/engineyard/cli/api.rb', line 32 def self.fetch_token EY.ui.info("We need to fetch your API token; please log in.") begin email = EY.ui.ask("Email: ") password = EY.ui.ask("Password: ", true) super(email, password) rescue EY::API::InvalidCredentials EY.ui.warn "Invalid username or password; please try again." retry end end |
Instance Method Details
#refresh ⇒ Object
28 29 30 |
# File 'lib/engineyard/cli/api.rb', line 28 def refresh @token = self.class.fetch_token end |