-
Notifications
You must be signed in to change notification settings - Fork 155
Allow faraday client configuration #138
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,10 +12,11 @@ class FCM | |
| INSTANCE_ID_API = "https://iid.googleapis.com" | ||
| TOPIC_REGEX = /[a-zA-Z0-9\-_.~%]+/ | ||
|
|
||
| def initialize(json_key_path = "", project_name = "", http_options = {}) | ||
| def initialize(json_key_path = "", project_name = "", http_options = {}, faraday_configurer = nil) | ||
| @json_key_path = json_key_path | ||
| @project_name = project_name | ||
| @http_options = http_options | ||
| @faraday_configurer = faraday_configurer | ||
| end | ||
|
|
||
| # See https://firebase.google.com/docs/cloud-messaging/send-message | ||
|
|
@@ -202,6 +203,7 @@ def for_uri(uri, extra_headers = {}) | |
| extra_headers.each do |key, value| | ||
| faraday.headers[key] = value | ||
| end | ||
| @faraday_configurer.call(faraday) if @faraday_configurer | ||
|
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. Style/SafeNavigation: Use safe navigation (&.) instead of checking if an object exists before calling the method.
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. Nice to have: We can probably move @faraday_configurer&.call(faraday) before faraday.adapter Faraday.default_adapter so users can add request middleware (e.g. faraday.request :retry) without confusing with ordering issues |
||
| end | ||
| yield connection | ||
| end | ||
|
|
||
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.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [100/80]