class Stytch::Client
Constants
- ENVIRONMENTS
Attributes
magic_links[R]
oauth[R]
otps[R]
sessions[R]
users[R]
Public Class Methods
new(env:, project_id:, secret:, &block)
click to toggle source
# File lib/stytch/client.rb, line 15 def initialize(env:, project_id:, secret:, &block) @api_host = api_host(env) @project_id = project_id @secret = secret create_connection(&block) @users = Stytch::Users.new(@connection) @magic_links = Stytch::MagicLinks.new(@connection) @oauth = Stytch::OAuth.new(@connection) @otps = Stytch::OTPs.new(@connection) @sessions = Stytch::Sessions.new(@connection) end
Private Instance Methods
api_host(env)
click to toggle source
# File lib/stytch/client.rb, line 31 def api_host(env) case env when :live 'https://api.stytch.com' when :test 'https://test.stytch.com' else raise ArgumentError, "Invalid value for env (#{@env}): should be live or test" end end
build_default_connection(builder)
click to toggle source
# File lib/stytch/client.rb, line 49 def build_default_connection(builder) builder.options[:timeout] = Stytch::Middleware::NETWORK_TIMEOUT builder.headers = Stytch::Middleware::NETWORK_HEADERS builder.request :json builder.use Stytch::Middleware builder.response :json, content_type: /\bjson$/ builder.adapter Faraday.default_adapter end
create_connection() { |builder| ... }
click to toggle source
# File lib/stytch/client.rb, line 42 def create_connection @connection = Faraday.new(url: @api_host) do |builder| block_given? ? yield(builder) : build_default_connection(builder) end @connection.basic_auth(@project_id, @secret) end