Giter Site home page Giter Site logo

togglapi.net's Introduction

TogglAPI.Net

TogglAPI.Netstandard is a .Net Standard C# wrapper for the toggl.com api

Warning!

For correct usage you need to change default client-key. You can find it on bottom of the page (https://www.toggl.com/app/profile). You need a pro version to use tasks, otherwise some tests will fail.

Code Samples

The heavy lifting happens in the dir Toggl/Services. In the services you can create an instance of a service with an api key or a default api key located in the app.config. the api key 2d1d95cef10e17831ec505e9e6f9f7ea is a test account so please use it as you see fit.

Get List Of Clients

    var srv = new ClientService();
    var obj = srv.List();

###OR

    var t = new Toggl.Toggl();
    var obj = t.Client.List();

Get Current User

    var apiKey="2d1d95cef10e17831ec505e9e6f9f7ea";
    var usrSrv = new Toggl.Services.UserService(apiKey);
    var c = usrSrv.GetCurrent();
    Console.WriteLine(c.FullName);
    Console.WriteLine(c.Email);

###OR

    var apiKey="2d1d95cef10e17831ec505e9e6f9f7ea";
    var t = new Toggl.Toggl(apiKey);
    var c = t.User.GetCurrent();
    Console.WriteLine(c.FullName);
    Console.WriteLine(c.Email);

Get Hours Worked For Time Period

    var apiKey="2d1d95cef10e17831ec505e9e6f9f7ea";
    var timeSrv= new Toggl.Services.TimeEntryService(apiKey);
    var prams = new TimeEntryParams();

    // there is an issue with the date ranges have
    // to step out of the range on the end.
    // To capture the end of the billing range day + 1
    prams.StartDate = Convert.ToDateTime("11/1/2012");
    prams.EndDate = Convert.ToDateTime("11/16/2012");

    var hours = timeSrv.List(prams)
                            .Where(w=>!string.IsNullOrEmpty(w.Description));

    hours.Select(s=>s);

###OR

    var timeSrv= new Toggl.Toggl().TimeEntry;
    var prams = new TimeEntryParams();

    // there is an issue with the date ranges have
    // to step out of the range on the end.
    // To capture the end of the billing range day + 1
    prams.StartDate = Convert.ToDateTime("11/1/2012");
    prams.EndDate = Convert.ToDateTime("11/16/2012");

    var hours = timeSrv.List(prams)
                            .Where(w=>!string.IsNullOrEmpty(w.Description));

    hours.Select(s=>s).Dump();

For more code samples check out the the Toggl.Tests Project

Copyright

Copyright (c) 2014 Pirozhenko Ilya. See LICENSE for details.

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.