Class: Trello::Member

Inherits:
BasicData show all
Includes:
HasActions
Defined in:
lib/trello/member.rb

Overview

A Member is a user of the Trello service.

Instance Attribute Summary

Attributes inherited from BasicData

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods included from HasActions

#actions

Methods inherited from BasicData

#==, client, create, #initialize, many, one, parse, parse_many, path_name, #refresh!, register_attributes, save

Constructor Details

This class inherits a constructor from Trello::BasicData

Class Method Details

.find(id_or_username, params = {}) ⇒ Object

Finds a user

The argument may be specified as either an id or a username.



15
16
17
# File 'lib/trello/member.rb', line 15

def find(id_or_username, params = {})
  client.find(:member, id_or_username, params)
end

Instance Method Details

#avatar_url(options = { :size => :large }) ⇒ Object

Retrieve a URL to the avatar.

Valid values for options are:

:large (170x170)
:small (30x30)


41
42
43
44
# File 'lib/trello/member.rb', line 41

def avatar_url(options = { :size => :large })
  size = options[:size] == :small ? 30 : 170
  "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
end

#request_prefixObject

:nodoc:



91
92
93
# File 'lib/trello/member.rb', line 91

def request_prefix
  "/members/#{id}"
end

#saveObject



76
77
78
79
80
81
# File 'lib/trello/member.rb', line 76

def save
  @previously_changed = changes
  @changed_attributes.clear

  return update! if id
end

#update!Object



83
84
85
86
87
88
# File 'lib/trello/member.rb', line 83

def update!
  client.put(request_prefix, {
    :fullName => full_name,
    :bio      => bio
  }).json_into(self)
end

#update_fields(fields) ⇒ Object

Update the fields of a member.

Supply a hash of string keyed data retrieved from the Trello API representing an Member.



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/trello/member.rb', line 24

def update_fields(fields)
  attributes[:id]        = fields['id']
  attributes[:full_name] = fields['fullName']
  attributes[:email]     = fields['email']
  attributes[:username]  = fields['username']
  attributes[:initials]  = fields['initials']
  attributes[:avatar_id] = fields['avatarHash']
  attributes[:bio]       = fields['bio']
  attributes[:url]       = fields['url']
  self
end