Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [Unreleased]

## [3.0.0] - 2025-09-22
- Update `faraday` dependency to version 2.13.4
- Remove `faraday_middleware` dependency

## [2.2.0] - 2025-09-16

- Add support for passing an optional person_id parameter to HTTP request helpers
Expand Down
43 changes: 13 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
PATH
remote: .
specs:
incognia_api (2.2.0)
faraday (~> 1.10)
faraday_middleware (~> 1.2)
incognia_api (3.0.0)
faraday (~> 2.13)

GEM
remote: https://rubygems.org/
Expand All @@ -14,34 +13,18 @@ GEM
crack (0.4.5)
rexml
diff-lcs (1.4.4)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
faraday (2.13.4)
faraday-net_http (>= 2.0, < 3.5)
json
logger
faraday-net_http (3.4.1)
net-http (>= 0.5.0)
hashdiff (1.0.1)
json (2.14.0)
logger (1.7.0)
method_source (1.0.0)
multipart-post (2.3.0)
net-http (0.6.0)
uri
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand All @@ -61,8 +44,8 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-support (3.10.2)
ruby2_keywords (0.0.5)
timecop (0.9.4)
uri (1.0.3)
webmock (3.14.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand Down
4 changes: 2 additions & 2 deletions fixtures/vcr_cassettes/token.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions incognia_api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
spec.summary = "Official Ruby lib for communicating with Incognia API"
spec.description = "Official Ruby lib for communicating with Incognia API"
spec.homepage = "https://github.com/inloco/incognia-ruby"
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/inloco/incognia-ruby"
Expand All @@ -28,8 +28,7 @@ Gem::Specification.new do |spec|

# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"
spec.add_dependency('faraday', '~> 1.10')
spec.add_dependency('faraday_middleware', '~> 1.2')
spec.add_dependency('faraday', '~> 2.13')

# For more information and examples about making a new gem, checkout our
# guide at: https://bundler.io/guides/creating_gem.html
Expand Down
1 change: 0 additions & 1 deletion lib/incognia_api/api.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require "faraday"
require "json"
require "logger"
require 'faraday_middleware'
Copy link
Copy Markdown
Contributor Author

@IanGabriel12 IanGabriel12 Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gem is deprecated, some common middlewares are bundled in faraday itself now. Ref


module Incognia
class Api
Expand Down
9 changes: 3 additions & 6 deletions lib/incognia_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def request(method, endpoint = nil, data = nil, headers = {})
json_data = JSON.generate(data) if data

connection.send(method, endpoint, json_data, headers) do |r|
r.headers[Faraday::Request::Authorization::KEY] ||= Faraday::Request
.lookup_middleware(:authorization)
.header(:Bearer, credentials.access_token)
Comment on lines -17 to -19
Copy link
Copy Markdown
Contributor Author

@IanGabriel12 IanGabriel12 Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper function does not exist anymore, but since credentials.access_token is a string, this just returns Bearer {token}

This is the old helper's code:

def self.header(type, token)
  case token
  when String, Symbol, Proc
    token = token.call if token.is_a?(Proc)
    "#{type} #{token}"
  when Hash
    build_hash(type.to_s, token)
  else
    raise ArgumentError,
          "Can't build an Authorization #{type}" \
            "header from #{token.inspect}"
  end
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also removed the .lookup_middleware(:authorization). Could you please explain what is the side effect of this removal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no side effects, what the old code did was to use the header method of the middleware :authorization, which behaves the same way as just returning Bearer #{token} in this case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

r.headers[Faraday::Request::Authorization::KEY] ||= "Bearer #{credentials.access_token}"
end
rescue Faraday::ClientError, Faraday::ServerError => e
raise APIError.new(e.to_s, e.response)
Expand Down Expand Up @@ -50,9 +48,8 @@ def connection
protected

def request_credentials
basic_auth = Faraday::Request
.lookup_middleware(:basic_auth)
.header(Incognia.config.client_id, Incognia.config.client_secret)
Comment on lines -53 to -55
Copy link
Copy Markdown
Contributor Author

@IanGabriel12 IanGabriel12 Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper function does not exist anymore, but i found an utility function that behaves the same way.

Old helper:

def self.header(login, pass)
  value = Base64.encode64([login, pass].join(':'))
  value.delete!("\n")
  super(:Basic, value)
end

New util:

def basic_header_from(login, pass)
  value = ["#{login}:#{pass}"].pack('m') # Base64 encoding
  value.delete!("\n")
  "Basic #{value}"
end

basic_auth = Faraday::Utils
.basic_header_from(Incognia.config.client_id, Incognia.config.client_secret)

response = connection.send(:post, 'v2/token') do |r|
r.headers[Faraday::Request::Authorization::KEY] = basic_auth
Expand Down
2 changes: 1 addition & 1 deletion lib/incognia_api/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Incognia
VERSION = "2.2.0"
VERSION = "3.0.0"
end
Loading