Class: Layer::Client::REST
- Inherits:
-
Layer::Client
- Object
- Layer::Client
- Layer::Client::REST
- Defined in:
- lib/layer/client/rest.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app_id = Layer::Client.app_id, &block) ⇒ REST
constructor
A new instance of REST.
Methods inherited from Layer::Client
configure, #delete, #get, #head, normalize_id, #options, #patch, #post, #put
Constructor Details
Instance Attribute Details
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
16 17 18 |
# File 'lib/layer/client/rest.rb', line 16 def app_id @app_id end |
#block ⇒ Object (readonly)
Returns the value of attribute block.
16 17 18 |
# File 'lib/layer/client/rest.rb', line 16 def block @block end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
16 17 18 |
# File 'lib/layer/client/rest.rb', line 16 def token @token end |
Class Method Details
.authenticate(app_id, nonce = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/layer/client/rest.rb', line 5 def self.authenticate(app_id, nonce = nil) client = Layer::Client.new nonce ||= client.post('/nonces')['nonce'] identity_token = yield(nonce) response = client.post('/sessions', { identity_token: identity_token, app_id: app_id }) response['session_token'] end |