Class: Flickr::People

Inherits:
APIBase show all
Defined in:
lib/flickr/people.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

#findByEmail(find_email) ⇒ Object



4
5
6
7
8
9
# File 'lib/flickr/people.rb', line 4

def findByEmail(find_email)
	res = @flickr.call_method('flickr.people.findByEmail',
		'find_email' => find_email)
	p = Flickr::Person.from_xml(res,@flickr)
	return p
end

#findByUsername(username) ⇒ Object



11
12
13
14
15
16
# File 'lib/flickr/people.rb', line 11

def findByUsername(username)
	res = @flickr.call_method('flickr.people.findByUsername',
		'username' => username)
	p = Flickr::Person.from_xml(res,@flickr)
	return p
end

#getInfo(user) ⇒ Object

user can be a Person or an nsid



19
20
21
22
23
24
25
# File 'lib/flickr/people.rb', line 19

def getInfo(user)
	user = user.nsid if user.class == Flickr::Person
	res = @flickr.call_method('flickr.people.getInfo',
			'user_id'=>user)
	person = Flickr::Person.from_xml(res,@flickr)
	return person
end

#getPublicGroups(user) ⇒ Object

user can be a Person or an nsid



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

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

		g = @flickr.group_cache_lookup(nsid) ||
			Flickr::Group.new(@flickr,nsid)

		g.name = att['name']
		g.eighteenplus = att['eighteenplus'].to_i == 1

		@flickr.group_cache_store(g)
		list << g
	end
	return list
end

#getPublicPhotos(user, extras = nil, per_page = nil, page = nil) ⇒ Object



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

def getPublicPhotos(user,extras=nil,per_page=nil,page=nil)
	args = {}

	user = user.nsid if user.class == Flickr::Person

	args['user_id'] = user if user
	args['extras'] = extras.join(',') if extras.class == Array
	args['per_page'] = per_page if per_page
	args['page'] = page if page

	res = @flickr.call_method('flickr.people.getPublicPhotos',args)
	att = res.root.attributes
	list = Flickr::PhotoList.new(att['page'].to_i,att['pages'].to_i,
		att['perpage'].to_i,att['total'].to_i)
	res.elements['/photos'].each_element do |e|
		list << Flickr::Photo.from_xml(e,@flickr)
	end
	return list
end

#getUploadStatus(user) ⇒ Object

user can be a Person or an nsid



72
73
74
75
76
77
78
# File 'lib/flickr/people.rb', line 72

def getUploadStatus(user)
	user = user.nsid if user.class == Flickr::Person
	res = @flickr.call_method('flickr.people.getUploadStatus',
			'user_id'=>user)
	person = Flickr::Person.from_xml(res,@flickr)
	return person
end