Class: Flickr::User
Overview
Todo: logged_in? if logged in: flickr.blogs.getList flickr.favorites.add flickr.favorites.remove flickr.groups.browse flickr.photos.getCounts flickr.photos.getNotInSet flickr.photos.getUntagged flickr.photosets.create flickr.photosets.orderSets flickr.tags.getListUserPopular flickr.test.login uploading
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#firstdate ⇒ Object
readonly
Returns the value of attribute firstdate.
-
#firstdatetaken ⇒ Object
readonly
Returns the value of attribute firstdatetaken.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#photos_url ⇒ Object
readonly
Builds url for user’s photos page as per www.flickr.com/services/api/misc.urls.html.
-
#url ⇒ Object
readonly
Builds url for user’s profile page as per www.flickr.com/services/api/misc.urls.html.
Instance Method Summary collapse
-
#contacts ⇒ Object
Implements flickr.contacts.getPublicList and flickr.contacts.getList.
-
#contactsPhotos ⇒ Object
Implements flickr.photos.getContactsPublicPhotos and flickr.photos.getContactsPhotos.
-
#favorites ⇒ Object
Implements flickr.favorites.getPublicList.
-
#groups ⇒ Object
Implements flickr.people.getPublicGroups.
-
#initialize(id_or_params_hash = nil, username = nil, email = nil, password = nil, api_key = nil) ⇒ User
constructor
A Flickr::User can be instantiated in two ways.
-
#photos(options = {}) ⇒ Object
Implements flickr.people.getPublicPhotos.
-
#photosets ⇒ Object
Implements flickr.photosets.getList.
- #pretty_url ⇒ Object
-
#tag(tag) ⇒ Object
Gets photos with a given tag.
-
#tags ⇒ Object
Implements flickr.tags.getListUser.
- #to_s ⇒ Object
- #username ⇒ Object
Constructor Details
#initialize(id_or_params_hash = nil, username = nil, email = nil, password = nil, api_key = nil) ⇒ User
A Flickr::User can be instantiated in two ways. The old (deprecated) method is with an ordered series of values. The new method is with a params Hash, which is easier when a variable number of params are supplied, which is the case here, and also avoids having to constantly supply nil values for the email and password, which are now irrelevant as authentication is no longer done this way. An associated flickr client will also be generated if an api key is passed among the arguments or in the params hash. Alternatively, and most likely, an existing client object may be passed in the params hash (e.g. ‘client’ => some_existing_flickr_client_object), and this is what happends when users are initlialized as the result of a method called on the flickr client (e.g. flickr.users)
269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 269 def initialize(id_or_params_hash=nil, username=nil, email=nil, password=nil, api_key=nil) if id_or_params_hash.is_a?(Hash) id_or_params_hash.each { |k,v| self.instance_variable_set("@#{k}", v) } # convert extra_params into instance variables else @id = id_or_params_hash @username = username @email = email @password = password @api_key = api_key end @client ||= Flickr.new('api_key' => @api_key, 'shared_secret' => @shared_secret, 'auth_token' => @auth_token) if @api_key @client.login(@email, @password) if @email and @password # this is now irrelevant as Flickr API no longer supports authentication this way end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
255 256 257 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 255 def client @client end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
255 256 257 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 255 def count @count end |
#firstdate ⇒ Object (readonly)
Returns the value of attribute firstdate.
255 256 257 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 255 def firstdate @firstdate end |
#firstdatetaken ⇒ Object (readonly)
Returns the value of attribute firstdatetaken.
255 256 257 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 255 def firstdatetaken @firstdatetaken end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
255 256 257 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 255 def id @id end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
255 256 257 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 255 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
255 256 257 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 255 def name @name end |
#photos_url ⇒ Object (readonly)
Builds url for user’s photos page as per www.flickr.com/services/api/misc.urls.html
304 305 306 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 304 def photos_url @photos_url end |
#url ⇒ Object (readonly)
Builds url for user’s profile page as per www.flickr.com/services/api/misc.urls.html
310 311 312 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 310 def url @url end |
Instance Method Details
#contacts ⇒ Object
Implements flickr.contacts.getPublicList and flickr.contacts.getList
342 343 344 345 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 342 def contacts @client.contacts_getPublicList('user_id'=>@id)['contacts']['contact'].collect { |contact| User.new(contact['nsid'], contact['username'], nil, nil, @api_key) } #or end |
#contactsPhotos ⇒ Object
Implements flickr.photos.getContactsPublicPhotos and flickr.photos.getContactsPhotos
363 364 365 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 363 def contactsPhotos @client.photos_request('photos.getContactsPublicPhotos', 'user_id' => @id) end |
#favorites ⇒ Object
Implements flickr.favorites.getPublicList
348 349 350 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 348 def favorites @client.photos_request('favorites.getPublicList', 'user_id' => @id) end |
#groups ⇒ Object
Implements flickr.people.getPublicGroups
319 320 321 322 323 324 325 326 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 319 def groups collection = @client.people_getPublicGroups('user_id'=>@id)['groups']['group'] collection = [collection] if collection.is_a? Hash collection.collect { |group| Group.new( "id" => group['nsid'], "name" => group['name'], "eighteenplus" => group['eighteenplus'], "client" => @client) } end |
#photos(options = {}) ⇒ Object
Implements flickr.people.getPublicPhotos. Options hash allows you to add extra restrictions as per flickr.people.getPublicPhotos docs, e.g. user.photos(‘per_page’ => ‘25’, ‘extras’ => ‘date_taken’)
331 332 333 334 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 331 def photos(={}) @client.photos_request('people.getPublicPhotos', {'user_id' => @id}.merge()) # what about non-public photos? end |
#photosets ⇒ Object
Implements flickr.photosets.getList
353 354 355 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 353 def photosets @client.photosets_getList('user_id'=>@id)['photosets']['photoset'].collect { |photoset| Photoset.new(photoset['id'], @api_key) } end |
#pretty_url ⇒ Object
314 315 316 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 314 def pretty_url @pretty_url ||= @client.urls_getUserProfile('user_id'=>@id)['user']['url'] end |
#tag(tag) ⇒ Object
Gets photos with a given tag
337 338 339 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 337 def tag(tag) @client.photos('user_id'=>@id, 'tags'=>tag) end |
#tags ⇒ Object
Implements flickr.tags.getListUser
358 359 360 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 358 def @client.('user_id'=>@id)['who']['tags']['tag'].collect { |tag| tag } end |
#to_s ⇒ Object
367 368 369 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 367 def to_s @name end |
#username ⇒ Object
283 284 285 |
# File 'lib/acts_as_unvlogable/flickr.rb', line 283 def username @username.nil? ? getInfo.username : @username end |