class Supai::Authorization
Constants
- ENDPOINT
Attributes
secret[RW]
token[RW]
user_id[RW]
Public Class Methods
create(authorization, api: API.new)
click to toggle source
# File lib/supai/authorization.rb, line 7 def self.create(authorization, api: API.new) response = api.request(:post, ENDPOINT, body: {}, token: authorization) raise response.error unless response.success? return self.new(response.json_body) end
new(hash)
click to toggle source
# File lib/supai/authorization.rb, line 14 def initialize(hash) set_attributes(hash) end
Public Instance Methods
authenticate_user(user_name:, password:, chain_id:, api: API.new)
click to toggle source
# File lib/supai/authorization.rb, line 18 def authenticate_user(user_name:, password:, chain_id:, api: API.new) endpoint = "/api/workbenchentry/v7/chains/#{chain_id}/authentication" body = { "SessionToken": token, "UserName": user_name, "Password": password, } response = api.request(:post, endpoint, body: body, token: secret) raise response.error unless response.success? return User.new(response.json_body["User"]) end