# README
pixela4go
Pixela API client for Go.
Documentation
https://godoc.org/github.com/ebc-2in2crc/pixela4go
Installation
$ go get -u github.com/ebc-2in2crc/pixela4go
Usage
package main
import (
"context"
"log"
pixela "github.com/ebc-2in2crc/pixela4go"
)
func main() {
// Specify the number of retries if you want to retry when the API call is rejected.
// If you do not want to retry, you do not need to specify it.
pixela.RetryCount = 10
client := pixela.New("YOUR_NAME", "YOUR_TOKEN")
// Create new user
uci := &pixela.UserCreateInput{
AgreeTermsOfService: pixela.Bool(true),
NotMinor: pixela.Bool(true),
ThanksCode: pixela.String("thanks-code"),
}
result, err := client.User().CreateWithContext(context.Background(), uci)
if err != nil {
log.Fatal(err)
}
if result.IsSuccess == false {
log.Fatal(result.Message)
}
// Updates the profile information for the user
upi := &pixela.UserProfileUpdateInput{
DisplayName: pixela.String("display-name"),
GravatarIconEmail: pixela.String("gravatar-icon-email"),
Title: pixela.String("title"),
Timezone: pixela.String("Asia/Tokyo"),
AboutURL: pixela.String("https://github.com/ebc-2in2crc"),
ContributeURLs: []string{},
PinnedGraphID: pixela.String("pinned-graph-id"),
}
result, err = client.UserProfile().UpdateWithContext(context.Background(), upi)
if err != nil {
log.Fatal(err)
}
if result.IsSuccess == false {
log.Fatal(result.Message)
}
// Create new graph
gci := &pixela.GraphCreateInput{
ID: pixela.String("graph-id"),
Name: pixela.String("graph-name"),
Unit: pixela.String("commit"),
Type: pixela.String(pixela.GraphTypeInt),
Color: pixela.String(pixela.GraphColorShibafu),
TimeZone: pixela.String("Asia/Tokyo"),
SelfSufficient: pixela.String(pixela.GraphSelfSufficientIncrement),
IsSecret: pixela.Bool(true),
PublishOptionalData: pixela.Bool(true),
}
result, err = client.Graph().CreateWithContext(context.Background(), gci)
if err != nil {
log.Fatal(err)
}
if result.IsSuccess == false {
log.Fatal(result.Message)
}
// Register value
pci := &pixela.PixelCreateInput{
Date: pixela.String("20180915"),
Quantity: pixela.String("5"),
GraphID: pixela.String("graph-id"),
}
result, err = client.Pixel().CreateWithContext(context.Background(), pci)
if err != nil {
log.Fatal(err)
}
if result.IsSuccess == false {
log.Fatal(result.Message)
}
// Create new webhook
wci := &pixela.WebhookCreateInput{
GraphID: pixela.String("graph-id"),
Type: pixela.String(pixela.WebhookTypeIncrement),
}
webhook, err := client.Webhook().CreateWithContext(context.Background(), wci)
if err != nil {
log.Fatal(err)
}
if webhook.IsSuccess == false {
log.Fatal(webhook.Message)
}
// Invoke webhook
wii := &pixela.WebhookInvokeInput{WebhookHash: pixela.String("webhook-hash")}
result, err = client.Webhook().InvokeWithContext(context.Background(), wii)
if err != nil {
log.Fatal(err)
}
if result.IsSuccess == false {
log.Fatal(result.Message)
}
}
Contribution
- Fork this repository
- Create your issue branch (
git checkout -b issue/:id
) - Change codes
- Run test suite with the
make test
command and confirm that it passes - Run
make fmt
- Commit your changes (
git commit -am 'Add some feature'
) - Create new Pull Request
License
Author
# Functions
Bool returns a pointer to the bool value passed in.
BoolValue returns the value of the bool pointer passed in or false if the pointer is nil.
New return a new Client instance.
String returns a pointer to the string value passed in.
StringValue returns the value of the string pointer passed in or "" if the pointer is nil.
# Constants
APIBaseURL is Base URL for API requests.
APIBaseURLForV1 is Base URL for API version 1 requests.
Dark theme.
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.
Specify the behavior when this Webhook is invoked.
Specify the behavior when this Webhook is invoked.
Specify the behavior when this Webhook is invoked.
Specify the behavior when this Webhook is invoked.
Specify the behavior when this Webhook is invoked.
# Variables
ErrAPICallRejected API call rejected.
RetryCount number of retries when an API call is rejected (max: 20).
# Structs
A Client manages communication with the Pixela User API.
A Graph manages communication with the Pixela graph API.
GraphAddInput is input of Graph.Add().
GraphCreateInput is input of Graph.Create().
GraphDefinition is graph definition.
GraphDefinitions is graph definition list.
GraphDeleteInput is input of Graph.Delete().
GraphGetInput is input of Graph.Get().
GraphGetPixelDatesInput is input of Graph.GetPixelDates().
GraphGetSVGInput is input of Graph.GetSVG().
GraphStatsInput is input of Graph.Stats().
GraphStopwatchInput is input of Graph.Stopwatch().
GraphSubtractInput is input of Graph.Subtract().
GraphUpdateInput is input of Graph.Update().
GraphUpdatePixelsInput is input of Graph.UpdatePixels().
GraphURLInput is input of Graph.GetURL().
A Pixel manages communication with the Pixela pixel API.
PixelCreateInput is input of Pixel.Create().
PixelDecrementInput is input of Pixel.Decrement().
PixelDeleteInput is input of Pixel.Delete().
PixelGetInput is input of Pixel.Get().
PixelIncrementInput is input of Pixel.Increment().
PixelInput is input of Graph.UpdatePixels().
Pixels is Date list of Pixel registered in the graph.
PixelUpdateInput is input of Pixel.Update().
PixelWithBody is Date of Pixel registered in the graph.
Quantity ..
Result is Pixela API Result struct.
Stats is various statistics based on the registered information.
A User manages communication with the Pixela user API.
UserCreateInput is input of User.Create().
A UserProfile manages communication with the Pixela user profile API.
UserProfileUpdateInput is input of UserProfile.Update().
UserUpdateInput is input of User.Update().
A Webhook manages communication with the Pixela webhook API.
WebhookCreateInput is input of Webhook.Create().
WebhookCreateResult is Create() Result struct.
WebhookDefinition is webhook definition.
WebhookDefinitions is webhook definition list.
WebhookDeleteInput is input of Webhook.Delete().
# Type aliases
WebhookInvokeInput is input of Webhook.Invoke().