Sha256: c4472bf73688cbb4e5b2906ef3f823f69bb99f321a663ba0be80daab3196b63a

Contents?: true

Size: 922 Bytes

Versions: 4

Compression:

Stored size: 922 Bytes

Contents

module Lifen
  class User < Base

    attribute :uuid, String
    attribute :token, String

    attribute :email, String
    attribute :last_name, String
    attribute :first_name, String
    attribute :unread_messages, Integer, default: 0

    def flows
      Lifen::Flows.new(self).all
    end

    def create!
      authentication = Lifen::Authentication.new(user: self)
      authentication.register!

      self.token = authentication.token
      self.uuid = authentication.uuid

      self
    end

    def refresh_token
      authentication = Lifen::Authentication.new(user: self)
      authentication.refresh_token

      self.token = authentication.token

      self
    end

    def refresh_unread_messages
      status = Lifen::Status.new(user: self)
      status.refresh

      self.unread_messages = status.unread

      self
    end

    def client
      UserAuthenticatedClient.new(token)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lifen-0.2.1 lib/lifen/user.rb
lifen-0.2.0 lib/lifen/user.rb
lifen-0.1.5 lib/lifen/user.rb
lifen-0.1.4 lib/lifen/user.rb