class HealtcheckProxyClient::Client
Public Class Methods
new(configuration:, healthcheck:)
click to toggle source
# File lib/healtcheck_proxy_client/client.rb, line 7 def initialize(configuration:, healthcheck:) @configuration = configuration @healthcheck = healthcheck end
ping(configuration:, healthcheck:)
click to toggle source
# File lib/healtcheck_proxy_client/client.rb, line 12 def self.ping(configuration:, healthcheck:) new(configuration: configuration, healthcheck: healthcheck).ping end
Public Instance Methods
ping()
click to toggle source
# File lib/healtcheck_proxy_client/client.rb, line 16 def ping validate_response(Faraday.get(url)) rescue Faraday::Error => e raise HttpError.new(e.message, http_error: e) end
Private Instance Methods
url()
click to toggle source
# File lib/healtcheck_proxy_client/client.rb, line 26 def url "#{endpoint}/checks/#{@healthcheck}/ping?token=#{api_key}" end
validate_response(response)
click to toggle source
# File lib/healtcheck_proxy_client/client.rb, line 30 def validate_response(response) return response if response.status == 200 raise HttpError.new( "Invalid HTTP Status code: #{response.status}", http_error: response ) end