Skip to content

Commit

Permalink
chore: Allow use of Faraday v2
Browse files Browse the repository at this point in the history
  • Loading branch information
agis committed Oct 27, 2023
1 parent ab076ca commit 0ce59a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
26 changes: 9 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,25 @@ PATH
specs:
clerk-sdk-ruby (2.10.0)
concurrent-ruby (~> 1.1)
faraday (~> 1.4.1)
faraday (>= 1.4.1, < 3.0)
jwt (~> 2.5)

GEM
remote: https://rubygems.org/
specs:
base64 (0.1.1)
byebug (11.1.3)
concurrent-ruby (1.2.2)
faraday (1.4.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
multipart-post (>= 1.2, < 3)
faraday (2.7.11)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
jwt (2.7.0)
minitest (5.18.0)
multipart-post (2.3.0)
faraday-net_http (3.0.2)
jwt (2.7.1)
minitest (5.20.0)
rake (13.0.6)
ruby2_keywords (0.0.5)
timecop (0.9.6)
timecop (0.9.8)

PLATFORMS
arm64-darwin-22
Expand Down
3 changes: 2 additions & 1 deletion clerk-sdk-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency "faraday", "~> 1.4.1"
spec.add_dependency "faraday", ">= 1.4.1", "< 3.0"
#spec.add_dependency "faraday", "~> 1.4.1"
spec.add_dependency "jwt", '~> 2.5'
spec.add_dependency "concurrent-ruby", "~> 1.1"

Expand Down
11 changes: 9 additions & 2 deletions lib/clerk/sdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def self.jwks_cache

def initialize(api_key: nil, base_url: nil, logger: nil, ssl_verify: true,
connection: nil)
if connection # Inject a Faraday::Connection for testing or full control over Faraday
if connection
# Inject a Faraday::Connection for testing or full control over Faraday
@conn = connection
return
else
Expand All @@ -50,7 +51,13 @@ def initialize(api_key: nil, base_url: nil, logger: nil, ssl_verify: true,
else
URI(base_url)
end
api_key = api_key || Clerk.configuration.api_key

api_key ||= if Faraday::VERSION.to_i < 2
Clerk.configuration.api_key
elsif Clerk.configuration.api_key.nil?
-> { raise ArgumentError, "Clerk secret key is not set" }
end

logger = logger || Clerk.configuration.logger
@conn = Faraday.new(
url: base_uri, headers: DEFAULT_HEADERS, ssl: {verify: ssl_verify}
Expand Down

0 comments on commit 0ce59a6

Please sign in to comment.