module Lifen class User include Virtus.model(finalize: false) attribute :token, "Lifen::Token"#, default: proc { Lifen::Token.new() } attribute :status, "Lifen::Status" attribute :uuid, String attribute :email, String attribute :last_name, String attribute :first_name, String # def initialize(*args) # self.token = Lifen::Token.new(user: self) # self.status = Lifen::Status.new(user: self) # super # end def flows Lifen::Flows.new(user: self).all end def create params = {emailAddress: email, lastName: last_name, firstName: first_name} json = application_client.post("authentication/api/register/third_party", params) self.uuid = json["accountUuid"] end def unread_messages status.unread end def token @token ||= Lifen::Token.new(user: self) end def token=(token) token.user = self @token = token end def status @status ||= Lifen::Status.new(user: self) end def client UserAuthenticatedClient.new(token) end private def application_client @application_client ||= AppAuthenticatedClient.new end end end