Class: PortableContacts::Client
- Inherits:
-
Object
- Object
- PortableContacts::Client
- Defined in:
- lib/portable_contacts.rb
Overview
This is the main PortableContacts Client.
query options
The library supports the various filter and sorting parameters. The format of this may change for this library, so limit use to : :count and :start_index for now.
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
-
#all(options = {}) ⇒ Object
Returns the contacts of the user.
-
#find(id, options = {}) ⇒ Object
Returns the full contact infor for a particular userid.
-
#initialize(base_url, access_token) ⇒ Client
constructor
First parameter is the portable contacts base_url.
-
#me(options = {}) ⇒ Object
Returns the AccessToken users contact details.
Constructor Details
#initialize(base_url, access_token) ⇒ Client
First parameter is the portable contacts base_url. Find this on your PortableContact providers documentation or through XRDS.
-
Google’s is www-opensocial.googleusercontent.com/api/people
The second parameter is an OAuth::AccessToken instantiated for the provider.
29 30 31 32 |
# File 'lib/portable_contacts.rb', line 29 def initialize(base_url, access_token) @base_url = base_url @access_token = access_token end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
20 21 22 |
# File 'lib/portable_contacts.rb', line 20 def base_url @base_url end |
Instance Method Details
#all(options = {}) ⇒ Object
Returns the contacts of the user. It defaults to all fields and 100 entries
@contacts = @client.all # return 100 contacts
@contacts = @client.all :count=>10 # return 10 contacts
@contacts = @client.all :count=>10, :start_index=>10 # returns the second page of 10 contacts
puts @contacts.total_entries # returns the total amount of contacts on the server
Returns a PortableContacts::Collection which is a subclass of Array
48 49 50 |
# File 'lib/portable_contacts.rb', line 48 def all(={}) collection(get("/@me/@all", .reverse_merge(:fields => :all, :count => 100))) end |
#find(id, options = {}) ⇒ Object
Returns the full contact infor for a particular userid. TODO This is not tested well Returns an PortableContacts::Person object
54 55 56 |
# File 'lib/portable_contacts.rb', line 54 def find(id, ={}) single(get("/@me/@all/#{id}", .reverse_merge(:fields => :all))) end |
#me(options = {}) ⇒ Object
Returns the AccessToken users contact details. Note this requests all fields from provider Returns an PortableContacts::Person object
36 37 38 |
# File 'lib/portable_contacts.rb', line 36 def me(={}) single(get("/@me/@self", .reverse_merge(:fields => :all))) end |