Class: Warrant::Session
- Inherits:
-
Object
- Object
- Warrant::Session
- Defined in:
- lib/warrant/models/session.rb
Class Method Summary collapse
-
.create_authorization_session(params = {}, options = {}) ⇒ String
Create an Authorization Session for a given user.
-
.create_self_service_session(redirect_url, params = {}, options = {}) ⇒ String
Create a Self-Service Dashboard Session for a given user.
Class Method Details
.create_authorization_session(params = {}, options = {}) ⇒ String
Create an Authorization Session for a given user
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/warrant/models/session.rb', line 18 def self.(params = {}, = {}) params = params.merge(type: "sess") res = APIOperations.post(URI.parse("#{::Warrant.config.api_base}/v1/sessions"), params: Util.normalize_params(params), options: ) case res when Net::HTTPSuccess res_json = JSON.parse(res.body) res_json['token'] else APIOperations.raise_error(res) end end |
.create_self_service_session(redirect_url, params = {}, options = {}) ⇒ String
Create a Self-Service Dashboard Session for a given user
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/warrant/models/session.rb', line 48 def self.create_self_service_session(redirect_url, params = {}, = {}) params = params.merge(type: "ssdash") res = APIOperations.post(URI.parse("#{::Warrant.config.api_base}/v1/sessions"), params: Util.normalize_params(params), options: ) case res when Net::HTTPSuccess res_json = JSON.parse(res.body) "#{::Warrant.config.self_service_dash_url_base}/#{res_json['token']}?redirectUrl=#{redirect_url}" else APIOperations.raise_error(res) end end |