npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gmail-contacts

v0.0.2

Published

Client-Side tool for handling oauth2 and retrive contacts using API v3 from Gmail

Downloads

3

Readme

Gcontacts

Client-Side tool for handling oauth2 and retrive contacts using API v3 from Gmail

Try the Demo!

http://eventioz.github.io/gcontacts/

API

namespace

Right now the namespace is Gcontacts and should be reachable from window given the nature of the requests.

Pagination

every function takes pagination as an argument.

you could set:

  • limit: max results per request (default 25)
  • offset: start request from a certain point (default 1)

every response would come back with next and/or previous actions to move between results. Also we attach the total of elements available.

If no pagination is given the default values will be used.

raw

Sometimes, the vanilla result that this library produced it's not enough , don't worry, just sending as last argument true will return a response from the api untouched.

extras

For now the only use for this variable is return useful content like the link of the group that you asked for.

Config

In order to get a valid token and consume this API, you would need an App registered on Google.

Load

(function () {
  var gc   = document.createElement('script')
    , s      = document.getElementsByTagName('script')[0]
  gc.type  = 'text/javascript'
  gc.async = true
  gc.src   = '/js/gcontacts.js'
  gc.onload = function () { Gcontacts._ready() };

  s.parentNode.insertBefore(gc, s);

}())

Ready

when the library is loaded we emmit an event called success.ready.gc avoid depending on third party libraries.

example:

window.document.addEventListener('success.ready.gc', function () {
    // do something with Gcontacts
})

Init

function: init

required arguments:

  • config

This argument holds the particular information related with your app in google user content (https://console.developers.google.com/)

note: an optional parameter could be appended to this object: redirect_uri if this parameter is not provided, the current url will be used.

example:

var config = {
				response_type : 'token',
				client_id     : 'SOME_NUMERIC_ID.apps.googleusercontent.com',
				scope         : 'https://www.google.com/m8/feeds',
				inmediate     : 'true'
			}

Gcontacts.init(config)

Login

function: login

required arguments:

  • callback

example: Gcontacts.login(callback, href)

response: none

Logout

function: logout

example: Gcontacts.logout()

response: none

Contacts

function: contacts

required arguments:

  • callback

example:

Gcontacts.Contacts(callback, pagination, raw)

response:

      {
        status: "success",
        author: {
                  name: "John Doe",
                  email: "[email protected]"
                },
        title: "John Doe's contacts",
        pagination: {
                      limit: 25,
                      offset: 26,
                      total: 100,
                      next,
                      previous,
                     },
        data: [
             [0]: {
                    id: "http://www.google.com/m8/feeds/contacts/email%40example.com/base/0",
                    email: [
                            [0]: [
                                  "[email protected]",
                                  "[email protected]"
                                 ]
                           ],
                    name: "Some Contact"
                  }

               ]
      }

Contacts from Group

function: contactsFromGroup

required arguments:

  • groupLink
  • callback

example:

Gcontacts.contactsFromGroup(groupLink, callback, pagination, raw)

response:

      {
        status: "success",
        author: {
                  name: "John Doe",
                  email: "[email protected]"
                },
        title: "John Doe's contacts",
        pagination: {
                      limit: 25,
                      offset: 26,
                      total: 100,
                      next,
                      previous
                     },
        data: [
             [0]: {
                    id: "http://www.google.com/m8/feeds/contacts/email%40example.com/base/0",
                    email: [
                            [0]: [
                                  "[email protected]",
                                  "[email protected]"
                                 ]
                           ],
                    name: "Some Contact"
                  }

               ]
      }

Groups

function: groups

required arguments:

  • callback

example:

Gcontacts.groups(callback, pagination, raw)

response:

      {
        status: "success",
        author: {
                  name: "John Doe",
                  email: "[email protected]"
                },
        title: "John Doe's contacts",
        pagination: {
                      limit: 25,
                      offset: 1,
                      total: 30,
                      next,
                      previous
                    },
        data: [
                [0]: {
                       id: "http://www.google.com/m8/feeds/groups/email%40example.com/base/162d77938sd212345",
                       name: "Some Group"
                     }
              ]
      }

Contrib!

first clone the repository

# git clone [email protected]:eventioz/gcontacts.git

then if you whant to use the examples

# git clone -b gh-pages [email protected]:eventioz/gcontacts.git examples/

and you are good to go!