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 collapse

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

Instance Attribute Details

#avatar_idString (readonly)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

#bioString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

#emailString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

#full_nameString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

#idString (readonly)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

#initialsString

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

#urlString (readonly)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

#usernameString (readonly)

Returns:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/trello/member.rb', line 20

class Member < BasicData
  register_attributes :id, :username, :email, :full_name, :initials, :avatar_id, :bio, :url, readonly: [ :id, :username, :avatar_id, :url ]
  validates_presence_of :id, :username
  validates_length_of   :full_name, minimum: 4
  validates_length_of   :bio,       maximum: 16384

  include HasActions

  class << self
    # Finds a user
    #
    # The argument may be specified as either an _id_ or a _username_.
    def find(id_or_username, params = {})
      client.find(:member, id_or_username, params)
    end
  end

  # Update the fields of a member.
  #
  # Supply a hash of string keyed data retrieved from the Trello API representing
  # an Member.
  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

  # Retrieve a URL to the avatar.
  #
  # Valid values for options are:
  #   :large (170x170)
  #   :small (30x30)
  def avatar_url(options = { size: :large })
    size = options[:size] == :small ? 30 : 170
    "https://trello-avatars.s3.amazonaws.com/#{avatar_id}/#{size}.png"
  end

  # Returns a list of the boards a member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :organization, :public, :open, :closed, :all ] # default: :all
  # i.e.,
  #    me.boards(:filter => :closed) # retrieves all closed boards
  many :boards, filter: :all

  # Returns a list of cards the member is assigned to.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #    :filter => [ :none, :open, :closed, :all ] # default :open
  # i.e.,
  #    me.cards(:filter => :closed) # retrieves all closed cards
  many :cards, filter: :open

  # Returns a list of the organizations this member is a part of.
  #
  # This method, when called, can take a hash table with a filter key containing any
  # of the following values:
  #   :filter => [ :none, :members, :public, :all ] # default: all
  # i.e.,
  #    me.organizations(:filter => :public) # retrieves all public organizations
  many :organizations, filter: :all

  # Returns a list of notifications for the user
  many :notifications

  def save
    @previously_changed = changes
    @changed_attributes.clear

    return update! if id
  end

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

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

Class Method Details

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

Finds a user

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



32
33
34
# File 'lib/trello/member.rb', line 32

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)


58
59
60
61
# File 'lib/trello/member.rb', line 58

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:



108
109
110
# File 'lib/trello/member.rb', line 108

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

#saveObject



93
94
95
96
97
98
# File 'lib/trello/member.rb', line 93

def save
  @previously_changed = changes
  @changed_attributes.clear

  return update! if id
end

#update!Object



100
101
102
103
104
105
# File 'lib/trello/member.rb', line 100

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.



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/trello/member.rb', line 41

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