-
Notifications
You must be signed in to change notification settings - Fork 1
Chore: Update faraday to v2.13.4 #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,6 @@ | ||
| require "faraday" | ||
| require "json" | ||
| require "logger" | ||
| require 'faraday_middleware' | ||
|
|
||
| module Incognia | ||
| class Api | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This helper function does not exist anymore, but since 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also removed the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
|
@@ -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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)
endNew 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 | ||
|
|
||
| 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 |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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