lib/workos.rb in workos-2.4.0 vs lib/workos.rb in workos-2.5.0

- old
+ new

@@ -3,10 +3,11 @@ require 'workos/version' require 'sorbet-runtime' require 'json' require 'workos/hash_provider' +require 'workos/configuration' # Use the WorkOS module to authenticate your # requests to the WorkOS API. The gem will read # your API key automatically from the ENV var `WORKOS_API_KEY`. # Alternatively, you can set the key yourself with @@ -14,24 +15,32 @@ # your application, such as an initializer. module WorkOS API_HOSTNAME = ENV['WORKOS_API_HOSTNAME'] || 'api.workos.com' def self.key=(value) - Base.key = value + warn '`WorkOS.key=` is deprecated. Use `WorkOS.configure` instead.' + + config.key = value end def self.key - Base.key + warn '`WorkOS.key` is deprecated. Use `WorkOS.configure` instead.' + + config.key end - def self.key! - key || raise('WorkOS.key not set') + def self.config + @config ||= Configuration.new end + def self.configure + yield(config) + end + autoload :Types, 'workos/types' - autoload :Base, 'workos/base' autoload :Client, 'workos/client' + autoload :Configuration, 'workos/configuration' autoload :AuditTrail, 'workos/audit_trail' autoload :Connection, 'workos/connection' autoload :DirectorySync, 'workos/directory_sync' autoload :Directory, 'workos/directory' autoload :DirectoryGroup, 'workos/directory_group' @@ -46,20 +55,21 @@ autoload :Webhook, 'workos/webhook' autoload :Webhooks, 'workos/webhooks' autoload :MFA, 'workos/mfa' autoload :Factor, 'workos/factor' autoload :Challenge, 'workos/challenge' - autoload :VerifyFactor, 'workos/verify_factor' + autoload :VerifyChallenge, 'workos/verify_challenge' autoload :DeprecatedHashWrapper, 'workos/deprecated_hash_wrapper' # Errors autoload :APIError, 'workos/errors' autoload :AuthenticationError, 'workos/errors' autoload :InvalidRequestError, 'workos/errors' autoload :SignatureVerificationError, 'workos/errors' + autoload :TimeoutError, 'workos/errors' # Remove WORKOS_KEY at some point in the future. Keeping it here now for # backwards compatibility. key = ENV['WORKOS_API_KEY'] || ENV['WORKOS_KEY'] - WorkOS.key = key unless key.nil? + config.key = key unless key.nil? end