Git Product home page Git Product logo

jstoggl's Introduction

JSToggl

An API wrapper to simplify interactions with the official Toggl API.

Find out more about Toggl.

Usage

You will need your API token that you can find in your Toggl profile.

You will also likely need to get the domain that you will be making requests from whitelisted so that the API returns the correct CORS headers. You can do so by emailing [email protected] with your domain name and requesting that it be added. They usually respond within 24 hours of making the request.

You will also require jQuery, but I hope to remove this requirement as it is really only being used to make the AJAX request.

Create your client

var Toggl = TogglClient(myToken);

Start and stop a timer

All requests return a promise with the API response that you can then use.

var timerId;
Toggl.timers.start('My Test Timer').then(function(timer){
    // Do stuff - eg. toggle the button state to stop the timer
    timerId = timer.data.id;
});

Toggl.timers.stop(timerId).then(function(){
    // Do stuff - eg. toggle the button state back to start another timer
});

Get the currently running timer

var timerId;
Toggl.timers.current().then(function(timer){
    if(timer.data !== null)
        timerId = timer.data.id;
    }
});

Create a new Client

Toggl.clients.create('My Client Pty Ltd').then(function(client){
    
});

Create projects assigned to a client

Toggl.clients.getProjects(clientId).then(function(projectArray){
    // for(var i = 0; i < projectArray.length; i++){ ... }
});

License

JSToggl may be freely distributed under the GPL v2 license.

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.