Class: EY::CLI::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
#==, #app_for_repo, #app_for_repo!, #apps, #environments, read_token, request, save_token
Constructor Details
#initialize(token = nil) ⇒ API
Returns a new instance of API.
5 6 7 8 9 10 |
# File 'lib/engineyard/cli/api.rb', line 5 def initialize(token = nil) @token = token @token ||= self.class.read_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
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/engineyard/cli/api.rb', line 26 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
22 23 24 |
# File 'lib/engineyard/cli/api.rb', line 22 def refresh @token = self.class.fetch_token end |