Class: Protolink::User

Inherits:
Object
  • Object
show all
Defined in:
lib/protolink/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, attributes = {}) ⇒ User

Returns a new instance of User.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/protolink/user.rb', line 5

def initialize(connection, attributes = {})
  @connection = connection
  @id         = attributes['id']
  @name       = attributes['name']
  @login      = attributes['login']
  @email      = attributes['email']
  @avatar_url = attributes['avatar_url']
  @node_id    = attributes['node_id']
  @external_profile_url = attributes['external_profile_url']
  @communication_token  = attributes['communication_token']
  @loaded     = false
end

Instance Attribute Details

#avatar_urlObject (readonly)

Returns the value of attribute avatar_url.



3
4
5
# File 'lib/protolink/user.rb', line 3

def avatar_url
  @avatar_url
end

#communication_tokenObject (readonly)

Returns the value of attribute communication_token.



3
4
5
# File 'lib/protolink/user.rb', line 3

def communication_token
  @communication_token
end

#emailObject (readonly)

Returns the value of attribute email.



3
4
5
# File 'lib/protolink/user.rb', line 3

def email
  @email
end

#external_profile_urlObject (readonly)

Returns the value of attribute external_profile_url.



3
4
5
# File 'lib/protolink/user.rb', line 3

def external_profile_url
  @external_profile_url
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/protolink/user.rb', line 3

def id
  @id
end

#loginObject (readonly)

Returns the value of attribute login.



3
4
5
# File 'lib/protolink/user.rb', line 3

def 
  @login
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/protolink/user.rb', line 3

def name
  @name
end

#node_idObject (readonly)

Returns the value of attribute node_id.



3
4
5
# File 'lib/protolink/user.rb', line 3

def node_id
  @node_id
end

Instance Method Details

#auth_tokenObject

get token for autologin



19
20
21
# File 'lib/protolink/user.rb', line 19

def auth_token
  connection.get("/api/v1/users/#{self.id}/auth_token.json")["token"]
end

#delete!Object



23
24
25
# File 'lib/protolink/user.rb', line 23

def delete!
  connection.delete("/api/v1/users/#{self.id}")
end