Git Product home page Git Product logo

gcontacts's Introduction

Gcontacts

Client-Side tool for handleing 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!

gcontacts's People

Contributors

gagoar avatar miloops avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.