Sha256: b62e428513d266ce78039e614b776d38e2b8e1b880e39335ea29136fd3fd36bf

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

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 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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lifen-1.1.0 lib/lifen/user.rb
lifen-1.0.2 lib/lifen/user.rb
lifen-1.0.1 lib/lifen/user.rb