Class: Synapsis::Authentication

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/synapsis/authentication.rb

Constant Summary

Constants included from Utilities

Utilities::API_V2_PATH

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_typeObject

Returns the value of attribute grant_type.



4
5
6
# File 'lib/synapsis/authentication.rb', line 4

def grant_type
  @grant_type
end

#passwordObject

Returns the value of attribute password.



4
5
6
# File 'lib/synapsis/authentication.rb', line 4

def password
  @password
end

#scopeObject

Returns the value of attribute scope.



4
5
6
# File 'lib/synapsis/authentication.rb', line 4

def scope
  @scope
end

#usernameObject

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.(params)
  self.new(params).
end

Instance Method Details

#loginObject



19
20
21
22
23
24
# File 'lib/synapsis/authentication.rb', line 19

def 
  Synapsis.connection.post do |req|
    req.url 'oauth2/access_token'
    req.body = build_params_from_string
  end
end