Sha256: cf53a8f60e3100e55f4229316b7664b862fcf6de8c616425c1ba30339c2e56d3

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

require_relative 'request_helper'

module Stytch
  class Sessions
    include Stytch::RequestHelper

    PATH = '/v1/sessions'

    def initialize(connection)
      @connection = connection
    end

    def get(user_id:)
      query_params = {
          user_id: user_id
      }

      request = request_with_query_params(PATH, query_params)

      get_request(request)
    end

    def authenticate(
        session_token:,
        session_duration_minutes: nil
    )
      request = {
          session_token: session_token
      }

      request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?

      post_request("#{PATH}/authenticate", request)
    end

    def revoke(
        session_id: nil,
        session_token: nil
    )
      request = {}

      request[:session_id] = session_id unless session_id.nil?
      request[:session_token] = session_token unless session_token.nil?

      post_request("#{PATH}/revoke", request)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stytch-2.2.0 lib/stytch/sessions.rb