Class: Fleakr::Objects::Contact

Inherits:
Object
  • Object
show all
Includes:
Support::Object
Defined in:
lib/fleakr/objects/contact.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Support::Object

included

Class Method Details

.find_all(params = {}) ⇒ Object

Retrieve a list of contacts for the currently authenticated user



21
22
23
24
# File 'lib/fleakr/objects/contact.rb', line 21

def self.find_all(params = {})
  response = Fleakr::Api::MethodRequest.with_response!('contacts.getList', params)
  (response.body/'contacts/contact').map {|c| Contact.new(c) }
end

.find_all_by_user_id(user_id) ⇒ Object

Retrieve a list of contacts for the specified user ID and return an initialized collection of User objects



15
16
17
18
# File 'lib/fleakr/objects/contact.rb', line 15

def self.find_all_by_user_id(user_id)
  response = Fleakr::Api::MethodRequest.with_response!('contacts.getPublicList', :user_id => user_id)
  (response.body/'contacts/contact').map {|c| Contact.new(c).to_user }
end

Instance Method Details

#to_userObject

TODO: deprecate in favor of shared behavior as a module



27
28
29
30
31
32
33
34
35
# File 'lib/fleakr/objects/contact.rb', line 27

def to_user # :nodoc:
  user = User.new
  self.class.attributes.each do |attribute|
    attribute_name = attribute.name
    user.send("#{attribute.name}=".to_sym, self.send(attribute.name))
  end

  user
end