Sha256: caa9b07b5f4b79583134e579605347ce454c9044ae6dc2d8a9a1cb0c67dd345d
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
module Roqua module CoreApi module Sessions class OAuthSession attr_reader :access_token attr_reader :server_url def initialize(access_token, server_url = ENV["CORE_URL"]) @access_token = access_token @server_url = server_url end def me response = get('/me') fail response.inspect unless response.code == 200 response["me"] end def get(url, params = {}) HTTParty.get(full_url_for(url), headers: headers, query: params) end def post(url, params = {}) HTTParty.post(full_url_for(url), headers: headers, body: params) end def put(url, params = {}) HTTParty.put(full_url_for(url), headers: headers, body: params) end def logout_url(redirect_to:) "#{server_url}/session/destroy?token=#{access_token}&redirect_to=#{CGI.escape redirect_to}" end private def full_url_for(url) server_url + base_url + url + ".json" end def base_url "/api/v1" end def headers {"Authorization" => "Bearer #{access_token}"} end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roqua-core-api-0.0.9 | lib/roqua/core_api/sessions/oauth_session.rb |
roqua-core-api-0.0.8 | lib/roqua/core_api/sessions/oauth_session.rb |