aliang / google_contacts_api

Google Contacts API for ruby, unofficial
Other
46 stars 26 forks source link

Sort/Order functionality? #22

Closed sarafisherman22 closed 7 years ago

sarafisherman22 commented 7 years ago

hi, I'm loving your gem. Right now, calling contacts returns all of a user's contacts. Ideally, I'd like to get back "Most Contacted or Frequently Contacted" but after researching it appears that is not available via the APIs. The 2nd best idea is to return the contacts sorted by:

query.orderby = 'lastmodified'

Which apparently is the default setting listed here: https://developers.google.com/google-apps/contacts/v3/#retrieving_contacts_using_query_parameters

However, this gem doesn't seem to have any sort order, the ordering appears to be random.

With your gem is it possible to sort or return just the X last modified contacts? Or better yet, per the contact record include a "last_modified" timestamp?

Thank you again for all the work! It's really great and helpful

aliang commented 7 years ago

You should be able to inject the params when calling methods on a GoogleContactsApi::User object. Building on the example in the README:

google_contacts_user = GoogleContactsApi::User.new(oauth_access_token_for_user)
# Using the symbol :orderby might work too since we use with_indifferent_access
contacts = google_contacts_user.contacts('orderby' => 'lastmodified')

should work (but I haven't tested it).

sarafisherman22 commented 7 years ago

That worked great. Thank you!