Loop/Architecture/Address Book: Difference between revisions

Line 92: Line 92:
=== Gmail ===
=== Gmail ===
The current plan is to use the [https://developers.google.com/google-apps/contacts/v3/ Google Contacts API, v3] to retrieve contacts from users' gmail accounts. Ideally, we can re-use some, most, or all of the [https://github.com/mozilla-b2g/gaia/blob/master/shared/js/contacts/import/gmail/gmail_connector.js Gaia Gmail Connector code] to expedite this importation.
The current plan is to use the [https://developers.google.com/google-apps/contacts/v3/ Google Contacts API, v3] to retrieve contacts from users' gmail accounts. Ideally, we can re-use some, most, or all of the [https://github.com/mozilla-b2g/gaia/blob/master/shared/js/contacts/import/gmail/gmail_connector.js Gaia Gmail Connector code] to expedite this importation.
Functionally, the steps involved here are:
# Retrieve OAUTH2 token for user (see [https://developers.google.com/google-apps/contacts/v3/#authorizing_requests_to_the_api_name_service "Authorizing requests to the Google Contacts API service" in the Google Contacts API])
# Retrieve the group id for the "Contacts" group from https://www.google.com/m8/feeds/groups/default/full/ (see [https://developers.google.com/google-apps/contacts/v3/#retrieving_all_contact_groups "Retreiving all Contact Groups"]).
# Retrieve the list of users in the "Contacts" group from https://www.google.com/m8/feeds/contacts/default/full/?max-results=''maxResults''&group=''groupId'', where groupId is the value retrieved in the previous step. The value of maxResults should be large enough to accommodate users' address books -- the mobile implementation uses 10,000.
# For each contact in the result:
#* Translate the result into a contact object according the the table below. Note that some data may require manipulation to convert between the gmail format and the field described in mozContacts.
#* Store the result in the database (ensuring that it replaces any entries with the same ID).
#* Fire a callback to allow the UI to update. The callback should include the number of total contacts being imported, the number of contacts already imported (from this import), and the "id" field of the contact that was just imported.


{| class="wikitable"
{| class="wikitable"
Confirmed users
632

edits