Class: MoesifApi::EventModel

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#clean_str, #to_hash, #to_json

Constructor Details

#initialize(request = nil, response = nil, session_token = nil, tags = nil, user_id = nil, company_id = nil, metadata = nil, direction = nil, weight = nil, blocked_by = nil) ⇒ EventModel

Returns a new instance of EventModel.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/moesif_api/models/event_model.rb', line 61

def initialize(request = nil,
               response = nil,
               session_token = nil,
               tags = nil,
               user_id = nil,
               company_id = nil,
                = nil,
               direction = nil,
               weight = nil,
               blocked_by = nil)
  @request = request
  @response = response
  @session_token = session_token
  @tags = tags
  @user_id = user_id
  @company_id = company_id
  @metadata = 
  @direction = direction
  @weight = weight
  @blocked_by = blocked_by
end

Instance Attribute Details

#blocked_byInteger

Blocked by in case of governance rule of an API call

Returns:

  • (Integer)


41
42
43
# File 'lib/moesif_api/models/event_model.rb', line 41

def blocked_by
  @blocked_by
end

#company_idString

company_id string

Returns:



25
26
27
# File 'lib/moesif_api/models/event_model.rb', line 25

def company_id
  @company_id
end

#directionString

direction string

Returns:



33
34
35
# File 'lib/moesif_api/models/event_model.rb', line 33

def direction
  @direction
end

#metadataHash

metadata

Returns:

  • (Hash)


29
30
31
# File 'lib/moesif_api/models/event_model.rb', line 29

def 
  @metadata
end

#requestEventRequestModel

API request object

Returns:



5
6
7
# File 'lib/moesif_api/models/event_model.rb', line 5

def request
  @request
end

#responseEventResponseModel

API response Object

Returns:



9
10
11
# File 'lib/moesif_api/models/event_model.rb', line 9

def response
  @response
end

#session_tokenString

End user’s auth/session token

Returns:



13
14
15
# File 'lib/moesif_api/models/event_model.rb', line 13

def session_token
  @session_token
end

#tagsString

comma separated list of tags, see documentation

Returns:



17
18
19
# File 'lib/moesif_api/models/event_model.rb', line 17

def tags
  @tags
end

#user_idString

End user’s user_id string from your app

Returns:



21
22
23
# File 'lib/moesif_api/models/event_model.rb', line 21

def user_id
  @user_id
end

#weightInteger

Weight of an API call

Returns:

  • (Integer)


37
38
39
# File 'lib/moesif_api/models/event_model.rb', line 37

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/moesif_api/models/event_model.rb', line 84

def self.from_hash(hash)
  if hash.nil?
    nil
  else
    # Extract variables from the hash
    request = EventRequestModel.from_hash(hash['request']) if hash['request']
    response = EventResponseModel.from_hash(hash['response']) if hash['response']
    session_token = hash['session_token']
    tags = hash['tags']
    user_id = hash['user_id']
    company_id = hash['company_id']
     = hash['metadata']
    direction = hash['direction']
    weight = hash['weight']
    blocked_by = hash['blocked_by']

    # Create object from extracted values
    EventModel.new(request,
                   response,
                   session_token,
                   tags,
                   user_id,
                   company_id,
                   ,
                   direction,
                   weight,
                   blocked_by)
  end
end

.namesObject

A mapping from model property names to API property names



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/moesif_api/models/event_model.rb', line 44

def self.names
  if @hash.nil?
    @hash = {}
    @hash['request'] = 'request'
    @hash['response'] = 'response'
    @hash['session_token'] = 'session_token'
    @hash['tags'] = 'tags'
    @hash['user_id'] = 'user_id'
    @hash['company_id'] = 'company_id'
    @hash['metadata'] = 'metadata'
    @hash['direction'] = 'direction'
    @hash['weight'] = 'weight'
    @hash['blocked_by'] = 'blocked_by'
  end
  @hash
end