Class: Kazoo::Auth
- Inherits:
-
Object
- Object
- Kazoo::Auth
- Defined in:
- lib/kazoo/auth.rb
Instance Attribute Summary collapse
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #get_token ⇒ Object
-
#initialize(kazoo_config) ⇒ Auth
constructor
A new instance of Auth.
Constructor Details
#initialize(kazoo_config) ⇒ Auth
Returns a new instance of Auth.
5 6 7 8 9 10 11 12 |
# File 'lib/kazoo/auth.rb', line 5 def initialize(kazoo_config) @api_key = kazoo_config['api_key'] @host = kazoo_config['host'] @port = kazoo_config['port'] @version = kazoo_config['version'] @account_id = kazoo_config['account_id'] get_token end |
Instance Attribute Details
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
3 4 5 |
# File 'lib/kazoo/auth.rb', line 3 def account_id @account_id end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/kazoo/auth.rb', line 3 def api_key @api_key end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/kazoo/auth.rb', line 3 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/kazoo/auth.rb', line 3 def port @port end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
3 4 5 |
# File 'lib/kazoo/auth.rb', line 3 def token @token end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
3 4 5 |
# File 'lib/kazoo/auth.rb', line 3 def version @version end |
Instance Method Details
#get_token ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/kazoo/auth.rb', line 14 def get_token unless token base_uri = 'http://' + host + ":" + port + '/' + version + '/' auth_url = base_uri + 'api_auth' payload = {'data' => {'api_key' => api_key}} response = Nestful.json_put(auth_url, {:params => payload}) @token = response['auth_token'] end @token end |