Sha256: 21ae23bd609330f362fb530b84416f34a148936e2234572ac7894a4410af0c22

Contents?: true

Size: 1.3 KB

Versions: 35

Compression:

Stored size: 1.3 KB

Contents

class Flickr::Contacts < Flickr::Base
  def initialize(flickr)
    @flickr = flickr
  end

  # Get a user's public contact list.
  # 
  # Params
  # * id (Required)
  #     the nsid of the user to get information for
  # 
  def get_public_list(id, options={})
    options.merge!({:user_id => id})
    rsp = @flickr.send_request('flickr.contacts.getPublicList', options)
    collect_contacts(rsp)
  end
    
  
  # Get the authorized user's contact list.
  # 
  def get_list(options={})
    rsp = @flickr.send_request('flickr.contacts.getList', options)
    collect_contacts(rsp)
  end
  
  
  protected
  def collect_contacts(rsp)
    contacts = []
    return contacts unless rsp
    if rsp.contacts.contact
      rsp.contacts.contact.each do |contact|
        attributes = create_attributes(contact)
        contacts << Contact.new(attributes)
      end
    end
    return contacts
  end
  
  def create_attributes(contact)
    {
      :nsid => contact[:nsid], 
      :path_alias => contact[:path_alias],
      :username => contact[:username],
      :iconfarm => contact[:iconfarm],
      :iconserver => contact[:iconserver],
      :ignored => contact[:ignored],
      :friend => contact[:friend],
      :family => contact[:family],
      :realname => contact[:realname],
      :location => contact[:location]
     }
  end
  
end

Version data entries

35 entries across 35 versions & 11 rubygems

Version Path
flickr_fu-0.3.4 lib/flickr/contacts.rb
flickr_fu-0.3.3 lib/flickr/contacts.rb
ayn-flickr_fu-0.3.5 lib/flickr/contacts.rb
ayn-flickr_fu-0.3.6 lib/flickr/contacts.rb
ayn-flickr_fu-0.3.7 lib/flickr/contacts.rb
ayn-flickr_fu-0.3.9 lib/flickr/contacts.rb
commonthread-flickr_fu-0.3.0 lib/flickr/contacts.rb
maciej-flickr_fu-0.3.0 lib/flickr/contacts.rb
rmm5t-flickr_fu-0.3.1 lib/flickr/contacts.rb
rschenk-flickr_fu-0.3.2 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.13 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.11 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.10 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.9 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.8 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.7 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.6 lib/flickr/contacts.rb
flickr_fu-0.3.2 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.4 lib/flickr/contacts.rb
fotonauts-flickr_fu-0.3.3 lib/flickr/contacts.rb