Class: VerifIP::HealthResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/verifip/models.rb

Overview

Response from the health check endpoint.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ HealthResponse

Returns a new instance of HealthResponse.



96
97
98
99
100
101
102
103
# File 'lib/verifip/models.rb', line 96

def initialize(**kwargs)
  @status         = kwargs.fetch(:status, "")
  @version        = kwargs.fetch(:version, "")
  @data_loaded_at = kwargs.fetch(:data_loaded_at, "")
  @redis          = kwargs.fetch(:redis, "")
  @postgres       = kwargs.fetch(:postgres, "")
  @uptime_seconds = kwargs.fetch(:uptime_seconds, 0)
end

Instance Attribute Details

#data_loaded_atObject (readonly)

Returns the value of attribute data_loaded_at.



94
95
96
# File 'lib/verifip/models.rb', line 94

def data_loaded_at
  @data_loaded_at
end

#postgresObject (readonly)

Returns the value of attribute postgres.



94
95
96
# File 'lib/verifip/models.rb', line 94

def postgres
  @postgres
end

#redisObject (readonly)

Returns the value of attribute redis.



94
95
96
# File 'lib/verifip/models.rb', line 94

def redis
  @redis
end

#statusObject (readonly)

Returns the value of attribute status.



94
95
96
# File 'lib/verifip/models.rb', line 94

def status
  @status
end

#uptime_secondsObject (readonly)

Returns the value of attribute uptime_seconds.



94
95
96
# File 'lib/verifip/models.rb', line 94

def uptime_seconds
  @uptime_seconds
end

#versionObject (readonly)

Returns the value of attribute version.



94
95
96
# File 'lib/verifip/models.rb', line 94

def version
  @version
end

Class Method Details

.from_hash(hash) ⇒ HealthResponse

Build a HealthResponse from a parsed JSON hash.

Parameters:

  • hash (Hash)

    parsed API response

Returns:



109
110
111
112
# File 'lib/verifip/models.rb', line 109

def self.from_hash(hash)
  hash = hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
  new(**hash.slice(:status, :version, :data_loaded_at, :redis, :postgres, :uptime_seconds))
end

Instance Method Details

#inspectObject



115
# File 'lib/verifip/models.rb', line 115

def inspect = to_s

#to_sObject



114
# File 'lib/verifip/models.rb', line 114

def to_s = "HealthResponse(status=#{@status}, version=#{@version})"