Class: Synapsis::Authentication
- Inherits:
-
Object
- Object
- Synapsis::Authentication
- Includes:
- Utilities
- Defined in:
- lib/synapsis/authentication.rb
Constant Summary
Constants included from Utilities
Instance Attribute Summary collapse
-
#grant_type ⇒ Object
Returns the value of attribute grant_type.
-
#password ⇒ Object
Returns the value of attribute password.
-
#scope ⇒ Object
Returns the value of attribute scope.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params) ⇒ Authentication
constructor
A new instance of Authentication.
- #login ⇒ Object
Methods included from Utilities
#build_json_from_params, #build_json_from_variable_hash, #build_params_from_string, #to_hash
Constructor Details
#initialize(params) ⇒ Authentication
Returns a new instance of Authentication.
10 11 12 13 14 15 16 17 |
# File 'lib/synapsis/authentication.rb', line 10 def initialize(params) params.each do |k, v| send("#{k}=", v) end @grant_type = 'password' @scope = 'write' end |
Instance Attribute Details
#grant_type ⇒ Object
Returns the value of attribute grant_type.
4 5 6 |
# File 'lib/synapsis/authentication.rb', line 4 def grant_type @grant_type end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/synapsis/authentication.rb', line 4 def password @password end |
#scope ⇒ Object
Returns the value of attribute scope.
4 5 6 |
# File 'lib/synapsis/authentication.rb', line 4 def scope @scope end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/synapsis/authentication.rb', line 4 def username @username end |
Class Method Details
.login(params) ⇒ Object
6 7 8 |
# File 'lib/synapsis/authentication.rb', line 6 def self.login(params) self.new(params).login end |
Instance Method Details
#login ⇒ Object
19 20 21 22 23 24 |
# File 'lib/synapsis/authentication.rb', line 19 def login Synapsis.connection.post do |req| req.url 'oauth2/access_token' req.body = build_params_from_string end end |