Giter Club home page Giter Club logo

go-wakatime's Introduction

go-wakatime api

GoDoc GolangCI Go Report Card Build Status Coverage Status API Coverage

This package contains a golang implementation of Wakatime's API V1. I didn't like the other implementations of go-wakatime so I made this one.

Explore the swagger file with Redoc

Generated from swagger spec for the most part except for some exceptions

  1. The swagger spec has not default date parse for the likes of 01/31/2019, so the internal package houses a near replica of the date type the strfmt that open-api has.
  2. Some parts have not been full tested so if you notice something or have an error open an issue.
  3. go-swagger has not be pleasant with custom types as I have to make the whole struct type, which i tried to avoid. Luckily, wakatime used a lot of formats the openapi has standardized in the strfmt package.

Example

package main

import (
	"context"
	"fmt"
	"github.com/go-openapi/strfmt"
	user2 "github.com/will7200/go-wakatime/client/user"
	"net/http"
	"os"
	"time"

	httptransport "github.com/go-openapi/runtime/client"
	"github.com/kr/pretty"
	apiclient "github.com/will7200/go-wakatime/client"
)

func main() {
	defaultT := apiclient.DefaultTransportConfig()
	runtime := httptransport.NewWithClient(defaultT.Host, defaultT.BasePath, defaultT.Schemes,
		&http.Client{Timeout: 10 * time.Second, Transport: http.DefaultTransport})
	client := apiclient.New(runtime, strfmt.Default)

	apiKeyAuth := httptransport.APIKeyAuth("api_key", "query", os.Getenv("WAKATIME_API_KEY"))

	user, err := client.User.User(nil, apiKeyAuth)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%# v\n", pretty.Formatter(user))

	params := user2.SummariesParams{
		Start:   strfmt.Date(time.Now().Add(-1 * time.Hour * 24)),
		End:     strfmt.Date(time.Now()),
		User:    "current",
		Context: context.Background(),
	}
	use, err := client.User.Summaries(&params, apiKeyAuth)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%# v\n", pretty.Formatter(use))
}

Build

Make changes to swagger.yml

swagger generate client

go-wakatime's People

Contributors

will7200 avatar

Stargazers

 avatar

Watchers

 avatar  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.