Skip to content

Commit 930c4b3

Browse files
authored
allow passing timout to http request #131 (#132)
closes #131
1 parent 1295f67 commit 930c4b3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/fcm.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ class FCM
1212
INSTANCE_ID_API = "https://iid.googleapis.com"
1313
TOPIC_REGEX = /[a-zA-Z0-9\-_.~%]+/
1414

15-
def initialize(json_key_path = "", project_name = "")
15+
def initialize(json_key_path = "", project_name = "", http_options = {})
1616
@json_key_path = json_key_path
1717
@project_name = project_name
18+
@http_options = http_options
1819
end
1920

2021
# See https://firebase.google.com/docs/cloud-messaging/send-message
@@ -192,7 +193,7 @@ def send_to_topic_condition(condition, options = {})
192193
def for_uri(uri, extra_headers = {})
193194
connection = ::Faraday.new(
194195
url: uri,
195-
request: { timeout: DEFAULT_TIMEOUT }
196+
request: { timeout: @http_options.fetch(:timeout, DEFAULT_TIMEOUT) }
196197
) do |faraday|
197198
faraday.adapter Faraday.default_adapter
198199
faraday.headers["Content-Type"] = "application/json"

0 commit comments

Comments
 (0)