Class: Bouncer::Client
- Inherits:
-
Object
- Object
- Bouncer::Client
- Defined in:
- lib/bouncer-client/client.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bouncer_url) ⇒ Client
constructor
A new instance of Client.
- #jwt(token) ⇒ Object
- #me ⇒ Object
- #token(token) ⇒ Object
- #token_info ⇒ Object
- #user(id) ⇒ Object
Constructor Details
#initialize(bouncer_url) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 |
# File 'lib/bouncer-client/client.rb', line 10 def initialize bouncer_url @conn = Faraday.new(url: bouncer_url, headers: { accept: 'application/json' }) do |faraday| faraday.response :json, :content_type => /\bjson$/ faraday.request :json faraday.use Faraday::Response::RaiseError faraday.adapter Faraday.default_adapter faraday.headers['Content-Type'] = 'application/json' end end |
Class Method Details
Instance Method Details
#jwt(token) ⇒ Object
20 21 22 |
# File 'lib/bouncer-client/client.rb', line 20 def jwt token @conn. :JWT, token end |
#me ⇒ Object
28 29 30 |
# File 'lib/bouncer-client/client.rb', line 28 def me @conn.get('/me') end |
#token(token) ⇒ Object
24 25 26 |
# File 'lib/bouncer-client/client.rb', line 24 def token token @conn. :Bearer, token end |
#token_info ⇒ Object
36 37 38 |
# File 'lib/bouncer-client/client.rb', line 36 def token_info @conn.get('/oauth/token/info') end |
#user(id) ⇒ Object
32 33 34 |
# File 'lib/bouncer-client/client.rb', line 32 def user id @conn.get("/users/#{id}") end |