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



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

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



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/flickr/contacts.rb', line 50

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(nsid,att['username'])

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