Categorygithub.com/ebc-2in2crc/pixela-client-go
modulepackage
1.3.0
Repository: https://github.com/ebc-2in2crc/pixela-client-go.git
Documentation: pkg.go.dev

# README

English | 日本語

pixela-client-go

Build Status MIT License GoDoc Go Report Card Version

Note: Active development on pixela-client-go has stopped. The only future changes will be bug fixes.

Please see pixela4go.

Pixela API client for Go.

Cloning count

Documentation

https://godoc.org/github.com/ebc-2in2crc/pixela-client-go

Installation

$ go get -u github.com/ebc-2in2crc/pixela-client-go

Usage

package main

import (
	"log"
	
	"github.com/ebc-2in2crc/pixela-client-go"
)

func main() {
	client := pixela.NewClient("YOUR_NAME", "YOUR_TOKEN")

	// create new user
	result, err := client.CreateUser(true, true, "")
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// create new graph
	result, err = client.Graph("graph-id").Create(
		"graph-name",
		"commit",
		pixela.TypeInt,
		pixela.ColorShibafu,
		"Asia/Tokyo",
		pixela.SelfSufficientNone,
		false,
		false,
	)
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// register value
	result, err = client.Pixel("graph-id").Create("20180915", "5", "")
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// increment value
	result, err = client.Pixel("graph-id").Increment()
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}

	// create new webhook
	webhook, err := client.Webhook().Create("graph-id", pixela.SelfSufficientIncrement)
	if err != nil {
		log.Fatal(err)
	}
	if webhook.IsSuccess == false {
		log.Fatal(webhook.Message)
	}

	// invoke webhook
	result, err = client.Webhook().Invoke(webhook.WebhookHash)
	if err != nil {
		log.Fatal(err)
	}
	if result.IsSuccess == false {
		log.Fatal(result.Message)
	}
}

Contribution

  1. Fork this repository
  2. Create your issue branch (git checkout -b issue/:id)
  3. Change codes
  4. Run test suite with the make test command and confirm that it passes
  5. Run make fmt
  6. Commit your changes (git commit -am 'Add some feature')
  7. Create new Pull Request

License

MIT

Author

ebc-2in2crc

# Functions

NewClient return a new Client instance.

# Constants

APIBaseURL is Base URL for API requests.
Defines the display color of the pixel in the pixelation graph.
Defines the display color of the pixel in the pixelation graph.
Defines the display color of the pixel in the pixelation graph.
Defines the display color of the pixel in the pixelation graph.
Defines the display color of the pixel in the pixelation graph.
Defines the display color of the pixel in the pixelation graph.
Specify the graph display mode.
Specify the graph display mode.
Specify the graph display mode.
Specify the graph display mode in html format.
Specify the graph display mode in html format.
If SVG graph with this field increment or decrement is referenced, Pixel of this graph itself will be incremented or decremented.
If SVG graph with this field increment or decrement is referenced, Pixel of this graph itself will be incremented or decremented.
If SVG graph with this field increment or decrement is referenced, Pixel of this graph itself will be incremented or decremented.
It is the type of quantity to be handled in the graph.
It is the type of quantity to be handled in the graph.

# Structs

A Client manages communication with the Pixela User API.
A Graph manages communication with the Pixela graph API.
GraphDefinition is graph definition.
GraphDefinitions is graph definition list.
A Pixel manages communication with the Pixela pixel API.
Pixels is Date list of Pixel registered in the graph.
Quantity ..
Result is Pixela API Result struct.
Stats is various statistics based on the registered information.
A Webhook manages communication with the Pixela webhook API.
WebhookCreateResult is Create() Result struct.
WebhookDefinition is webhook definition.
WebhookDefinitions is webhook definition list.