Class: MoesifApi::ResponseModel

Inherits:
BaseModel show all
Defined in:
lib/moesif_api/models/event_response_model.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(time = nil, status = nil, headers = nil, body = nil, ip_address = nil) ⇒ ResponseModel

Returns a new instance of ResponseModel.



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/moesif_api/models/event_response_model.rb', line 39

def initialize(time = nil,
               status = nil,
               headers = nil,
               body = nil,
               ip_address = nil)
  @time = time
  @status = status
  @headers = headers
  @body = body
  @ip_address = ip_address
end

Instance Attribute Details

#bodyObject

Response body

Returns:

  • (Object)


20
21
22
# File 'lib/moesif_api/models/event_response_model.rb', line 20

def body
  @body
end

#headersObject

Key/Value map of response headers

Returns:

  • (Object)


16
17
18
# File 'lib/moesif_api/models/event_response_model.rb', line 16

def headers
  @headers
end

#ip_addressString

IP Address from the response, such as the server IP Address

Returns:



24
25
26
# File 'lib/moesif_api/models/event_response_model.rb', line 24

def ip_address
  @ip_address
end

#statusInteger

HTTP Status code such as 200

Returns:

  • (Integer)


12
13
14
# File 'lib/moesif_api/models/event_response_model.rb', line 12

def status
  @status
end

#timeDateTime

Time when response received

Returns:

  • (DateTime)


8
9
10
# File 'lib/moesif_api/models/event_response_model.rb', line 8

def time
  @time
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/moesif_api/models/event_response_model.rb', line 52

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash
    time = DateTime.iso8601(hash["time"]) if hash["time"]
    status = hash["status"]
    headers = hash["headers"]
    body = hash["body"]
    ip_address = hash["ip_address"]

    # Create object from extracted values
    ResponseModel.new(time,
                                 status,
                                 headers,
                                 body,
                                 ip_address)
  end
end

.namesObject

A mapping from model property names to API property names



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/moesif_api/models/event_response_model.rb', line 27

def self.names
  if @hash.nil?
    @hash = {}
    @hash["time"] = "time"
    @hash["status"] = "status"
    @hash["headers"] = "headers"
    @hash["body"] = "body"
    @hash["ip_address"] = "ip_address"
  end
  @hash
end