Class: MoesifApi::UserModel
- Defined in:
- lib/moesif_api/models/user_model.rb
Instance Attribute Summary collapse
-
#campaign ⇒ CampaignModel
campaign object.
-
#company_id ⇒ String
company id associated with the user if avaialble.
-
#ip_address ⇒ String
ip address associated with user if avaialble.
-
#metadata ⇒ Object
meta data.
-
#modified_time ⇒ DateTime
Time when modification was made.
-
#session_token ⇒ String
session token associated with user if avaialble.
-
#user_agent_string ⇒ String
Optionally tag the user with an user agent.
-
#user_id ⇒ String
user id of the user.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#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
constructor
A new instance of UserModel.
Methods inherited from BaseModel
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
#campaign ⇒ CampaignModel
campaign object
37 38 39 |
# File 'lib/moesif_api/models/user_model.rb', line 37 def campaign @campaign end |
#company_id ⇒ String
company id associated with the user if avaialble.
13 14 15 |
# File 'lib/moesif_api/models/user_model.rb', line 13 def company_id @company_id end |
#ip_address ⇒ String
ip address associated with user if avaialble.
21 22 23 |
# File 'lib/moesif_api/models/user_model.rb', line 21 def ip_address @ip_address end |
#metadata ⇒ Object
meta data
33 34 35 |
# File 'lib/moesif_api/models/user_model.rb', line 33 def @metadata end |
#modified_time ⇒ DateTime
Time when modification was made. default to current time on server side.
17 18 19 |
# File 'lib/moesif_api/models/user_model.rb', line 17 def modified_time @modified_time end |
#session_token ⇒ String
session token associated with user if avaialble.
25 26 27 |
# File 'lib/moesif_api/models/user_model.rb', line 25 def session_token @session_token end |
#user_agent_string ⇒ String
Optionally tag the user with an user agent.
29 30 31 |
# File 'lib/moesif_api/models/user_model.rb', line 29 def user_agent_string @user_agent_string end |
#user_id ⇒ String
user id of the user
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 |
.names ⇒ Object
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 |