class Fire::Connection::Request
Public Class Methods
new()
click to toggle source
# File lib/connection/request.rb, line 7 def initialize @client = HTTPClient.new(base_url: Fire.config.base_uri) @client.connect_timeout = Fire.config.timeout || 120 @client.default_header['Content-Type'] = 'application/json' end
Protected Instance Methods
prepare_options(query_options)
click to toggle source
# File lib/connection/request.rb, line 47 def prepare_options(query_options) query_options.merge(Fire.config.auth) end
process(method, path, query={}, body=nil, tries=5)
click to toggle source
# File lib/connection/request.rb, line 35 def process(method, path, query={}, body=nil, tries=5) raise 'Firebase Connection Failed' if tries.zero? begin Fire.logger.request(method, path) raw_response = @client.request(method, "#{path}.json", body: body, query: prepare_options(query), follow_redirect: true) Fire::Connection::Response.new(raw_response, path) rescue HTTPClient::ConnectTimeoutError Fire.logger.timed_out(method, path) return process(method, path, query, body, tries-1) end end