Class: MoesifApi::EventRequestModel

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/moesif_api/models/event_request_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, uri = nil, verb = nil, headers = nil, api_version = nil, ip_address = nil, body = nil, transfer_encoding = nil) ⇒ EventRequestModel

Returns a new instance of EventRequestModel.



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

def initialize(time = nil,
               uri = nil,
               verb = nil,
               headers = nil,
               api_version = nil,
               ip_address = nil,
               body = nil,
               transfer_encoding = nil)
  @time = time
  @uri = uri
  @verb = verb
  @headers = headers
  @api_version = api_version
  @ip_address = ip_address
  @body = body
  @transfer_encoding = transfer_encoding
end

Instance Attribute Details

#api_versionString

Optionally tag the call with your API or App version

Returns:



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

def api_version
  @api_version
end

#bodyObject

Request body

Returns:

  • (Object)


32
33
34
# File 'lib/moesif_api/models/event_request_model.rb', line 32

def body
  @body
end

#headersObject

Key/Value map of request headers

Returns:

  • (Object)


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

def headers
  @headers
end

#ip_addressString

IP Address of the client if known.

Returns:



28
29
30
# File 'lib/moesif_api/models/event_request_model.rb', line 28

def ip_address
  @ip_address
end

#timeDateTime

Time when request was made

Returns:

  • (DateTime)


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

def time
  @time
end

#transfer_encodingString

Transfer Encoding of body if other than JSON

Returns:



36
37
38
# File 'lib/moesif_api/models/event_request_model.rb', line 36

def transfer_encoding
  @transfer_encoding
end

#uriString

full uri of request such as www.example.com/my_path?param=1

Returns:



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

def uri
  @uri
end

#verbString

verb of the API request such as GET or POST

Returns:



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

def verb
  @verb
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/moesif_api/models/event_request_model.rb', line 73

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

    # Create object from extracted values
    EventRequestModel.new(time,
                          uri,
                          verb,
                          headers,
                          api_version,
                          ip_address,
                          body,
                          transfer_encoding)
  end
end

.namesObject

A mapping from model property names to API property names



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

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