Skip to content

Commit

Permalink
allow passing timout to http request #131 (#132)
Browse files Browse the repository at this point in the history
closes #131
  • Loading branch information
sabman authored Oct 21, 2024
1 parent 1295f67 commit 930c4b3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/fcm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ class FCM
INSTANCE_ID_API = "https://iid.googleapis.com"
TOPIC_REGEX = /[a-zA-Z0-9\-_.~%]+/

def initialize(json_key_path = "", project_name = "")
def initialize(json_key_path = "", project_name = "", http_options = {})
@json_key_path = json_key_path
@project_name = project_name
@http_options = http_options
end

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

0 comments on commit 930c4b3

Please sign in to comment.