Sha256: 56836abefb84bd60dbd50610919db135f9e97091387019293e0519fa0c48d6c0
Contents?: true
Size: 1.71 KB
Versions: 25
Compression:
Stored size: 1.71 KB
Contents
# frozen_string_literal: true require 'net/http' module WorkOS # The Portal module provides resource methods for working with the Admin # Portal product module Portal class << self include Client GENERATE_LINK_INTENTS = WorkOS::Types::Intent::ALL # Generate a link to grant access to an organization's Admin Portal # # @param [String] intent The access scope for the generated Admin Portal # link. Valid values are: ["audit_logs", "dsync", "log_streams", "sso",] # @param [String] organization The ID of the organization the Admin # Portal link will be generated for. # @param [String] The URL that the end user will be redirected to upon # exiting the generated Admin Portal. If none is provided, the default # redirect link set in your WorkOS Dashboard will be used. # @param [String] The URL to which WorkOS will redirect users to upon # successfully setting up Single Sign On or Directory Sync. def generate_link(intent:, organization:, return_url: nil, success_url: nil) validate_intent(intent) request = post_request( auth: true, body: { intent: intent, organization: organization, return_url: return_url, success_url: success_url, }, path: '/portal/generate_link', ) response = execute_request(request: request) JSON.parse(response.body)['link'] end private def validate_intent(intent) return if GENERATE_LINK_INTENTS.include?(intent) raise ArgumentError, "#{intent} is not a valid value." \ " `intent` must be in #{GENERATE_LINK_INTENTS}" end end end end
Version data entries
25 entries across 25 versions & 1 rubygems