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

#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) ⇒ EventModel

Returns a new instance of EventModel.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/moesif_api/models/event_model.rb', line 58

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

Instance Attribute Details

#company_idString

company_id string

Returns:



27
28
29
# File 'lib/moesif_api/models/event_model.rb', line 27

def company_id
  @company_id
end

#directionString

direction string

Returns:



35
36
37
# File 'lib/moesif_api/models/event_model.rb', line 35

def direction
  @direction
end

#metadataHash

metadata

Returns:

  • (Hash)


31
32
33
# File 'lib/moesif_api/models/event_model.rb', line 31

def 
  
end

#requestEventRequestModel

API request object

Returns:



7
8
9
# File 'lib/moesif_api/models/event_model.rb', line 7

def request
  @request
end

#responseEventResponseModel

API response Object

Returns:



11
12
13
# File 'lib/moesif_api/models/event_model.rb', line 11

def response
  @response
end

#session_tokenString

End user’s auth/session token

Returns:



15
16
17
# File 'lib/moesif_api/models/event_model.rb', line 15

def session_token
  @session_token
end

#tagsString

comma separated list of tags, see documentation

Returns:



19
20
21
# File 'lib/moesif_api/models/event_model.rb', line 19

def tags
  @tags
end

#user_idString

End user’s user_id string from your app

Returns:



23
24
25
# File 'lib/moesif_api/models/event_model.rb', line 23

def user_id
  @user_id
end

#weightInteger

Weight of an API call

Returns:

  • (Integer)


39
40
41
# File 'lib/moesif_api/models/event_model.rb', line 39

def weight
  @weight
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/moesif_api/models/event_model.rb', line 79

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"]

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

.namesObject

A mapping from model property names to API property names



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

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"
  end
  @hash
end