class Lifen::User
Public Class Methods
find(uuid)
click to toggle source
# File lib/lifen/user.rb, line 48 def self.find(uuid) json = application_client.get("docbook/api/thirdParty/person/#{uuid}") json[:uuid] = json["uuid"] json[:email] = json["emailAddress"] json[:first_name] = json["firstName"] json[:last_name] = json["lastName"] json[:profile_picture_url] = json["profilePicUrl"] new(json) end
Private Class Methods
application_client()
click to toggle source
# File lib/lifen/user.rb, line 110 def self.application_client @application_client ||= AppAuthenticatedClient.new end
Public Instance Methods
client()
click to toggle source
# File lib/lifen/user.rb, line 99 def client UserAuthenticatedClient.new(token) end
create(persisted_lifen_uuid: ->(user) {}
click to toggle source
# File lib/lifen/user.rb, line 23 def create(persisted_lifen_uuid: ->(user) {}, save_to_db: ->(user) {}) params = {emailAddress: email, lastName: last_name, firstName: first_name, profilePicUrl: profile_picture_url} @@create_lock.synchronize do exisiting_uuid = persisted_lifen_uuid.call(self) if exisiting_uuid.nil? json = application_client.post("authentication/api/register/third_party", params) self.uuid = json["accountUuid"] else self.uuid = exisiting_uuid end save_to_db.call(self) end end
flows()
click to toggle source
# File lib/lifen/user.rb, line 19 def flows Lifen::Flows.new(user: self).all end
reload()
click to toggle source
# File lib/lifen/user.rb, line 60 def reload self.class.find(uuid) end
save()
click to toggle source
# File lib/lifen/user.rb, line 64 def save params = {emailAddress: email, lastName: last_name, firstName: first_name, profilePicUrl: profile_picture_url} params[:uuid] = uuid json = application_client.put("docbook/api/thirdParty/person/", params) self.email = json["emailAddress"] self.first_name = json["firstName"] self.last_name = json["lastName"] self.profile_picture_url = json["profilePicUrl"] self end
settings()
click to toggle source
# File lib/lifen/user.rb, line 95 def settings @settings ||= Lifen::Settings.new(user: self).reload end
status()
click to toggle source
# File lib/lifen/user.rb, line 91 def status @status ||= Lifen::Status.new(user: self).reload end
token()
click to toggle source
# File lib/lifen/user.rb, line 82 def token @token ||= Lifen::Token.new(user: self) end
token=(token)
click to toggle source
# File lib/lifen/user.rb, line 86 def token=(token) token.user = self @token = token end
unread_messages()
click to toggle source
# File lib/lifen/user.rb, line 78 def unread_messages status.unread end
Private Instance Methods
application_client()
click to toggle source
# File lib/lifen/user.rb, line 106 def application_client @application_client ||= AppAuthenticatedClient.new end