Class: Flickr::Contacts

Inherits:
APIBase show all
Defined in:
lib/flickr/contacts.rb

Instance Attribute Summary

Attributes inherited from APIBase

#flickr

Instance Method Summary collapse

Methods inherited from APIBase

#initialize

Constructor Details

This class inherits a constructor from Flickr::APIBase

Instance Method Details

#getList(filter = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/flickr/contacts.rb', line 4

def getList(filter=nil)
  res = filter ?
  @flickr.call_method('flickr.contacts.getList') :
    @flickr.call_method('flickr.contacts.getList',
                        'filter'=>filter)
  list = []
  res.elements['/contacts'].each_element do |e|
    att = e.attributes
    nsid = att['nsid']

    person = @flickr.person_cache_lookup(nsid)
    person ||= Flickr::Person.new(@flickr,nsid,att['username'])

    person.realname = att['realname']
    person.friend = (att['friend'].to_i == 1)
    person.family = (att['family'].to_i == 1)
    person.ignored = (att['ignored'].to_i == 1)

    list << person

    @flickr.person_cache_store(person)
  end
  return list
end

#getPublicList(user) ⇒ Object

User can be either the NSID String or a Contact



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/flickr/contacts.rb', line 30

def getPublicList(user)
  user = user.nsid if user.class == Flickr::Person
  res = @flickr.call_method('flickr.contacts.getPublicList',
                            'user_id'=>user)
  list = []
  res.elements['/contacts'].each_element do |e|
    att = e.attributes
    nsid = att['nsid']

    person = @flickr.person_cache_lookup(nsid)
    person ||= Flickr::Person.new(@flickr,nsid,att['username'])

    person.ignored = (att['ignored'].to_i == 1)
    @flickr.person_cache_store(person)
    list << person
  end
  return list
end