Module: Pivit::Authentication
- Included in:
- Client
- Defined in:
- lib/pivit/authentication.rb
Instance Method Summary collapse
Instance Method Details
#authenticate(options) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pivit/authentication.rb', line 8 def authenticate() if ![:username].nil? && ![:password].nil? self.username = URI::encode([:username]) self.password = URI::encode([:password]) self.api_token = get("tokens/active").token.guid build_endpoint elsif ![:token].nil? self.api_token = [:token] build_endpoint else raise "Your authentication credentials are invalid." end end |
#authenticated? ⇒ Boolean
4 5 6 |
# File 'lib/pivit/authentication.rb', line 4 def authenticated? !self.api_token.nil? end |