Class: MoesifApi::UserModel

Inherits:
BaseModel show all
Defined in:
lib/moesif_api/models/user_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(user_id = nil, company_id = nil, modified_time = nil, ip_address = nil, session_token = nil, user_agent_string = nil, metadata = nil, campaign = nil) ⇒ UserModel

Returns a new instance of UserModel.



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

def initialize(user_id = nil,
               company_id = nil,
               modified_time = nil,
               ip_address = nil,
               session_token = nil,
               user_agent_string = nil,
                = nil,
               campaign = nil)
  @user_id = user_id
  @company_id = company_id
  @modified_time = modified_time
  @ip_address = ip_address
  @session_token = session_token
  @user_agent_string = user_agent_string
  @metadata = 
  @campaign = campaign
end

Instance Attribute Details

#campaignCampaignModel

campaign object

Returns:



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

def campaign
  @campaign
end

#company_idString

company id associated with the user if avaialble.

Returns:



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

def company_id
  @company_id
end

#ip_addressString

ip address associated with user if avaialble.

Returns:



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

def ip_address
  @ip_address
end

#metadataObject

meta data

Returns:

  • (Object)


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

def 
  @metadata
end

#modified_timeDateTime

Time when modification was made. default to current time on server side.

Returns:

  • (DateTime)


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

def modified_time
  @modified_time
end

#session_tokenString

session token associated with user if avaialble.

Returns:



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

def session_token
  @session_token
end

#user_agent_stringString

Optionally tag the user with an user agent.

Returns:



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

def user_agent_string
  @user_agent_string
end

#user_idString

user id of the user

Returns:



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

def user_id
  @user_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash



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

def self.from_hash(hash)
  if hash == nil
    nil
  else
    # Extract variables from the hash
    user_id = hash["user_id"]
    company_id = hash["company_id"]
    modified_time = DateTime.iso8601(hash["modified_time"]) if hash["modified_time"]
    ip_address = hash["ip_address"]
    session_token = hash["session_token"]
    user_agent_string = hash["user_agent_string"]
     = hash["metadata"]
    campaign = CampaignModel.from_hash(hash["campaign"]) if hash["campaign"]

    # Create object from extracted values
    UserModel.new(user_id,
                  company_id,
                  modified_time,
                  ip_address,
                  session_token,
                  user_agent_string,
                  ,
                  campaign)
  end
end

.namesObject

A mapping from model property names to API property names



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

def self.names
  if @hash.nil?
    @hash = {}
    @hash["user_id"] = "user_id"
    @hash["company_id"] = "company_id"
    @hash["modified_time"] = "modified_time"
    @hash["ip_address"] = "ip_address"
    @hash["session_token"] = "session_token"
    @hash["user_agent_string"] = "user_agent_string"
    @hash["metadata"] = "metadata"
    @hash["campaign"] = "campaign"
  end
  @hash
end